:root {
  --bg: #f6f7f2;
  --surface: #ffffff;
  --ink: #17211b;
  --muted: #667068;
  --line: #dfe4db;
  --green: #246b45;
  --blue: #265d85;
  --red: #a63d35;
  --amber: #9a6a1a;
  --soft: #fbfcf8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-sprite {
  display: none;
}

.shell {
  min-height: 100vh;
  padding: 24px;
}

.topbar,
.workspace,
.summary-grid,
.person-header,
.transaction-form {
  width: min(1320px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.identity-text {
  display: grid;
  gap: 2px;
}

.identity img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.identity a {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.identity .icon-btn {
  flex: 0 0 auto;
}

.link-btn {
  background: transparent;
  border: 0;
  color: var(--blue);
  cursor: pointer;
  font-weight: 700;
  padding: 0;
  text-align: left;
}

.login {
  width: min(560px, 100%);
  margin: 12vh auto 0;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 20px;
}

.error-page {
  background:
    linear-gradient(135deg, rgba(36, 107, 69, 0.08), transparent 36%),
    linear-gradient(315deg, rgba(166, 61, 53, 0.08), transparent 34%),
    var(--bg);
}

.error-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.error-panel {
  width: min(560px, 100%);
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(23, 33, 27, 0.12);
  display: grid;
  gap: 16px;
}

.error-mark {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--red);
  background: #fff1ef;
  border: 1px solid #f0c7c2;
}

.error-mark svg {
  width: 28px;
  height: 28px;
}

.error-panel h1 {
  font-size: 24px;
}

.error-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.error-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.workspace {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 18px;
  align-items: start;
}

.sidebar,
.content,
.login,
.drawer-card {
  box-shadow: 0 14px 40px rgba(23, 33, 27, 0.08);
}

.sidebar,
.content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sidebar {
  padding: 16px;
  position: sticky;
  top: 18px;
}

.content {
  padding: 16px;
  min-width: 0;
}

.panel-title,
.person-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-actions {
  display: flex;
  gap: 8px;
}

.panel-title button,
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--soft);
  cursor: pointer;
  color: var(--ink);
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.stack,
.transaction-form {
  display: grid;
  gap: 10px;
}

.stack {
  margin: 16px 0;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--soft);
}

.primary,
.secondary,
.danger {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  text-decoration: none;
}

.primary {
  background: var(--green);
  color: #fff;
}

.secondary {
  background: #eef2eb;
  border: 1px solid var(--line);
  color: var(--ink);
}

.danger {
  background: var(--red);
  color: #fff;
}

.icon-only {
  width: 42px;
  padding-left: 0;
  padding-right: 0;
}

.danger-icon {
  color: var(--red);
}

.danger-icon:hover {
  background: #faeeee;
  border-color: #e8b8b4;
}

.danger-inline {
  color: var(--red);
  min-height: 34px;
  padding: 7px 10px;
}

.danger-inline:hover {
  background: #faeeee;
  border-color: #e8b8b4;
}

