/* Styles that belong to one screen or one family of screens. Shared pieces are in components.css. */

/* A row of summary figures above a table. */
.summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  margin-bottom: var(--space-3);
  font-size: var(--font-size-sm);
}
.summary-strip strong {
  font-weight: 600;
}

/* A small grey note under a panel's content. */
.note {
  margin: var(--space-3) 0 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}

.subtitle {
  margin: var(--space-4) 0 var(--space-2);
  font-weight: 600;
}

/* A link that looks like a small button (e.g. "Open Overview" in a table). */
.link-button {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: var(--color-on-accent);
  white-space: nowrap;
}
.link-button:hover {
  filter: brightness(0.94);
}

/* One-line search form: text, filters, button. */
.search-row {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) minmax(150px, 1fr) minmax(130px, 1fr) auto;
  gap: var(--space-3);
  align-items: center;
}
@media (max-width: 760px) {
  .search-row {
    grid-template-columns: 1fr;
  }
}

/* ─── Client Overview ─── */
.profile {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}
@media (max-width: 640px) {
  .profile {
    grid-template-columns: 1fr;
  }
}
.photo {
  display: grid;
  width: 120px;
  height: 120px;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--color-ink);
  color: var(--color-on-accent);
  font-size: 40px;
  font-weight: 300;
}
.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.profile-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.add-form {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px dashed var(--color-border);
}

