/* ═══════════════════════════════════════════════════
   EntryLMS Design System — Django edition
   Accent: #76B900 (NVIDIA green)
   ═══════════════════════════════════════════════════ */

/* ── Google Fonts (JetBrains Mono + Inter) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Design tokens */
:root {
  --bg:           oklch(0.985 0.003 110);
  --panel:        #ffffff;
  --ink:          oklch(0.18 0.01 260);
  --ink-2:        oklch(0.42 0.01 260);
  --ink-3:        oklch(0.62 0.008 260);
  --line:         oklch(0.92 0.005 260);
  --line-2:       oklch(0.96 0.004 260);
  --hover:        oklch(0.97 0.008 130);
  --accent:       #76B900;
  --accent-ink:   #3d6b00;
  --accent-wash:  oklch(0.97 0.05 130);
  --accent-wash-2:oklch(0.93 0.09 130);
  --warn:         #D97706;
  --warn-wash:    oklch(0.96 0.05 80);
  --danger:       #B91C1C;
  --danger-wash:  oklch(0.96 0.035 25);
  --info:         #2563eb;
  --info-wash:    oklch(0.96 0.03 250);
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;
  --radius:       10px;
  --radius-sm:    6px;
  --side-w:       224px;
}

/* ── Base reset */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  height: 100%;
}
button { font-family: inherit; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.num  { font-variant-numeric: tabular-nums; }

/* ═══════════════════════════════
   APP SHELL
   ═══════════════════════════════ */
.lms-app {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns .18s ease;
}
.lms-app.compact { grid-template-columns: 56px 1fr; }

/* ─── Sidebar */
.lms-side {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100vh;
  position: sticky;
  top: 0;
}

.lms-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
  min-height: 52px;
  overflow: hidden;
}
.lms-logo {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid; place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}
.lms-logo img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.lms-brand-text { min-width: 0; overflow: hidden; }
.lms-brand-name { font-weight: 700; font-size: 13.5px; letter-spacing: -0.01em; white-space: nowrap; }
.lms-brand-env  { font-size: 10.5px; color: var(--ink-3); margin-top: 1px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }

.lms-app.compact .lms-brand-text { display: none; }

.lms-nav {
  padding: 8px 6px;
  overflow-y: auto;
  flex: 1;
}
.lms-nav::-webkit-scrollbar { width: 6px; }
.lms-nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.lms-nav-label {
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 10px 12px 6px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}
.lms-app.compact .lms-nav-label { opacity: 0; height: 6px; padding: 0; }

.lms-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  position: relative;
  margin: 1px 0;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  transition: background .12s, color .12s;
  white-space: nowrap;
  overflow: hidden;
}
.lms-nav-item:hover { background: var(--line-2); color: var(--ink); text-decoration: none; }
.lms-nav-item.active {
  background: var(--accent-wash);
  color: var(--accent-ink);
  font-weight: 600;
}
.lms-nav-item.active::before {
  content: "";
  position: absolute; left: -6px; top: 6px; bottom: 6px;
  width: 3px; border-radius: 2px;
  background: var(--accent);
}
.lms-nav-item .nav-icon { width: 18px; height: 18px; display: grid; place-items: center; flex-shrink: 0; }
.lms-nav-item .nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.lms-nav-item .nav-count {
  margin-left: auto;
  font-size: 11px; color: var(--ink-3);
  background: var(--line-2);
  padding: 1px 6px; border-radius: 10px;
  font-weight: 600; flex-shrink: 0;
}
.lms-nav-item.active .nav-count { background: var(--accent-wash-2); color: var(--accent-ink); }

.lms-app.compact .lms-nav-item { justify-content: center; padding: 8px; }
.lms-app.compact .nav-label,
.lms-app.compact .nav-count { display: none; }

.lms-side-foot {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  overflow: hidden;
}
.lms-app.compact .lms-side-foot .side-foot-meta { display: none; }
.side-foot-meta { font-size: 12px; min-width: 0; overflow: hidden; }
.side-foot-meta .sfm-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot-meta .sfm-role { font-size: 11px; color: var(--ink-3); white-space: nowrap; }

/* ─── Main area */
.lms-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  height: 100vh;
}

