/* ==========================================================================
   LRMS — Loan Recovery Management System
   Single stylesheet. No external fonts or CDNs so the strict CSP holds.
   ========================================================================== */

:root {
  --navy-900: #0b1220;
  --navy-800: #111c31;
  --navy-700: #1a2942;
  --navy-600: #24374f;
  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --surface: #ffffff;
  --canvas: #f4f6fa;
  --brand: #1e3a5f;
  --brand-600: #24507f;
  --brand-100: #e8eef7;
  --success: #15803d;
  --success-bg: #e7f6ec;
  --warning: #a16207;
  --warning-bg: #fdf4e3;
  --danger: #b91c1c;
  --danger-bg: #fdecec;
  --info: #1d4ed8;
  --info-bg: #e8eeff;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 4px 14px rgba(15, 23, 42, .08);
  --sidebar-w: 252px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-900);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; font-weight: 650; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 .8em; }

code, pre, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em;
}

.muted { color: var(--ink-500); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 650; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.uppercase { text-transform: uppercase; letter-spacing: .04em; }
.hidden { display: none !important; }
.danger-text { color: var(--danger); }
.success-text { color: var(--success); }
.warning-text { color: var(--warning); }

/* --------------------------------------------------------------- Layout -- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--navy-900);
  color: #cdd7e5;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  color: #fff;
}
.sidebar-brand .logo {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(140deg, #2f5f9e, #16233a);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; letter-spacing: .5px;
}
.sidebar-brand .name { font-weight: 680; font-size: 15px; }
.sidebar-brand .role { font-size: 11px; color: #8ea3bf; }

.nav { padding: 10px 8px 24px; }
.nav-section {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: #6d829f; padding: 14px 12px 6px; font-weight: 650;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin-bottom: 1px;
  border-radius: var(--radius-sm);
  color: #c3d0e0; font-size: 13.5px; text-decoration: none;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: var(--brand-600); color: #fff; font-weight: 600; }
.nav a svg { flex: 0 0 auto; opacity: .9; }
.nav a .count {
  margin-left: auto; background: rgba(255, 255, 255, .14);
  border-radius: 20px; padding: 1px 7px; font-size: 11px;
}
.nav a.active .count { background: rgba(0, 0, 0, .25); }
.nav a .count.alert { background: var(--danger); color: #fff; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-size: 16px; font-weight: 650; }
.topbar .spacer { flex: 1 1 auto; }
.topbar .deadline-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-100); color: var(--brand);
  border-radius: 20px; padding: 5px 12px; font-size: 12.5px; font-weight: 600;
}
.topbar .deadline-chip.passed { background: var(--danger-bg); color: var(--danger); }

/* English / हिन्दी switch. Devanagari sits lower than Latin and needs a little
   more line height, or the vowel marks above the letters get clipped. */
.locale-switch {
  display: inline-flex; align-items: center; gap: 2px;
  border: 1px solid var(--border); border-radius: 20px;
  padding: 2px; background: var(--surface);
}
.locale-switch-label {
  font-size: 11.5px; color: var(--muted); font-weight: 600;
  padding: 0 6px 0 8px; text-transform: uppercase; letter-spacing: .03em;
}
.locale-option {
  all: unset; cursor: pointer;
  padding: 4px 11px; border-radius: 16px;
  font-size: 12.5px; line-height: 1.5; font-weight: 600;
  color: var(--muted); white-space: nowrap;
}
.locale-option:hover { color: var(--text); background: var(--brand-100); }
.locale-option.active {
  cursor: default; color: #fff; background: var(--brand);
}
.auth-foot .locale-switch { background: transparent; margin-bottom: 12px; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 650;
}

.content { padding: 22px 24px 60px; flex: 1 1 auto; }
.content-narrow { max-width: 880px; }

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .grow { flex: 1 1 320px; }
.page-head .subtitle { color: var(--ink-500); font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* -------------------------------------------------------------- Buttons -- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--brand); color: #fff;
  font-size: 13.5px; font-weight: 600; font-family: inherit;
  cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-600); text-decoration: none; color: #fff; }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--ink-700); border-color: var(--line-strong); }