.people-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.person-select-field {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.person-select-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.person-select-field select {
  background: #fff;
  font-weight: 800;
}

.admin-sidebar {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
}

.sidebar-action {
  align-items: center;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  text-align: left;
  width: 100%;
}

.sidebar-action span {
  font-weight: 800;
}

.people-group {
  display: grid;
  gap: 8px;
}

.people-group h3 {
  color: var(--muted);
  font-size: 11px;
  margin: 0;
  text-transform: uppercase;
}

.shared-group {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 12px;
}

.shared-group h3 {
  color: var(--blue);
}

.person-item {
  align-items: center;
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 8px;
}

.person-item.active {
  border-color: var(--green);
  background: #edf7ef;
}

.shared-person {
  background: #f3f7fb;
  border-color: #cbdce8;
}

.shared-person.active {
  background: #eaf3fa;
  border-color: var(--blue);
}

.person-select {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  min-width: 0;
  padding: 2px;
  text-align: left;
}

.person-select strong,
.person-select span {
  display: block;
}

.person-select strong {
  align-items: center;
  display: flex;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-badge {
  background: #e4eef6;
  border: 1px solid #c8dbe8;
  border-radius: 999px;
  color: var(--blue);
  flex: 0 0 auto;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  padding: 2px 6px;
  text-transform: uppercase;
}

.person-select span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.person-select b {
  font-weight: 800;
}

.person-actions {
  display: flex;
  gap: 6px;
}

.person-actions .icon-btn {
  height: 32px;
  width: 32px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.summary-grid article,
.balance-box {
  background: transparent;
  border-top: 1px solid var(--line);
  padding: 11px 0 0;
}

.summary-grid span,
.balance-box span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-grid strong,
.balance-box strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
  text-align: right;
}

.person-header {
  align-items: stretch;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  margin-bottom: 14px;
  padding: 14px;
}

.account-tabs {
  align-items: end;
  border-bottom: 2px solid #2f98d8;
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  min-height: 50px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 8px 0;
  scrollbar-width: none;
}

.account-tabs::-webkit-scrollbar {
  display: none;
}

.account-tab {
  appearance: none;
  background: #eef3f5;
  border: 1px solid #c8d5dc;
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
  font-weight: 800;
  min-height: 42px;
  padding: 10px 18px;
  position: relative;
  top: 2px;
  transition: background 0.16s ease, color 0.16s ease;
}

.account-tab.active {
  background: #fff;
  border-color: #2f98d8;
  border-top: 3px solid #2f98d8;
  border-bottom: 2px solid #fff;
  box-shadow: none;
  color: var(--ink);
  font-weight: 900;
  min-height: 44px;
  transform: none;
  z-index: 1;
}

.account-tab:not(.active):hover {
  background: #f7fafb;
  color: var(--ink);
}

.person-identity {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.avatar {
  background: #e8f0e8;
  border-radius: 8px;
  color: var(--green);
  display: grid;
  flex: 0 0 auto;
  height: 44px;
  place-items: center;
  width: 44px;
}

.avatar svg {
  height: 22px;
  width: 22px;
}

.person-identity > div:last-child {
  min-width: 0;
  width: 100%;
}

.name-banner {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 0;
}

.name-banner h2 {
  font-size: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.name-banner .icon-btn {
  flex: 0 0 auto;
  height: 30px;
  width: 30px;
}

.name-banner .icon-btn svg {
  height: 16px;
  width: 16px;
}

.person-info-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-actions .secondary {
  min-height: 36px;
  padding: 8px 10px;
}

.person-balance-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  overflow: hidden;
}

.person-balance-strip article {
  align-items: baseline;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 9px 11px;
}

.person-balance-strip article:last-child {
  border-bottom: 0;
}

.person-balance-strip span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.person-balance-strip strong {
  display: inline-block;
  font-size: 18px;
  margin-top: 0;
  text-align: right;
}

.balance-credit {
  color: var(--green);
}

.balance-debit {
  color: var(--red);
}

.action-row {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding-top: 12px;
}

.action-row input {
  min-height: 42px;
  width: 145px;
}

.regular-summary-panel {
  align-items: center;
  --panel-color: #315f78;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  overflow: hidden;
  padding: 0 12px 12px;
}

.regular-summary-heading {
  align-items: center;
  background: var(--panel-color);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 0 -12px 2px;
  min-height: 40px;
  padding: 7px 10px;
}

.regular-summary-heading h3 {
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  margin: 0;
}

.summary-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.regular-summary-content {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 220px);
}

.regular-summary-chart {
  align-items: center;
  justify-self: end;
  display: grid;
  gap: 10px;
  justify-items: center;
}

.summary-pie {
  aspect-ratio: 1;
  border: 8px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line);
  height: 106px;
}

.summary-chart-legend {
  display: grid;
  gap: 5px;
  justify-items: start;
}

.summary-chart-legend span {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  gap: 7px;
  text-transform: uppercase;
}

.summary-chart-legend i {
  border-radius: 999px;
  display: inline-block;
  height: 9px;
  width: 9px;
}

.legend-credit {
  background: var(--green);
}

.legend-debit {
  background: var(--red);
}

.legend-interest {
  background: var(--blue);
}

#selectedMeta {
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.45;
  margin: 0;
}

.transaction-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.transaction-form label {
  display: grid;
  gap: 6px;
}

.transaction-form label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.transaction-form .checkbox-field {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
}