/* Figure tiles (totals). */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}
.tile {
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
}
.tile span {
  display: block;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.tile b {
  font-size: 18px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

/* ─── Loan interactions and other comment lists ─── */
.comments {
  display: grid;
  gap: var(--space-3);
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
}
.comment {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
}
.comment p {
  margin: 4px 0 0;
  white-space: pre-wrap;
}
.comment-meta {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.reversed {
  color: var(--color-text-muted);
  text-decoration: line-through;
}

/* ─── Loan forms: quote tiles, the picked client, form sections ─── */
.quote-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
  margin: var(--space-3) 0;
}
.quote-tiles div {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
}
.quote-tiles span {
  display: block;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.quote-tiles b {
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.picked {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-2);
}
.picked:empty {
  display: none;
}
.form-section {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px dashed var(--color-border);
}

/* ─── Group loan builder (New Micro / Micro Extra / Festival Loans) ─── */
.builder-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: center;
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.builder-search {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 260px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-surface-raised);
  color: var(--color-text-muted);
}
.builder-search:focus-within {
  border-color: var(--color-border-focus);
}
.builder-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: var(--font-size-sm);
}
.tally {
  margin: 0 auto 0 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}
.tally b {
  color: var(--color-text-strong);
  font-weight: 600;
}
/* An added member: clearly done, not disabled; clicking removes the loan again. */
.btn.added {
  border-color: var(--color-success);
  background: var(--color-surface-raised);
  color: #3f8f1f;
}
.loan-cards {
  display: grid;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
}
.loan-card {
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
}
.loan-card[data-invalid="true"] {
  border-left-color: var(--color-danger);
}
.card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-bottom: 1px solid var(--color-border);
}
.card-number {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--color-primary) 14%, transparent);
  color: var(--color-primary);
  font-size: var(--font-size-xs);
  font-weight: 700;
}
.card-who {
  display: grid;
  min-width: 0;
}
.card-who b {
  overflow: hidden;
  color: var(--color-text-strong);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-who span {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
/* A member's credit score, at the right of their card header. */
.card-header .credit-slot {
  margin-left: auto;
  white-space: nowrap;
}
.card-remove {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}
.card-remove:hover {
  background: color-mix(in srgb, var(--color-danger) 12%, transparent);
  color: var(--color-danger);
}
.card-error {
  margin: var(--space-2) var(--space-3) 0;
}
/* ─── Customer → Client Overview ─── */
.co-page {
  display: grid;
  gap: var(--space-4);
}
.co-page .panel {
  margin: 0;
}
/* Header: photo · name and key facts · actions */
.co-hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-4);
}
.co-photo {
  display: grid;
  justify-items: center;
  gap: 6px;
}
.co-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #334155, #1e293b);
  color: #fff;
  font-size: 34px;
  font-weight: 600;
  box-shadow: 0 0 0 3px #fff, 0 0 0 4px #e2e8f0;
}
.co-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.co-photo-link {
  border: 0;
  background: none;
  padding: 0;
  font-size: 12px;
  color: var(--color-primary, #2563eb);
  cursor: pointer;
}
.co-photo-link:hover {
  text-decoration: underline;
}
.co-photo-actions {
  display: flex;
  gap: 6px;
}
.co-identity {
  min-width: 0;
}
.co-name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.co-name {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}
.co-code {
  font-size: 12px;
  font-family: ui-monospace, Consolas, monospace;
  color: #475569;
  background: #f1f5f9;
  border-radius: 6px;
  padding: 2px 8px;
}
.co-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5, 28px);
  margin: 0;
}
.co-meta div {
  display: grid;
  gap: 2px;
}
.co-meta dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}
.co-meta dd {
  margin: 0;
  font-weight: 500;
}
.co-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-2);
}
.co-records .tab-list {
  flex-wrap: wrap;
}
.co-records-toolbar {
  display: flex;
  justify-content: flex-start;
  padding: var(--space-3) var(--space-4) 0;
}
/* Wide tables scroll inside the records column instead of spilling over the side cards. */
.co-records,
.co-records .tab-panel {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
}
/* Personal Information across the full width: label above value, as many columns as fit. */
.co-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3) var(--space-4);
  margin: 0;
}
.co-facts div {
  display: grid;
  gap: 2px;
}
.co-facts dt {
  color: #64748b;
  font-size: 12px;
}
.co-facts dd {
  margin: 0;
  font-weight: 500;
  word-break: break-word;
}
@media (max-width: 700px) {
  .co-hero {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .co-name-row,
  .co-meta,
  .co-actions {
    justify-content: center;
  }
}

/* Credit score card: the score in a ring with its band on a scale, the six totals, then the note. */
.cs {
  display: grid;
  gap: var(--space-3);
}
.cs-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-radius: 10px;
}
.cs-ring {
  --size: 88px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: conic-gradient(currentColor calc(var(--score) * 1%), rgba(0, 0, 0, 0.08) 0);
  display: grid;
  place-items: center;
}
.cs-ring-inner {
  width: calc(var(--size) - 16px);
  height: calc(var(--size) - 16px);
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-content: center;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.cs-ring-inner strong {
  font-size: 28px;
  line-height: 1;
}
.cs-ring-inner span {
  margin-top: 2px;
  font-size: 10px;
  color: var(--color-text-subtle);
}
.cs-hero-text {
  min-width: 0;
  color: var(--color-text-strong);
}
.cs-headline {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.cs-headline h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}
.cs-reasons {
  margin: var(--space-1) 0 var(--space-2);
  font-size: 12px;
  padding-left: 18px;
  color: var(--color-text-subtle);
}
.cs-scale-bar {
  position: relative;
  display: flex;
  gap: 2px;
  font-size: 10px;
  text-align: center;
}
.cs-scale-bar span {
  padding: 3px 2px;
  color: #fff;
  opacity: 0.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cs-scale-bar span:first-child {
  border-radius: 6px 0 0 6px;
}
.cs-scale-bar span:last-of-type {
  border-radius: 0 6px 6px 0;
}
.cs-scale-bar .cs-band-on {
  opacity: 1;
  font-weight: 600;
}
.cs-band-danger {
  background: #dc2626;
}
.cs-band-warning {
  background: #f59e0b;
}
.cs-band-info {
  background: #0ea5e9;
}
.cs-band-success {
  background: #16a34a;
}
.cs-marker {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--color-text-strong);
}
.cs-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2) var(--space-3);
}
/* Plain figures, no boxes: only the number takes the colour. */
.cs-stat {
  display: grid;
  gap: 0;
}
.cs-stat-success .cs-stat-value {
  color: #16a34a;
}
.cs-stat-warning .cs-stat-value {
  color: #d97706;
}
.cs-stat-danger .cs-stat-value {
  color: #dc2626;
}
.cs-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-subtle);
}
.cs-stat-value {
  font-size: 15px;
  color: var(--color-text-strong);
}
.cs-stat-detail {
  font-size: 10px;
  color: var(--color-text-muted);
}
.cs-note {
  margin: 0;
  font-size: 10px;
  color: var(--color-text-muted);
}
/* Client Overview adds Grading under the score card in the pop-up. */
.cs-section {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}
.cs-section > h3 {
  margin: 0 0 var(--space-2);
  font-size: 14px;
  font-weight: 600;
}
/* Grade colours: --tone is the strong colour, --tint the light background. */
.cs-grade-success {
  --tone: #16a34a;
  --tint: #f0fdf4;
}
.cs-grade-info {
  --tone: #0284c7;
  --tint: #f0f9ff;
}
.cs-grade-warning {
  --tone: #d97706;
  --tint: #fffbeb;
}
.cs-grade-danger {
  --tone: #dc2626;
  --tint: #fef2f2;
}
.cs-grade-default {
  --tone: #64748b;
  --tint: #f8fafc;
}
.cs-grade-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.cs-grade-pill {
  min-width: 72px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--tone);
  color: #fff;
  font-weight: 600;
  text-align: center;
}
.cs-grade-text {
  flex: 1;
  min-width: 160px;
  display: grid;
  gap: 2px;
}
.cs-grade-text span {
  font-size: 12px;
  color: var(--color-text-subtle);
}
.cs-grade-form {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.cs-grade-label {
  font-weight: 600;
  font-size: 12px;
}
/* Plain buttons in a row: an outline in the grade's colour, filled when chosen. */
.cs-grade-choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.cs-grade-choice {
  padding: 5px 16px;
  border: 1px solid var(--tone);
  border-radius: 999px;
  background: #fff;
  color: var(--tone);
  font: inherit;
  cursor: pointer;
}
.cs-grade-choice:hover {
  background: var(--tint);
}
.cs-grade-choice.is-on {
  background: var(--tone);
  color: #fff;
  font-weight: 600;
}
.cs-grade-form .form-actions {
  margin: 0;
}
.credit-success {
  color: #15803d;
  background: #f0fdf4;
}
.credit-info {
  color: #0369a1;
  background: #f0f9ff;
}
.credit-warning {
  color: #b45309;
  background: #fffbeb;
}
.credit-danger {
  color: #b91c1c;
  background: #fef2f2;
}
.credit-default {
  color: #475569;
  background: #f8fafc;
}
.credit-actions {
  margin-bottom: var(--space-3);
}
.credit-reasons {
  margin: 0 0 var(--space-3);
  padding-left: 18px;
}
@media (max-width: 640px) {
  .cs-hero {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .cs-hero-text {
    width: 100%;
  }
  .cs-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* CRO Approval → Document Checklist: one tick box per document. */
.checklist {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

/* A note that is allowed but needs attention, e.g. an amount above the product limit (needs RM approval). */
.text-warning {
  color: color-mix(in srgb, var(--color-warning) 55%, #000);
  font-weight: 600;
}
.card-fields {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(140px, 1fr) minmax(150px, 1fr) minmax(160px, 1fr);
  gap: var(--space-3);
  padding: var(--space-3);
}
.card-quote {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) 24px;
  margin: 0;
  padding: 8px var(--space-3) 10px;
  border-top: 1px dashed var(--color-border);
  background: var(--color-table-row-hover);
}
.card-quote div {
  display: grid;
  gap: 1px;
}
.card-quote dt {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.card-quote dd {
  margin: 0;
  color: var(--color-text-strong);
  font-variant-numeric: tabular-nums;
}
.card-quote small {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.card-quote .note {
  margin: 0;
}
.payout {
  font-weight: 600;
}
.builder-summary {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--space-4);
  align-items: end;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}
.builder-totals {
  display: grid;
  justify-items: end;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.builder-totals b {
  color: var(--color-text-strong);
  font-size: var(--font-size-lg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 900px) {
  .card-fields {
    grid-template-columns: 1fr 1fr;
  }
  .builder-summary {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .builder-totals {
    justify-items: start;
  }
}
@media (max-width: 480px) {
  .card-fields {
    grid-template-columns: 1fr;
  }
  .tally {
    flex-basis: 100%;
  }
}

/* ─── Operation: collection sheet and group schedule ─── */
.blank-line {
  display: inline-block;
  min-width: 80px;
  border-bottom: 1px solid var(--color-border);
}
.schedule-scroll {
  overflow-x: auto;
}
.schedule-grid {
  border-collapse: collapse;
  font-size: var(--font-size-xs);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.schedule-grid th,
.schedule-grid td {
  padding: 4px 6px;
  border: 1px solid var(--color-border);
  text-align: right;
}
.schedule-grid th:nth-child(-n + 3),
.schedule-grid td:nth-child(-n + 3) {
  text-align: left;
}
.schedule-grid .paid {
  background: color-mix(in srgb, var(--color-success) 18%, transparent);
}
.schedule-grid .partial {
  background: color-mix(in srgb, var(--color-warning) 22%, transparent);
}

/* ─── CBO screens ─── */
.pending {
  margin-top: var(--space-4);
}
.attendance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 6px var(--space-4);
  margin: var(--space-3) 0;
}
.check-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.spaced {
  margin-bottom: var(--space-3);
}

/* ─── Workflow queues: the bar above the loans (select all, note, actions) ─── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.toolbar > span {
  margin-right: auto;
  color: var(--color-text-muted);
}
.toolbar-note {
  width: 220px;
  max-width: 100%;
}
.guarantor-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(160px, 2fr) auto;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

/* ─── Loan picker: the list of matching loans ─── */
.match-list {
  max-height: 260px;
  margin: var(--space-3) 0 0;
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  list-style: none;
}
.match {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(160px, 2fr) minmax(110px, 1fr) minmax(90px, 1fr) auto;
  gap: var(--space-3);
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  font-size: var(--font-size-sm);
  text-align: left;
  cursor: pointer;
}
.match:hover,
.match:focus-visible {
  background: #eef8e8;
  outline: none;
}
.match-loan {
  font-weight: 600;
}
.no-match {
  margin: var(--space-3) 0 0;
  color: var(--color-text-muted);
}
@media (max-width: 640px) {
  .match {
    grid-template-columns: 1fr 1fr;
  }
}

/* ─── Client search box (type a NIC or name, pick from the list) ─── */
.client-search {
  position: relative;
}
.client-search-list {
  position: absolute;
  top: calc(100% + 2px);
  right: 0;
  left: 0;
  z-index: var(--z-menu);
  max-height: 280px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-menu);
  list-style: none;
}
.client-option {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto;
  gap: var(--space-3);
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  font-size: var(--font-size-sm);
  text-align: left;
  cursor: pointer;
}
.client-option:hover,
.client-option:focus-visible {
  background: #eef8e8;
  outline: none;
}
.client-option span {
  color: var(--color-text-subtle);
}
.client-search-note {
  padding: 8px 10px;
  color: var(--color-text-muted);
}

/* ─── Printable documents (loan agreement, receipts, delivery order) ─── */
.document {
  max-width: 780px;
  margin: 0 auto;
  color: #000;
  font-size: 12px;
  line-height: 1.5;
}
.document section {
  margin-top: 16px;
}
.document h3 {
  margin: 0 0 6px;
  padding-bottom: 2px;
  border-bottom: 1px solid #999;
  font-size: 13px;
}
.document-header {
  text-align: center;
}
.document-company {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.document-title {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.document-meta {
  margin: 2px 0 0;
  color: #444;
}
.document-terms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 24px;
  margin: 0;
}
.document-terms div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px dotted #bbb;
}
.document-terms dt {
  color: #444;
}
.document-terms dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.document-schedule {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.document-schedule th,
.document-schedule td {
  padding: 2px 6px;
  border: 1px solid #ccc;
  text-align: left;
}
.document-schedule td:last-child,
.document-schedule th:last-child {
  text-align: right;
}
.document-signatures {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  margin-top: 48px;
}
.document-signatures span {
  min-width: 160px;
  padding-top: 4px;
  border-top: 1px solid #000;
  text-align: center;
}
@media (max-width: 600px) {
  .document-terms {
    grid-template-columns: 1fr;
  }
}

/* --- Admin: Loan Product charges --- */
.charges {
  display: grid;
  gap: 6px;
  margin: var(--space-4) 0 0;
  padding: var(--space-4) 0 0;
  border: 0;
  border-top: 1px dashed var(--color-border);
}
.charges-title {
  margin: 0 0 4px;
  padding: 0;
  font-size: var(--font-size-sm);
  font-weight: 600;
}
.charge-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(90px, 0.6fr) minmax(110px, 1fr);
  gap: var(--space-3);
  align-items: center;
  max-width: 620px;
}
.spaced-top {
  margin-top: var(--space-3);
}
@media (max-width: 560px) {
  .charge-row {
    grid-template-columns: 1fr 1fr;
  }
  .charge-row > :first-child {
    grid-column: 1 / -1;
  }
}

.section-title {
  margin: 18px 0 8px;
  font-size: 14px;
}

/* --- View Contract / View Client pop-ups and the eye buttons that open them --- */
.view-buttons {
  display: inline-flex;
  gap: 4px;
}
.inspect-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  color: var(--color-primary);
  cursor: pointer;
}
.inspect-btn:hover,
.inspect-btn:focus-visible,
.icon-btn:hover {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
}
.icon-btn {
  width: 20px;
  height: 20px;
  margin-left: 6px;
  border: 0;
  background: transparent;
}
.contract-view {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.contract-hero {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
}
.contract-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.eyebrow {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.contract-name {
  margin: 2px 0 0;
  font-size: 17px;
  text-transform: uppercase;
}
.loan-no-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, Consolas, monospace;
  font-weight: 600;
}
.contract-address {
  margin: 0;
  color: var(--color-text-subtle);
}
.inactive-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 8px 12px;
  border: 1px solid;
  border-radius: var(--radius-sm);
}
.inactive-critical {
  border-color: var(--color-warning);
  background: color-mix(in srgb, var(--color-warning) 14%, transparent);
}
.inactive-severe {
  border-color: var(--color-danger);
  background: color-mix(in srgb, var(--color-danger) 12%, transparent);
}
.inactive-action {
  padding: 2px 8px;
  border: 1px solid currentColor;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
}
.progress-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
  font-size: var(--font-size-xs);
}
.progress-head span:first-child {
  color: var(--color-success);
  font-weight: 700;
  text-transform: uppercase;
}
.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--color-border);
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--color-success);
}
.money-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-2);
}
.money-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--tone, var(--color-border));
  border-radius: var(--radius-sm);
}
.money-card-info {
  --tone: var(--color-info);
}
.money-card-success {
  --tone: var(--color-success);
}
.money-card-warning {
  --tone: var(--color-warning);
}
.money-card-primary {
  --tone: var(--color-primary);
}
.money-card-danger {
  --tone: var(--color-danger);
}
.money-card-label {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
}
.money-card-value {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px var(--space-3);
}
.info-grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.info-pair {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.info-pair span {
  color: var(--color-text-muted);
}
.info-pair strong {
  text-align: right;
  font-weight: 600;
}
.contract-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.contract-line {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) minmax(0, 1.5fr) auto minmax(90px, auto);
  gap: var(--space-3);
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid var(--color-border);
}
.contract-line:last-child {
  border-bottom: 0;
}
.contract-line-no {
  font-weight: 600;
}
.contract-line .align-end {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.toolbar-plain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin: var(--space-3) 0 var(--space-2);
}
.guarantor-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.guarantor-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-2);
  align-items: center;
}