/* ─── Top bar */
.lms-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  min-height: 52px;
  flex-shrink: 0;
}
.lms-crumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--ink-3);
}
.lms-crumb .crumb-cur { color: var(--ink); font-weight: 600; }
.lms-crumb svg { opacity: .4; }
.lms-search-btn {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  background: var(--bg);
  cursor: pointer;
  color: var(--ink-3);
  font-size: 12.5px;
  min-width: 260px;
  font-family: inherit;
  transition: border-color .12s;
}
.lms-search-btn:hover { border-color: var(--ink-3); }

/* ─── Content area */
.lms-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}
.lms-content.flush { padding: 0; }

/* ═══════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════ */
h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.02em; color: var(--ink); }
h2 { font-size: 15px; font-weight: 600; margin: 0; color: var(--ink); }
h3 { font-size: 13px; font-weight: 600; margin: 0; color: var(--ink); }
.sub { color: var(--ink-3); font-size: 12.5px; }
.muted { color: var(--ink-3); }

/* ═══════════════════════════════
   COMPONENTS
   ═══════════════════════════════ */

/* ─── Avatar */
.lms-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-wash-2);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: 11px;
  flex-shrink: 0;
  user-select: none;
}

/* ─── kbd */
.kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink-2);
}

/* ─── Icon button */
.lms-iconbtn {
  width: 30px; height: 30px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--ink-2);
  transition: background .12s, color .12s;
  padding: 0;
}
.lms-iconbtn:hover { background: var(--line-2); color: var(--ink); }
.lms-iconbtn.rel { position: relative; }

/* ─── Card */
.lms-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.lms-card-h {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  min-height: 46px;
}
.lms-card-b { padding: 16px; }