.transaction-form .checkbox-field input {
  min-height: auto;
  width: auto;
}

.transaction-form .segmented,
.transaction-form .form-status,
.transaction-form button,
.wide-field {
  grid-column: 1 / -1;
}

.primary:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.form-status {
  border-radius: 8px;
  font-weight: 700;
  padding: 10px 12px;
}

.form-status.success {
  background: #edf7ef;
  color: var(--green);
}

.form-status.error {
  background: #faeeee;
  color: var(--red);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  min-height: 42px;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: grid;
  place-items: center;
  height: 100%;
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
}

.segmented input:checked + span {
  background: var(--blue);
  color: #fff;
}

.invoice-grid {
  display: grid;
  gap: 16px;
}

.invoice-section {
  --panel-color: #315f78;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  overflow: hidden;
  padding: 0 12px 12px;
}

.invoice-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 40px;
  margin: 0 -12px 6px;
  padding: 7px 10px;
  background: var(--panel-color);
  border-bottom: 0;
}

.invoice-title strong {
  color: #fff;
  font-size: 16px;
  white-space: nowrap;
  text-align: right;
}

.invoice-title .eyebrow,
.invoice-title h3 {
  color: #fff;
}

.invoice-title h3 {
  font-size: 13px;
  font-weight: 800;
  margin: 0;
}

.invoice-title-actions {
  align-items: center;
  display: inline-flex;
  gap: 10px;
}

.invoice-title .panel-plus {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.94);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
  color: #fff;
  min-height: 34px;
  width: 34px;
}

.invoice-title .panel-plus:hover {
  background: rgba(255, 255, 255, 0.22);
}

.credit-section {
  --panel-color: var(--green);
}

.credit-section .invoice-title {
  border-left: 0;
}

.debit-section {
  --panel-color: var(--red);
}

.debit-section .invoice-title {
  border-left: 0;
}

.interest-section {
  --panel-color: var(--amber);
}

.interest-section .invoice-title {
  border-left: 0;
}

.interest-body {
  display: grid;
  gap: 14px;
  padding: 0;
}

#interestMethod {
  color: var(--muted);
  margin: 0;
}

.interest-group-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  overflow: hidden;
  padding: 0;
}

.interest-group-summary article {
  align-items: baseline;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(90px, 1fr) minmax(110px, auto) minmax(100px, auto) minmax(70px, auto);
  padding: 9px 11px;
}

.interest-group-summary article:last-child {
  border-bottom: 0;
}

.interest-group-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.interest-group-summary strong {
  color: var(--ink);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.interest-group-summary small {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-align: right;
}

.interest-group-summary em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  text-align: right;
}

.interest-groups {
  display: grid;
  gap: 10px;
}

.interest-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.interest-group header {
  display: grid;
  grid-template-columns: 1fr repeat(4, minmax(100px, auto));
  gap: 10px;
  align-items: center;
  background: #f7f4ec;
  padding: 10px;
}