/* --- Portfolio screens: pills, multi-selects, chips, cards and the printable sheet --- */
.filter-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
}
.filter-top > input[type="search"] {
  flex: 1 1 260px;
  max-width: 420px;
}
.pill-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
}
.pill-label {
  padding: 0 6px;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  font-weight: 600;
}
.pill {
  padding: 3px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font-size: var(--font-size-sm);
  cursor: pointer;
}
.pill[aria-pressed="true"] {
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
}
.multi-select {
  position: relative;
}
.multi-select > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  list-style: none;
}
.multi-select > summary::-webkit-details-marker {
  display: none;
}
.multi-summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.multi-menu {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  z-index: var(--z-menu);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 240px;
  max-height: 320px;
  padding: 8px;
  overflow-y: auto;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-menu);
}
.columns-menu .multi-menu {
  right: 0;
  left: auto;
}
.multi-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.multi-count {
  margin-left: auto;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-primary);
  font-size: var(--font-size-xs);
  font-weight: 600;
  cursor: pointer;
}
.multi-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.multi-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  cursor: pointer;
}
.chips-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-primary) 14%, transparent);
  font-size: var(--font-size-xs);
}
.chip-clear {
  display: inline-flex;
  padding: 2px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  cursor: pointer;
}
.chips-bar .btn {
  margin-left: auto;
}
.metric-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.metric-cards .money-card {
  background: var(--color-surface-raised);
}
.range-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-3);
}
.range-row > .field {
  min-width: 140px;
}
.range-pair {
  display: flex;
  align-items: center;
  gap: 6px;
}
.range-pair input {
  min-width: 0;
  max-width: 150px;
}
.field-end {
  margin-left: auto;
}
.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.report-sheet {
  color: var(--color-text-strong);
}
.report-sheet-head {
  margin-bottom: var(--space-3);
  text-align: center;
}
.report-sheet-head h3 {
  margin: 2px 0;
  font-size: 16px;
  text-transform: uppercase;
}
.report-group {
  margin-bottom: var(--space-4);
}
.report-group-title {
  margin: 0 0 6px;
  padding: 4px 8px;
  border-left: 3px solid var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
  font-size: 13px;
}
.report-subgroup-title {
  margin: 8px 0 4px;
  font-weight: 600;
}
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.report-table th,
.report-table td {
  padding: 4px 6px;
  border: 1px solid var(--color-border);
  text-align: left;
}
.report-table th {
  background: var(--color-surface);
}
.report-table .num {
  text-align: right;
  white-space: nowrap;
}
.report-table tfoot td,
.report-table .report-total td {
  font-weight: 700;
}
.report-table .remarks {
  min-width: 90px;
  color: var(--color-text-muted);
}