/* ─── Buttons */
.lms-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 12.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  font-family: inherit;
  transition: background .12s, border-color .12s;
  text-decoration: none;
}
.lms-btn:hover { background: var(--line-2); border-color: var(--ink-3); color: var(--ink); text-decoration: none; }
.lms-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.lms-btn.primary:hover { background: #649e00; border-color: #649e00; color: #fff; }
.lms-btn.ghost { border-color: transparent; background: transparent; }
.lms-btn.ghost:hover { background: var(--line-2); }
.lms-btn.sm { padding: 4px 9px; font-size: 12px; gap: 5px; }
.lms-btn.danger { color: var(--danger); border-color: transparent; }
.lms-btn.danger:hover { background: var(--danger-wash); }

/* ─── Badges */
.lms-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
}
.lms-badge .bdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-pending     { background: oklch(0.96 0.02 260); color: #4a5568; }
.b-draft       { background: oklch(0.95 0.005 260); color: var(--ink-3); }
.b-submitted   { background: oklch(0.94 0.04 250); color: #3b5bdb; }
.b-under_review { background: var(--warn-wash); color: var(--warn); }
.b-approved    { background: var(--info-wash); color: var(--info); }
.b-active    { background: var(--accent-wash); color: var(--accent-ink); }
.b-disbursed { background: oklch(0.94 0.03 210); color: #0e7490; }
.b-closed    { background: oklch(0.92 0.005 260); color: var(--ink-3); }
.b-rejected  { background: var(--danger-wash); color: var(--danger); }
.b-overdue   { background: var(--danger-wash); color: var(--danger); }
.b-blacklisted { background: var(--danger-wash); color: var(--danger); }
.b-inactive  { background: oklch(0.92 0.005 260); color: var(--ink-3); }
.b-emergency { background: var(--warn-wash); color: var(--warn); }

/* ─── KPI strip */
.lms-kpi {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.lms-kpi .cell {
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 3px;
  cursor: pointer;
  transition: background .12s;
}
.lms-kpi .cell:last-child { border-right: none; }
.lms-kpi .cell:hover { background: var(--line-2); }
.lms-kpi .cell.active { background: var(--accent-wash); }

/* ─── KPI 6-cell layout */
.lms-kpi-6 { grid-template-columns: repeat(6, 1fr); }

/* ─── Loan detail grids */
.loan-overview-grid { grid-template-columns: 2fr 1fr; }
.loan-stats-grid    { grid-template-columns: repeat(3, 1fr); }

/* ─── Dashboard grids */
.dash-main-grid   { grid-template-columns: 1.35fr 1fr; }
.dash-charts-grid { grid-template-columns: 1.5fr 1fr; }

/* ─── Borrower detail 2-col */
.detail-two-col { grid-template-columns: 1fr 1fr; }
.lms-kpi .cell .kl { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.lms-kpi .cell .kv { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.lms-kpi .cell .kd { font-size: 11px; color: var(--ink-3); }
.lms-kpi .cell .kd.up { color: var(--accent-ink); }
.lms-kpi .cell .kd.dn { color: var(--danger); }

/* ─── Data table */
.lms-dt {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.75px;
}
.lms-dt thead th {
  position: sticky; top: 0;
  background: oklch(0.975 0.003 110);
  z-index: 2;
  text-align: left;
  padding: 8px 12px;
  font-weight: 600; color: var(--ink-2);
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.lms-dt thead th:hover { color: var(--ink); background: var(--line-2); }
.lms-dt tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
.lms-dt tbody tr { cursor: pointer; }
.lms-dt tbody tr:hover { background: var(--hover); }
.lms-dt .num-col { text-align: right; }

/* ─── Row actions */
.row-act {
  opacity: 0;
  transition: opacity .12s;
  display: flex; gap: 3px; justify-content: flex-end;
}
.lms-dt tbody tr:hover .row-act { opacity: 1; }

/* ─── Mini cell */
.mini-cell { display: flex; flex-direction: column; line-height: 1.25; }
.mini-cell .mc-sub { font-size: 11px; color: var(--ink-3); }

/* ─── Filter chips */
.lms-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.lms-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 12px; font-weight: 500;
  cursor: pointer; color: var(--ink-2);
  font-family: inherit;
  transition: background .12s, color .12s;
  text-decoration: none;
}
.lms-chip:hover { background: var(--line-2); color: var(--ink); text-decoration: none; }
.lms-chip.on { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.lms-chip.on span[style*="opacity"] { opacity: 1 !important; color: rgba(255,255,255,.6); }
.lms-chip.add { border-style: dashed; color: var(--ink-3); }

/* ─── Inputs */
.lms-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit; font-size: 12.75px;
  background: var(--panel); color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
.lms-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash-2);
}
.lms-inputgrp {
  display: flex; align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  padding: 0 8px; gap: 6px;
  transition: border-color .12s, box-shadow .12s;
}
.lms-inputgrp:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash-2);
}
.lms-inputgrp input {
  border: none; outline: none;
  background: transparent;
  padding: 7px 0;
  font: inherit; flex: 1;
  color: var(--ink); min-width: 0;
}
.req { color: var(--danger); }

/* ─── Progress bar */
.lms-progress {
  display: flex; align-items: center; gap: 6px;
  min-width: 110px;
}
.lms-progress-track {
  flex: 1; height: 6px;
  background: var(--line-2); border-radius: 3px; overflow: hidden;
}
.lms-progress-fill {
  height: 100%; background: var(--accent); border-radius: 3px;
  transition: width .2s;
}
.lms-progress-fill.overdue { background: var(--danger); }
.lms-progress-pct { font-size: 11px; color: var(--ink-3); width: 32px; font-variant-numeric: tabular-nums; }

/* ─── Tag */
.lms-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--line-2);
  font-size: 11px; color: var(--ink-2); font-weight: 500;
}
.lms-tag.emg { background: var(--warn-wash); color: var(--warn); }

/* ─── Tabs */
.lms-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
.lms-tab {
  padding: 10px 14px;
  font-size: 13px; color: var(--ink-3);
  cursor: pointer;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  font-family: inherit;
  font-weight: 500;
  text-decoration: none;
  transition: color .12s;
  white-space: nowrap;
}
.lms-tab:hover { color: var(--ink); text-decoration: none; }
.lms-tab.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

/* ─── Workflow strip */
.lms-flow {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
}
.lms-flow .flow-st {
  padding: 10px 12px;
  background: var(--line-2);
}
.lms-flow .flow-st:first-child { border-radius: 8px 0 0 8px; }
.lms-flow .flow-st:last-child  { border-radius: 0 8px 8px 0; }
.lms-flow .flow-st.done { background: var(--accent-wash); color: var(--accent-ink); }
.lms-flow .flow-st.cur  { background: var(--accent); color: #fff; }
.lms-flow .flow-st .ft { font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; opacity: .85; }
.lms-flow .flow-st .fn { font-weight: 600; font-size: 13px; }
.lms-flow .flow-st .fd { font-size: 10.5px; opacity: .8; margin-top: 1px; }

/* ─── Sched (amortization) table */
.lms-sched {
  width: 100%;
  border-collapse: separate; border-spacing: 0;
  font-size: 12px;
}
.lms-sched th {
  padding: 8px 10px;
  background: oklch(0.975 0.003 110);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-3); text-align: right;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.lms-sched th:first-child, .lms-sched th:nth-child(2) { text-align: left; }
.lms-sched td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.lms-sched td:first-child, .lms-sched td:nth-child(2) { text-align: left; }
.lms-sched tr.paid { background: oklch(0.985 0.01 130); }
.lms-sched tr.paid td { color: var(--ink-2); }
.lms-sched tr.next { background: oklch(0.97 0.05 85); }

/* ─── FAB */
.lms-fab {
  position: fixed; right: 22px; bottom: 22px;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--accent); color: #fff;
  border: none; display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(118,185,0,.35);
  z-index: 20;
  transition: background .12s, transform .12s;
}
.lms-fab:hover { background: #649e00; transform: scale(1.05); }

/* ─── Command palette */
.lms-cmdbox {
  position: fixed; top: 12vh;
  left: 50%; transform: translateX(-50%);
  width: 620px; max-width: 92vw;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 30px 60px rgba(0,0,0,.22);
  z-index: 80;
  overflow: hidden;
  animation: cmdin .15s ease;
}
@keyframes cmdin {
  from { transform: translate(-50%, -8px); opacity: 0; }
  to   { transform: translate(-50%, 0);    opacity: 1; }
}
.cmd-input {
  width: 100%; border: none; outline: none;
  padding: 16px 18px;
  font-size: 15px; font-family: inherit;
  background: transparent; color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.cmd-list { max-height: 50vh; overflow: auto; padding: 6px; }
.cmd-group {
  font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
  padding: 8px 12px 4px; font-weight: 600;
}
.cmd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 7px;
  cursor: pointer; font-size: 13px;
  transition: background .1s;
}
.cmd-item:hover, .cmd-item.sel { background: var(--accent-wash); color: var(--accent-ink); }
.cmd-item .cmd-sh { margin-left: auto; font-size: 10.5px; color: var(--ink-3); }
.cmd-foot {
  border-top: 1px solid var(--line);
  padding: 8px 14px;
  font-size: 11px; color: var(--ink-3);
  display: flex; gap: 14px;
}

/* ─── Overlay */
.lms-overlay {
  position: fixed; inset: 0;
  background: rgba(15,20,30,.35);
  z-index: 50;
  backdrop-filter: blur(2px);
}

/* ─── Quick action pills (dashboard) */
.lms-qpill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer; text-decoration: none;
  color: var(--ink); font-size: 13px;
  transition: border-color .12s, box-shadow .12s;
}
.lms-qpill:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(118,185,0,.08);
  text-decoration: none; color: var(--ink);
}
.lms-qpill-ico {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent-wash);
  color: var(--accent-ink);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.lms-qpill .ql { font-weight: 600; }