.interest-group header span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.interest-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.interest-group li {
  display: grid;
  grid-template-columns: 1fr repeat(4, minmax(90px, auto));
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

.invoice-section .table-wrap {
  border: 0;
  border-radius: 0;
}

.invoice-section > .table-wrap,
.interest-body > .table-wrap {
  margin: 0 -12px;
}

.loan-section-panel .table-wrap {
  margin: 0;
}

.ledger-scroll {
  max-height: 320px;
  overflow: auto;
}

.interest-scroll {
  max-height: 360px;
  overflow: auto;
}

.interest-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.subtle-line {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

th {
  background: #eef2eb;
  color: var(--muted);
  font-size: 11px;
  position: sticky;
  top: 0;
  text-transform: uppercase;
  z-index: 1;
}

td {
  cursor: pointer;
  font-size: 13px;
}

.regular-date-cell {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.regular-particulars {
  min-width: 210px;
}

.regular-particulars strong {
  color: var(--ink);
  display: block;
  font-size: 13px;
  line-height: 1.25;
}

.regular-particulars small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  line-height: 1.35;
  margin-top: 3px;
}

.regular-action-col {
  width: 108px;
}

.interest-section tbody tr.interest-group-0 {
  background: #f1f8f2;
}

.interest-section tbody tr.interest-group-1 {
  background: #f2f6fb;
}

.interest-section tbody tr.interest-group-2 {
  background: #fff7e8;
}

.interest-section tbody tr.interest-group-3 {
  background: #f8f1fb;
}

.interest-section tbody tr.interest-group-4 {
  background: #eef8f7;
}

.interest-section tbody tr.interest-group-5 {
  background: #fbf2f0;
}

.right {
  text-align: right;
}

td.right,
th.right {
  font-variant-numeric: tabular-nums;
}

.table-icon-action {
  align-items: center;
  background: #eef2eb;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  height: 30px;
  justify-content: center;
  padding: 0;
  width: 30px;
}

.table-action-group {
  display: inline-flex;
  gap: 5px;
  justify-content: flex-end;
}

.particulars-action-cell {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.particulars-action-cell > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.table-icon-action:hover {
  background: #e2ebe4;
}

.table-icon-action.close-action {
  background: #edf7ef;
  border-color: #c8e3ce;
  color: var(--green);
}

.table-icon-action.close-action:hover {
  background: #dff0e3;
}

.table-icon-action.danger-action {
  background: #faeeee;
  border-color: #e8b8b4;
  color: var(--red);
}

.table-icon-action.danger-action:hover {
  background: #f4dddd;
}

.table-icon-action svg {
  height: 15px;
  width: 15px;
}

.modal-copy {
  color: var(--muted);
  line-height: 1.5;
  margin: 6px 0 14px;
}

.lender-list-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.lender-list-panel h3 {
  font-size: 0.86rem;
  margin: 0 0 8px;
}

.lender-default-row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
  padding: 8px 0;
}

.lender-default-row:first-child {
  border-top: 0;
}

.default-pill {
  background: #e8f5eb;
  border-radius: 999px;
  color: var(--green);
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 800;
  margin-left: 6px;
  padding: 2px 7px;
}

.default-lender-chip {
  background: #e8f5eb;
  border: 1px solid #c8e3ce;
  border-radius: 999px;
  color: var(--green);
  display: inline-flex;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 6px 10px;
}

.default-lender-chip:empty {
  display: none;
}

.ledger-footer {
  align-items: center;
  background: var(--soft);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px 14px;
  grid-template-columns: auto auto 1fr auto;
  padding: 10px 14px;
}

.ledger-footer span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.ledger-footer strong {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.ledger-footer span:nth-of-type(2) {
  justify-self: end;
}

.credit {
  color: var(--green);
  font-weight: 800;
}

.debit {
  color: var(--red);
  font-weight: 800;
}

.cashflow-credit {
  color: var(--blue);
  font-weight: 800;
}

.cashflow-debit {
  color: var(--red);
  font-weight: 800;
}

.cashflow-month-cell {
  background: #f0f6f8;
  color: var(--blue);
  font-weight: 900;
  min-width: 82px;
  text-align: center;
  vertical-align: middle;
}

.cashflow-month-row td {
  vertical-align: top;
}

.cashflow-month-row.cashflow-month-group-0 td:not(.cashflow-month-cell) {
  background: #fbfcf8;
}

.cashflow-month-row.cashflow-month-group-1 td:not(.cashflow-month-cell) {
  background: #f6fbfd;
}

.cashflow-month-total {
  border-top: 2px solid var(--blue);
}

.cashflow-month-total.cashflow-month-group-0 td:not(.cashflow-month-cell) {
  background: #eef5ef;
}

.cashflow-month-total.cashflow-month-group-1 td:not(.cashflow-month-cell) {
  background: #eaf4f8;
}

.cashflow-month-total td {
  font-weight: 900;
}

.cashflow-month-total span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.warning {
  color: var(--amber);
  font-weight: 800;
}

.drawer {
  position: fixed;
  inset: 0;
  display: grid;
  justify-items: end;
  background: rgba(23, 33, 27, 0.26);
  z-index: 10;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 33, 27, 0.28);
  z-index: 12;
}

.modal-card {
  width: min(620px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(23, 33, 27, 0.18);
  padding: 22px;
  position: relative;
}

.compact-modal {
  width: min(520px, 100%);
}

.compact-form {
  margin-top: 12px;
}

.preset-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

.modal-card .icon-btn {
  position: absolute;
  top: 16px;
  right: 16px;
}

.modal-actions {
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 16px;
}

.danger-zone {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
}

.share-panel {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
}

.inline-form {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
}

.share-list {
  display: grid;
  gap: 8px;
}

.share-row {
  align-items: center;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 8px 10px;
}

.share-row > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.confirm-box {
  background: #faeeee;
  border: 1px solid #e8b8b4;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.confirm-box p {
  margin: 0;
}

.drawer-card {
  width: min(430px, 100%);
  min-height: 100%;
  background: var(--surface);
  padding: 24px;
  position: relative;
}

.drawer-card .icon-btn {
  position: absolute;
  top: 18px;
  right: 18px;
}

dl {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 10px;
  margin: 22px 0;
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  margin: 0;
  word-break: break-word;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  padding: 12px 16px;
  z-index: 20;
}

.hidden {
  display: none;
}

.sr-only {
  border: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.loans-section {
  margin-top: 18px;
}

.loan-section-panel {
  --panel-color: var(--blue);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  margin-top: 14px;
  overflow: hidden;
  padding: 0 12px 12px;
}

.loan-panel-heading {
  align-items: center;
  background: var(--panel-color);
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin: 0 -12px 6px;
  min-height: 40px;
  padding: 7px 10px;
}

.compact-heading h3 {
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  margin: 0;
}

.loan-section-panel:nth-of-type(1) {
  --panel-color: var(--green);
}

.loan-section-panel:nth-of-type(2) {
  --panel-color: var(--blue);
}

.loan-section-panel:nth-of-type(3) {
  --panel-color: var(--amber);
}

.loan-section-panel:nth-of-type(4) {
  --panel-color: #315f78;
}

.loan-section-panel:nth-of-type(5) {
  --panel-color: #6b5b95;
}

.loan-section-panel:nth-of-type(6) {
  --panel-color: #8a5a2b;
}

.loan-section-panel:nth-of-type(7) {
  --panel-color: #3f6f78;
}

.loan-section-panel:nth-of-type(8) {
  --panel-color: var(--green);
}

.loan-section-panel:nth-of-type(9) {
  --panel-color: var(--red);
}

.loan-total-footer {
  align-items: center;
  background: var(--panel-color);
  color: #fff;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  justify-content: flex-end;
  margin: -2px -12px -12px;
  min-height: 38px;
  padding: 8px 12px;
}

.loan-total-footer:empty {
  display: none;
}

.loan-total-footer .total-item {
  align-items: baseline;
  display: inline-flex;
  gap: 7px;
}

.loan-total-footer span {
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.loan-total-footer strong {
  color: #fff;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.loan-total-footer strong.cashflow-credit {
  color: #9ed0ff;
}

.loan-total-footer strong.cashflow-debit {
  color: #ffd0cb;
}

.loan-tx-date-col {
  width: 18%;
}

.loan-tx-particulars-col {
  width: auto;
}

.loan-tx-amount-col {
  width: 22%;
}

.loan-tx-action-col {
  width: 76px;
}

#loanCreditTransactionTotal,
#loanDebitTransactionTotal {
  display: grid;
  grid-template-columns: 18% minmax(0, 1fr) 22% 76px;
  justify-content: stretch;
}

#loanCreditTransactionTotal .loan-total-count,
#loanDebitTransactionTotal .loan-total-count {
  grid-column: 1 / 3;
  justify-self: end;
}

#loanCreditTransactionTotal .loan-total-amount,
#loanDebitTransactionTotal .loan-total-amount {
  grid-column: 3;
  justify-self: end;
  text-align: right;
}

#loanCreditTransactionTotal .loan-total-action-spacer,
#loanDebitTransactionTotal .loan-total-action-spacer {
  grid-column: 4;
  width: 76px;
}

.loan-section-panel input[type="month"] {
  width: 150px;
}

.month-stepper {
  align-items: center;
  display: inline-flex;
  gap: 4px;
}

.month-stepper input[type="month"] {
  width: 138px;
}

.step-btn {
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  height: 30px;
  justify-content: center;
  min-width: 30px;
  padding: 0 8px;
}

.step-btn:hover {
  background: #f3f8f1;
}

.loan-section-panel .panel-actions {
  align-items: center;
  display: flex;
  gap: 6px;
}

.loan-section-panel .panel-actions select,
.loan-section-panel .panel-actions input[type="month"] {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  min-height: 30px;
  padding: 5px 8px;
}

.loan-section-panel .icon-label {
  align-items: center;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  height: 30px;
  justify-content: center;
  min-height: 30px;
  padding: 0;
  width: 30px;
}

.loan-section-panel .icon-label:hover {
  background: rgba(255, 255, 255, 0.28);
}

.loan-section-panel .icon-label svg {
  height: 15px;
  width: 15px;
}

.loan-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.compact-loan-summary {
  margin-bottom: 4px;
}

.loan-info-summary {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  gap: 6px 22px;
  grid-template-columns: repeat(2, minmax(190px, 1fr));
  margin-bottom: 6px;
  padding: 10px 12px;
}

.loan-summary article {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 4px;
}

.loan-info-summary article {
  align-items: baseline;
  background: transparent;
  border: 0;
  border-radius: 0;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 0;
}

.loan-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.loan-info-summary span {
  font-size: 10px;
}

.loan-summary strong {
  color: var(--blue);
  font-size: 17px;
}

.loan-info-summary strong {
  font-size: 14px;
}

#loanSummary.loan-info-summary {
  background: transparent;
  border: 0;
  gap: 10px;
  grid-template-columns: minmax(170px, 0.85fr) minmax(210px, 1.15fr) minmax(170px, 0.85fr);
  padding: 0;
}