.btn-secondary:hover { background: #f8fafc; color: var(--ink-900); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #991b1b; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #166534; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-link { background: none; color: var(--brand-600); border: none; padding: 4px 6px; }
.btn-link:hover { background: var(--brand-100); }

/* ---------------------------------------------------------------- Cards -- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { flex: 1 1 auto; }
.card-body { padding: 18px; }
.card-body.tight { padding: 12px 14px; }
.card-foot {
  padding: 12px 18px; border-top: 1px solid var(--line);
  background: #fbfcfe; border-radius: 0 0 var(--radius) var(--radius);
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}

/* ---------------------------------------------------------------- Stats -- */

.stat-grid {
  display: grid; gap: 12px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.stat .label {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-500); font-weight: 650; display: flex; align-items: center; gap: 6px;
}
.stat .value { font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.stat .value.sm { font-size: 19px; }
.stat .meta { font-size: 12px; color: var(--ink-500); margin-top: 3px; }
.stat.accent { border-left: 3px solid var(--brand); }
.stat.good { border-left: 3px solid var(--success); }
.stat.warn { border-left: 3px solid var(--warning); }
.stat.bad { border-left: 3px solid var(--danger); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* --------------------------------------------------------------- Tables -- */

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th, table.data td {
  padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.data thead th {
  background: #f7f9fc; color: var(--ink-700);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 680;
  border-bottom: 1px solid var(--line-strong); white-space: nowrap;
  position: sticky; top: 0;
}
table.data tbody tr:hover { background: #fafcff; }
table.data td.right, table.data th.right { text-align: right; }
table.data td.center, table.data th.center { text-align: center; }
table.data td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tfoot td {
  background: #f7f9fc; font-weight: 680; border-top: 2px solid var(--line-strong);
}
table.data.compact th, table.data.compact td { padding: 6px 10px; font-size: 12.5px; }

.empty {
  padding: 42px 20px; text-align: center; color: var(--ink-500);
}
.empty svg { color: var(--line-strong); margin-bottom: 8px; }
.empty h3 { color: var(--ink-700); }

/* -------------------------------------------------------------- Badges --- */

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 650; white-space: nowrap;
  background: #eef1f6; color: var(--ink-700);
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: #eef1f6; color: var(--ink-500); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-400); }
.dot.online { background: var(--success); }
.dot.offline { background: var(--ink-400); }

/* --------------------------------------------------------------- Forms --- */

.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.field { margin-bottom: 14px; }
.field.span-2 { grid-column: 1 / -1; }
/* Groups a long form into the sections of the paper form it mirrors. */
.form-section {
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-500); margin: 22px 0 12px; padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}
.form-section:first-child { margin-top: 0; }
label, .label {
  display: block; font-size: 12.5px; font-weight: 650; color: var(--ink-700); margin-bottom: 5px;
}
label .req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=time], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13.5px; color: var(--ink-900); background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-600); box-shadow: 0 0 0 3px rgba(36, 80, 127, .12);
}
input[readonly], input:disabled, select:disabled, textarea:disabled {
  background: #f1f5f9; color: var(--ink-500); cursor: not-allowed;
}
textarea { min-height: 78px; resize: vertical; }
.help { font-size: 12px; color: var(--ink-500); margin-top: 4px; }
.error-text { font-size: 12px; color: var(--danger); margin-top: 4px; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }

.check { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; font-size: 13.5px; }
.check input { width: auto; margin-top: 2px; }
.check label { margin: 0; font-weight: 500; font-size: 13.5px; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 16px; }
legend { font-size: 12.5px; font-weight: 680; color: var(--ink-700); padding: 0 6px; }

/* ------------------------------------------------------------- Filters --- */

.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
}
.filters .field { margin: 0; min-width: 140px; flex: 0 1 auto; }
.filters .field.wide { min-width: 220px; }
.filters .actions { display: flex; gap: 8px; }

/* ---------------------------------------------------------------- Flash -- */