/* --- Letter of Termination (A4) --- */
.letter-holder {
  overflow-x: auto;
  padding: var(--space-3);
  background: #e5e7eb;
}
.letter-sheet {
  box-sizing: border-box;
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 16mm 15mm;
  background: #fff;
  color: #111;
  font-size: 12.3px;
  line-height: 1.55;
  outline: none;
}
.letter-si {
  font-family: "Iskoola Pota", "Noto Sans Sinhala", "Nirmala UI", sans-serif;
}
.letter-ta {
  font-family: "Latha", "Noto Sans Tamil", "Nirmala UI", sans-serif;
}
.letter-sheet p {
  margin: 0 0 8px;
  text-align: justify;
}
.letter-head {
  display: flex;
  justify-content: flex-end;
  text-align: right;
}
.letter-company strong {
  display: block;
  font-size: 15px;
}
.letter-post {
  margin: 10px 0 4px;
}
.letter-post span {
  padding: 2px 8px;
  border: 1px solid #111;
  font-weight: 700;
}
.letter-date {
  margin-bottom: 10px;
}
.letter-recipient-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}
.letter-title {
  align-self: center;
  max-width: 280px;
  padding: 8px;
  border: 2px solid #111;
  font-weight: 700;
  text-align: center;
}
.letter-subject {
  font-weight: 700;
  text-decoration: underline;
}
.letter-table {
  margin: 4px 0 12px 16px;
  border-collapse: collapse;
}
.letter-table td {
  padding: 2px 6px;
  vertical-align: top;
}
.letter-table td:last-child {
  font-weight: 700;
}
.letter-foot {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 36px;
}
.letter-sign strong,
.letter-copies strong {
  display: block;
}
.letter-copies ol {
  margin: 4px 0 0;
  padding-left: 18px;
}
@media print {
  .letter-holder {
    padding: 0;
    background: none;
  }
  .letter-sheet.print-area {
    width: 100%;
    min-height: 0;
    padding: 0;
  }
}