.loan-summary-group {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(31, 45, 51, 0.06);
  display: grid;
  gap: 7px;
  min-height: 100%;
  overflow: hidden;
  padding: 0 12px 10px;
}

.loan-summary-group h4 {
  background: var(--green);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  margin: 0 -12px 4px;
  padding: 8px 12px;
  text-transform: uppercase;
}

.loan-summary-group:nth-child(2) h4 {
  background: var(--blue);
}

.loan-summary-group:nth-child(3) h4 {
  background: #315f78;
}

.loan-summary-group article {
  border-bottom: 1px dashed var(--line);
  min-height: 24px;
  padding: 2px 0;
}

.loan-summary-group article:last-child {
  border-bottom: 0;
}

.loan-summary-group.emphasis {
  background: #f2f8fa;
  border-color: #c9dde4;
}

.loan-summary-group.emphasis strong {
  color: var(--red);
  font-size: 16px;
}

.loan-total-row {
  background: #f3f8f6;
  border-top: 2px solid var(--green);
}

.loan-opening-row {
  background: #eef6f8;
}

.loan-opening-row td:nth-child(5),
.loan-opening-row td:last-child {
  color: var(--blue);
  font-weight: 800;
}

.loan-topup-row {
  background: #fff7e8;
}

.loan-discount-row {
  background: #edf7ef;
}