.flash { margin-bottom: 16px; }
.alert {
  padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 10px;
  font-size: 13.5px; display: flex; gap: 9px; align-items: flex-start;
  border: 1px solid transparent;
}
.alert svg { flex: 0 0 auto; margin-top: 1px; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #bfe3cb; }
.alert-error, .alert-danger { background: var(--danger-bg); color: var(--danger); border-color: #f3c9c9; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #f0dcae; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #c9d6fb; }

/* ----------------------------------------------------------- Pagination -- */

.pagination { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 5px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--ink-700); background: #fff; text-decoration: none;
}
.pagination a:hover { background: #f1f5f9; text-decoration: none; }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination .disabled { opacity: .45; }

/* --------------------------------------------------------------- Detail -- */

.kv { display: grid; gap: 0; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.kv > div {
  padding: 9px 0; border-bottom: 1px solid var(--line); padding-right: 18px;
}
.kv .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); font-weight: 650; }
.kv .v { font-size: 13.5px; margin-top: 2px; word-break: break-word; }

.photo-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.photo-grid figure { margin: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.photo-grid img { display: block; width: 100%; height: 130px; object-fit: cover; background: #eef1f6; }
.photo-grid figcaption { padding: 6px 8px; font-size: 11.5px; color: var(--ink-500); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  padding: 9px 0 9px 18px; border-left: 2px solid var(--line);
  position: relative; font-size: 13px;
}
.timeline li::before {
  content: ''; position: absolute; left: -5px; top: 14px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong);
}
.timeline li.good::before { background: var(--success); }
.timeline li.bad::before { background: var(--danger); }
.timeline time { color: var(--ink-500); font-size: 11.5px; display: block; }

/* ------------------------------------------------------------ Progress -- */

.bar { height: 7px; background: #eef1f6; border-radius: 20px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 20px; }
.bar > span.good { background: var(--success); }
.bar > span.warn { background: var(--warning); }
.bar > span.bad { background: var(--danger); }

.sparkline { display: flex; align-items: flex-end; gap: 3px; height: 60px; }
.sparkline > div { flex: 1 1 auto; background: var(--brand-100); border-radius: 2px 2px 0 0; min-height: 2px; position: relative; }
.sparkline > div > i { display: block; background: var(--brand); border-radius: 2px 2px 0 0; width: 100%; }

/* -------------------------------------------------------------- Wizard --- */

.steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.steps .step {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 20px; background: #fff;
  border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-500);
}
.steps .step .n {
  width: 20px; height: 20px; border-radius: 50%; background: #eef1f6;
  display: grid; place-items: center; font-size: 11px; font-weight: 680;
}
.steps .step.active { border-color: var(--brand); color: var(--brand); font-weight: 650; }
.steps .step.active .n { background: var(--brand); color: #fff; }
.steps .step.done { color: var(--success); border-color: #bfe3cb; }
.steps .step.done .n { background: var(--success); color: #fff; }

/* --------------------------------------------------------------- Login --- */

.auth-shell {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(140deg, #0b1220, #17263f 55%, #1e3a5f);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 410px; background: #fff;
  border-radius: 14px; box-shadow: 0 18px 50px rgba(3, 8, 20, .38);
  padding: 30px 30px 26px;
}
.auth-card .brand { display: flex; align-items: center; gap: 11px; margin-bottom: 20px; }
.auth-card .brand .logo {
  width: 40px; height: 40px; border-radius: 10px; background: var(--brand);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.auth-card h1 { font-size: 19px; margin-bottom: 4px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 12px; color: rgba(255, 255, 255, .6); }

/* --------------------------------------------------------------- Error --- */

.error-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.error-card { max-width: 520px; text-align: center; }
.error-card .code { font-size: 60px; font-weight: 750; color: var(--line-strong); line-height: 1; }

/* ------------------------------------------------------- Form renderer -- */

.form-field-row {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; margin-bottom: 7px;
}
.form-field-row .handle { color: var(--ink-400); cursor: grab; }
.form-field-row .info { flex: 1 1 auto; min-width: 0; }
.form-field-row .info .name { font-weight: 620; font-size: 13.5px; }
.form-field-row .info .meta { font-size: 11.5px; color: var(--ink-500); }
.form-field-row.inactive { opacity: .6; background: #f8fafc; }
.form-field-row.section { background: var(--brand-100); border-color: #c9d8ea; }

.gps-box {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; background: #fbfcfe; margin-bottom: 14px;
}
.gps-box .coords { font-variant-numeric: tabular-nums; font-weight: 650; }

canvas.signature {
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; width: 100%; height: 130px; touch-action: none;
}

/* ------------------------------------------------------------ Responsive */

@media (max-width: 960px) {
  .sidebar { position: fixed; left: -100%; z-index: 60; transition: left .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { left: 0; }
  .menu-toggle { display: inline-flex !important; }
  .content { padding: 16px 14px 60px; }
  .topbar { padding: 10px 14px; }
}

@media (min-width: 961px) {
  .menu-toggle { display: none !important; }
}

@media print {
  .sidebar, .topbar, .page-actions, .filters, .pagination, .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .card { border: none; box-shadow: none; page-break-inside: avoid; }
  table.data thead th { position: static; }
}