.lms-qpill .qs { font-size: 11px; color: var(--ink-3); }

/* ─── Detail header */
.lms-detail-hdr {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.lms-ring {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--accent-wash-2);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}

/* ─── Stat box */
.lms-stat .stat-label {
  font-size: 10.5px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-3);
  font-weight: 600;
}
.lms-stat .stat-val {
  font-size: 15px; font-weight: 600;
  color: var(--ink); margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.lms-stat .stat-val.em { font-size: 20px; font-weight: 700; color: var(--accent-ink); }

/* ─── Info row */
.lms-inforow {
  display: flex; align-items: center; gap: 8px;
  color: var(--ink-2); font-size: 12.5px;
}

/* ─── HR divider */
.lms-hr { height: 1px; background: var(--line); margin: 12px 0; }

/* ─── Key/value grid (borrower detail) */
.lms-kv-grid {
  display: grid; grid-template-columns: auto 1fr;
  gap: 6px 16px; font-size: 13px;
}
.kv-label {
  font-size: 11.5px; color: var(--ink-3); font-weight: 500;
  white-space: nowrap; padding-top: 1px;
}
.kv-val { color: var(--ink); word-break: break-word; }

/* ─── Page filter bar */
.lms-filterbar {
  padding: 10px 14px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  border-bottom: 1px solid var(--line-2);
}

/* ─── Pagination footer */
.lms-pager {
  padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--ink-3);
  border-top: 1px solid var(--line-2);
}

/* ─── Tooltip */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 4px 8px; border-radius: 5px;
  font-size: 11px; white-space: nowrap; z-index: 100; font-weight: 500;
  pointer-events: none;
}