.loan-discount-row td:nth-child(5),
.loan-discount-row td:last-child {
  color: var(--green);
  font-weight: 800;
}

.loan-topup-row td:nth-child(5),
.loan-topup-row td:last-child {
  color: var(--amber);
  font-weight: 800;
}

.loan-total-row td {
  cursor: default;
  font-weight: 800;
}

.loan-total-row span {
  color: var(--muted);
  display: block;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.loan-total-row strong {
  font-size: 14px;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .transaction-form {
    grid-template-columns: 1fr 1fr;
  }

  .interest-group header,
  .interest-group li {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .shell {
    padding: 14px;
  }

  .topbar,
  .person-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-grid,
  .transaction-form,
  .loan-summary,
  .person-balance-strip,
  .regular-summary-content,
  .regular-summary-panel,
  .ledger-footer {
    grid-template-columns: 1fr;
  }

  .regular-summary-chart {
    justify-self: center;
  }

  .interest-group-summary article {
    grid-template-columns: 1fr;
  }

  .interest-group-summary strong,
  .interest-group-summary small,
  .interest-group-summary em {
    text-align: left;
  }

  .transaction-form .segmented,
  .transaction-form button {
    grid-column: auto;
  }

  #loanSummary.loan-info-summary {
    grid-template-columns: 1fr;
  }
}