/* --- CBO Overview: members by group, with Client Details alongside --- */
.groups-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
  gap: var(--space-4);
  align-items: start;
}
@media (max-width: 1280px) {
  .groups-layout {
    grid-template-columns: 1fr;
  }
}
.group-blocks {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}
.group-block {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
}
.group-block > summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px var(--space-3);
  align-items: baseline;
  padding: 10px var(--space-3);
  cursor: pointer;
  list-style-position: inside;
}
.group-block[open] > summary {
  border-bottom: 1px solid var(--color-border);
}
.group-block-title {
  font-weight: 600;
}
.group-block tbody tr {
  cursor: pointer;
}

/* --- Accounts: entry notes and the balance sheet --- */
.note {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.sheet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-5);
}
@media (max-width: 800px) {
  .sheet-grid {
    grid-template-columns: 1fr;
  }
}
.sheet-section h3 {
  margin: 0 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-md);
  font-weight: 400;
}
.sheet {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.sheet td {
  padding: 3px 4px;
  border-bottom: 1px dotted var(--color-border);
}
.sheet td:first-child {
  width: 64px;
  color: var(--color-text-muted);
}
.sheet td:last-child {
  text-align: right;
  white-space: nowrap;
}
.sheet-total td {
  border-top: 1px solid var(--color-text);
  border-bottom: none;
  font-weight: 600;
}
.sheet-earnings {
  margin: var(--space-3) 0 0;
  color: var(--color-text-muted);
}
.sheet-earnings b {
  color: var(--color-text);
  font-weight: 600;
}

/* --- Reports → Center Report (detailed): one block per branch and center, as the center sheets print --- */
.center-sheets {
  display: flex;
  flex-direction: column;
  gap: 36px;
  padding: 6px 0;
}
.center-sheet {
  overflow: hidden;
  border: 1px solid #dfe3ea;
  border-bottom: 2px solid #1f2733;
  border-radius: 10px;
  background: #fff;
  break-inside: avoid;
  page-break-inside: avoid;
}
.cs-head {
  padding: 12px 14px 10px;
  border-bottom: 2px solid #1f2733;
  background: #f7f8fb;
}
.cs-head h3 {
  margin: 0;
  color: #111;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.cs-head p {
  margin: 2px 0 0;
  color: #333;
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
}
.cs-table {
  width: 100%;
  border-collapse: collapse;
}
.cs-table th {
  padding: 10px 6px;
  border-bottom: 2px solid #1f2733;
  background: #f1f3f7;
  color: #333;
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.cs-table td {
  padding: 6px;
  border-bottom: 1px solid #e8ebf0;
  color: #111;
  font-family: Consolas, "Courier New", monospace;
  font-size: 10.5px;
  white-space: nowrap;
}
.cs-table tbody tr:nth-child(even) td {
  background: #fafbfc;
}
.cs-table .cs-client {
  text-transform: uppercase;
}
.cs-table .cs-loanNo,
.cs-table .cs-due {
  font-weight: 700;
}
.cs-table .cs-phone {
  color: #333;
}
/* Empty columns to write in at the center meeting. */
.cs-table .cs-blank {
  width: 6%;
  min-width: 70px;
  border-left: 1px solid #d5dae2;
}
.cs-table tfoot td {
  padding: 9px 6px;
  border-top: 2px solid #1f2733;
  border-bottom: 0;
  background: #fff;
  font-size: 11.5px;
  font-weight: 700;
}
.cs-table .cs-total-label {
  font-family: var(--font-sans);
  font-size: 13px;
}
.cs-table tfoot .cs-due {
  color: #138a4a;
}
@media print {
  .center-sheets {
    gap: 18px;
  }
  .center-sheet {
    border-radius: 0;
  }
}

/* --- Accounts → CO Settle Cash: counting the cash, and the settlement slip --- */
.cash-counter {
  max-width: 560px;
  margin-bottom: var(--space-3);
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 8px;
}
.cash-table {
  width: 100%;
  border-collapse: collapse;
}
.cash-table th,
.cash-table td {
  padding: 5px 10px;
  border-bottom: 1px solid #f0f2f6;
  text-align: left;
}
.cash-table thead th {
  background: var(--color-surface);
  color: var(--color-text-subtle);
  font-size: var(--font-size-xs);
  font-weight: 600;
}
.cash-table .align-end {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cash-note {
  display: inline-block;
  min-width: 84px;
  padding: 3px 9px;
  border-radius: 6px;
  background: #eef6ea;
  color: #2f5f17;
  font-size: var(--font-size-sm);
  font-weight: 600;
}
.cash-coins {
  background: #fdf3df;
  color: #7a5200;
}
.cash-x {
  width: 16px;
  color: var(--color-text-muted);
}
.cash-input {
  width: 110px;
  text-align: right;
}
.cash-row-used {
  background: color-mix(in srgb, var(--color-success) 7%, #fff);
}
.cash-table tfoot th,
.cash-table tfoot td {
  border-top: 2px solid #1f2733;
  border-bottom: 0;
  background: var(--color-surface);
  font-weight: 700;
}
.cash-total-value {
  font-size: var(--font-size-lg);
}

.settle-slip {
  width: 190mm;
  max-width: 100%;
  margin: 0 auto;
  padding: 14mm 14mm 12mm;
  background: #fff;
  color: #000;
  font-size: 12px;
  box-shadow: 0 2px 10px rgb(0 0 0 / 12%);
}
.slip-head {
  padding-bottom: 8px;
  border-bottom: 2px solid #000;
  text-align: center;
}
.slip-head h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.slip-head p {
  margin: 3px 0 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.slip-facts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 24px;
  margin: 12px 0;
}
.slip-fact {
  display: flex;
  gap: 8px;
}
.slip-fact span {
  min-width: 100px;
  color: #444;
}
.slip-fact span::after {
  content: " :";
}
.slip-table {
  width: 100%;
  border-collapse: collapse;
}
.slip-table th,
.slip-table td {
  padding: 5px 8px;
  border: 1px solid #000;
}
.slip-table thead th {
  background: #eee;
  text-align: left;
}
.slip-table .align-end {
  text-align: right;
}
.slip-zero td {
  color: #777;
}
.slip-table tfoot td {
  font-size: 13px;
  font-weight: 700;
}
.slip-words {
  margin: 8px 0 0;
  font-style: italic;
}
.slip-note {
  margin: 6px 0 0;
}
.slip-signs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  margin-top: 46px;
}
.slip-sign {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
}
.slip-sign-line {
  margin-bottom: 2px;
  border-top: 1px dotted #000;
}
.slip-sign strong {
  font-size: 12px;
}
@media print {
  .settle-slip.print-area {
    width: 100%;
    padding: 0;
    box-shadow: none;
  }
}