/* ═══════════════════════════════
   UTILITY
   ═══════════════════════════════ */
.pulse::after {
  content: ""; display: inline-block;
  width: 6px; height: 6px;
  background: var(--accent); border-radius: 50%;
  margin-left: 6px;
  animation: pulse 1.6s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ═══════════════════════════════
   BOOTSTRAP OVERRIDES
   (crispy-forms uses Bootstrap classes)
   ═══════════════════════════════ */
.form-control, .form-select {
  border-radius: 7px !important;
  border-color: var(--line) !important;
  font-size: 12.75px !important;
  font-family: inherit !important;
  background: var(--panel) !important;
  color: var(--ink) !important;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-wash-2) !important;
  outline: none !important;
}
.form-label { font-size: 11.5px !important; font-weight: 600 !important; color: var(--ink-2) !important; }
.btn-primary {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
  font-family: inherit !important;
}
.btn-primary:hover {
  background: #649e00 !important;
  border-color: #649e00 !important;
}
.btn-outline-secondary { font-family: inherit !important; }
.alert-success { background: var(--accent-wash) !important; border-color: var(--accent-wash-2) !important; color: var(--accent-ink) !important; }
.alert-danger  { background: var(--danger-wash) !important; color: var(--danger) !important; }
.alert-warning { background: var(--warn-wash) !important; color: var(--warn) !important; }

/* ═══════════════════════════════
   MOBILE
   ═══════════════════════════════ */
@media (max-width: 767px) {
  /* Switch from grid to block so .lms-main fills full viewport width */
  .lms-app {
    display: block;
    position: relative;
  }

  /* Sidebar: fixed overlay, slides in from left */
  .lms-side {
    position: fixed;
    top: 0; left: 0;
    width: var(--side-w);
    height: 100%;
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 200;
  }
  .lms-app.mobile-open .lms-side { transform: translateX(0); }

  /* Main area: full width, natural document scroll */
  .lms-main {
    width: 100%;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  /* Content: natural height so page scrolls freely */
  .lms-content {
    overflow-y: visible;
    height: auto;
    padding: 14px 16px;
  }

  .lms-search-btn { min-width: 120px; }

  /* KPI 6-cell: collapse to 3×2 */
  .lms-kpi-6 { grid-template-columns: repeat(3, 1fr) !important; }
  .lms-kpi-6 .cell:nth-child(3) { border-right: none; }
  .lms-kpi-6 .cell:nth-child(4),
  .lms-kpi-6 .cell:nth-child(5),
  .lms-kpi-6 .cell:nth-child(6) { border-top: 1px solid var(--line); }

  /* Table: hide low-priority columns on small screens (global utility) */
  .hide-mobile { display: none !important; }

  /* Row actions: always visible on touch (no hover state) */
  .row-act { opacity: 1; }

  /* Loan detail header: stack vertically */
  .lms-detail-hdr {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 16px;
  }

  /* Loan overview: single column */
  .loan-overview-grid { grid-template-columns: 1fr !important; }

  /* Loan stats: 3-col → 2-col */
  .loan-stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .loan-stats-grid .stat-span-3 { grid-column: span 2 !important; }

  /* Workflow strip: scroll horizontally */
  .lms-flow {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
    gap: 0;
    -webkit-overflow-scrolling: touch;
  }
  .flow-st { min-width: 80px; flex-shrink: 0; }

  /* Topbar: hide search text, collapse to icon only */
  .lms-topbar { padding: 8px 14px; gap: 8px; }
  .lms-search-btn { min-width: 36px; width: 36px; padding: 0; justify-content: center; }
  .lms-search-btn span:not(.kbd) { display: none; }
  .lms-search-btn .kbd { display: none; }

  /* Dashboard: stack all multi-col grids */
  .dash-main-grid   { grid-template-columns: 1fr !important; }
  .dash-charts-grid { grid-template-columns: 1fr !important; }

  /* Borrower detail 2-col: stack */
  .detail-two-col { grid-template-columns: 1fr !important; }

  /* Page header: stack title and buttons */
  .dash-page-hdr { flex-direction: column; align-items: flex-start; gap: 10px; }
}

/* ═══════════════════════════════
   PRINT
   ═══════════════════════════════ */
@media print {
  .lms-side, .lms-topbar, .lms-fab { display: none !important; }
  .lms-app { display: block; }
  .lms-content { overflow: visible; padding: 0; }
}
