/* =========================================================================
   Teso Loan Point — design tokens
   Palette: deep indigo sidenav, warm brass accent, three interest-stage
   colours (on-time / late) that are used consistently everywhere
   a loan's status appears — table rows, badges, and the "Loan Clock" ring.
   Type: Fraunces (display) + Inter (UI) + IBM Plex Mono (figures/data).
   ========================================================================= */

:root {
  --ink-900: #0F1D33;
  --ink-800: #16274A;
  --ink-700: #1F3358;
  --ink-600: #2B4373;

  --paper: #F1F2ED;
  --card: #FFFFFF;
  --border: #E1E1D6;

  --brass: #C6923C;
  --brass-dark: #A6772C;
  --brass-tint: #F4E7CE;

  --clr-on-time: #3F7857;
  --clr-on-time-tint: #E4EFE7;
  --clr-late: #B23A48;
  --clr-late-tint: #F5DEE0;

  --text-primary: #16213A;
  --text-muted: #616B7A;
  --text-inverse: #F1F2ED;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-card: 0 1px 2px rgba(15, 29, 51, 0.06), 0 8px 24px rgba(15, 29, 51, 0.06);

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --sidenav-w: 264px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink-900);
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------------------------- App shell -------------------------------- */

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

/* ---------------------------- Sidenav ----------------------------------- */

.sidenav {
  width: var(--sidenav-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--ink-900), var(--ink-800) 60%, var(--ink-700));
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidenav__brand {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(241, 242, 237, 0.1);
}

.sidenav__brand .wordmark {
  display: block;
  max-width: 100%;
  color: #fff;
}

.sidenav__brand  {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: #fff;
  margin: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.brand-title{
  font-size:10px;
}
.sidenav__brand .wordmark .mark {
  float: left;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: conic-gradient(var(--clr-on-time) 0 50%, var(--clr-late) 50% 100%);
  margin-right: 10px;
  margin-bottom: 8px;
  box-shadow: inset 0 0 0 3px var(--ink-900);
}

.sidenav__brand .tagline {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(241, 242, 237, 0.55);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidenav__nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidenav__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(241, 242, 237, 0.72);
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidenav__link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }

.sidenav__link:hover {
  background: rgba(241, 242, 237, 0.06);
  color: #fff;
}

.sidenav__link.is-active {
  background: rgba(198, 146, 60, 0.14);
  color: #fff;
  border-left-color: var(--brass);
}

.sidenav__foot {
  padding: 16px 20px 22px;
  border-top: 1px solid rgba(241, 242, 237, 0.1);
  font-size: 13px;
}

.sidenav__user {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}

.sidenav__user .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brass);
  color: var(--ink-900);
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}

.sidenav__user .who { color: #fff; font-weight: 600; }
.sidenav__user .role { color: rgba(241, 242, 237, 0.5); font-size: 12px; }

.logout-btn {
  display: flex; align-items: center; gap: 8px;
  color: rgba(241, 242, 237, 0.6);
  background: none; border: none; cursor: pointer;
  font-family: var(--font-body); font-size: 13px; padding: 4px 0;
}
.logout-btn:hover { color: #fff; }

/* ---------------------------- Main content ------------------------------ */

.main {
  flex: 1;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 36px;
  border-bottom: 1px solid var(--border);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

.notification-control { position: relative; z-index: 6; flex: 0 0 auto; }
.notification-trigger {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink-800);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.notification-trigger:hover, .notification-trigger[aria-expanded="true"] {
  border-color: var(--ink-600);
  background: #f7f8f5;
  box-shadow: 0 2px 8px rgba(15, 29, 51, .1);
}
.notification-trigger:focus-visible, .notification-item:focus-visible,
.notification-menu__close:focus-visible, .notification-dialog button:focus-visible,
.notification-dialog a:focus-visible {
  outline: 3px solid rgba(198, 146, 60, .55);
  outline-offset: 2px;
}
.notification-trigger svg { width: 20px; height: 20px; }
.notification-count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border: 2px solid var(--paper);
  border-radius: 10px;
  background: var(--clr-late);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  white-space: nowrap;
}
.notification-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 32px));
  max-height: min(480px, calc(100dvh - 104px));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: 0 18px 46px rgba(15, 29, 51, .22);
}
.notification-menu[hidden] { display: none; }
.notification-menu__header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: #fbfbf8;
}
.notification-menu__header h2 { font: 600 15px var(--font-body); }
.notification-menu__close, .notification-dialog__close {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.notification-menu__items { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.notification-item {
  display: block;
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}
.notification-item:hover { background: #f5f7f3; }
.notification-item.is-unread {
  background: #fbf7ed;
  box-shadow: inset 3px 0 var(--brass);
}
.notification-item.is-unread:hover { background: #f7efdd; }
.notification-item__heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.notification-item__title { font-size: 13px; font-weight: 700; }
.notification-item__time { flex: 0 0 auto; color: var(--text-muted); font-size: 10px; }
.notification-item__preview { display: block; margin-top: 4px; color: var(--text-muted); font-size: 12px; line-height: 1.45; }
.notification-empty { margin: 0; padding: 20px 16px; color: var(--text-muted); font-size: 13px; }
.notification-dialog {
  position: fixed;
  width: min(500px, calc(100vw - 32px));
  max-width: none;
  max-height: min(80vh, 620px);
  padding: 26px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-primary);
  box-shadow: 0 22px 70px rgba(15, 29, 51, .28);
}
.notification-dialog::backdrop { background: rgba(15, 29, 51, .48); }
.notification-dialog__close { position: absolute; top: 14px; right: 14px; }
.notification-dialog__kind { display: block; margin: 4px 34px 8px 0; color: var(--clr-late); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.notification-dialog h2 { margin-right: 24px; font-size: 21px; }
.notification-dialog__time { display: block; margin-top: 8px; color: var(--text-muted); font-size: 12px; }
.notification-dialog__message { margin: 20px 0 24px; white-space: pre-line; }
.notification-dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.notification-dialog__actions [hidden] { display: none; }

@media (max-width: 900px) {
  .topbar { gap: 14px; padding: 18px 24px; }
  .topbar-controls { gap: 8px; }
  .topbar-actions { gap: 8px; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidenav {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 0;
  }
  .sidenav__brand { padding: 12px 16px 8px; }
  .sidenav__brand .tagline { margin-top: 2px; font-size: 10px; }
  .sidenav__nav {
    flex: none;
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
    padding: 8px 10px;
    scrollbar-width: thin;
  }
  .sidenav__link {
    flex: 0 0 auto;
    padding: 8px 10px;
    border-left: 0;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
  }
  .sidenav__link.is-active {
    border-left-color: transparent;
    border-bottom-color: var(--brass);
  }
  .sidenav__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px;
  }
  .sidenav__user { margin: 0; }
  .sidenav__foot form { margin-left: auto; }
  .main { width: 100%; }
  .content { padding: 22px 18px 44px; }
}

@media (max-width: 680px) {
  .topbar {
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    padding: 14px 16px;
  }
  .topbar > div:first-child { flex: 1 1 150px; min-width: 0; }
  .topbar-controls { flex: 1 1 100%; justify-content: flex-start; }
  .topbar-actions { width: 100%; justify-content: flex-start; gap: 6px; }
  .notification-menu {
    position: fixed;
    top: var(--notification-menu-top, 76px);
    right: 12px;
    width: min(390px, calc(100vw - 24px));
    max-height: calc(100dvh - var(--notification-menu-top, 76px) - 12px);
  }
  .notification-dialog {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 32px);
    padding: 22px 18px;
  }
  .notification-dialog__actions { justify-content: stretch; }
  .notification-dialog__actions .btn { flex: 1 1 auto; justify-content: center; }
}

@media (max-width: 380px) {
  .topbar { padding-right: 12px; padding-left: 12px; }
  .notification-menu { right: 8px; width: calc(100vw - 16px); }
  .notification-item__heading { align-items: flex-start; flex-direction: column; gap: 2px; }
  .content { padding-right: 12px; padding-left: 12px; }
}

.topbar h1 { font-size: 18px; }
.topbar .subtitle { color: var(--text-muted); font-size: 9px; margin-top: 2px; }

.content { padding: 28px 36px 60px; max-width: 1200px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--brass); color: var(--ink-900); }
.btn-primary:hover { background: var(--brass-dark); }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-primary); }
.btn-ghost:hover { background: var(--card); border-color: var(--ink-600); }

.btn-danger { background: var(--clr-late-tint); color: var(--clr-late); }
.btn-danger:hover { background: #eec6ca; }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }

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

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.card-pad { padding: 22px 24px; }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 15.5px; }

/* ---------------------------- Stat cards ---------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 1000px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.stat-card .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-card .value {
  font-family: var(--font-display);
  font-size: 30px;
  margin-top: 6px;
  color: var(--ink-900);
}

.stat-card .delta { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

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

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.badge-on_time, .badge-ACTIVE { background: var(--clr-on-time-tint); color: var(--clr-on-time); }
.badge-late_20pct_monthly { background: var(--clr-late-tint); color: var(--clr-late); }
.badge-SETTLED { background: var(--clr-on-time-tint); color: var(--clr-on-time); }
.badge-DEFAULTED { background: var(--clr-late-tint); color: var(--clr-late); }

.interest-log {
  margin-top: 18px;
  border-top: 1px dashed var(--border);
  padding-top: 14px;
}

.interest-log summary {
  cursor: pointer;
  color: var(--ink-700);
  font-size: 13px;
  font-weight: 600;
}

.interest-log__list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.interest-log__item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.interest-log__item small {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
}

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

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.data th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data tbody tr { transition: background 0.12s ease; }
table.data tbody tr:hover { background: #FAFAF6; }
table.data tbody tr:last-child td { border-bottom: none; }

.row-link { display: block; }

/* ---------------------------- Loan Clock ring ----------------------------- */

.ring {
  --p: 0;
  --c: var(--clr-on-time);
  width: 42px; height: 42px;
  border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--border) 0);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ring::after {
  content: "";
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--card);
}

.ring-lg { width: 168px; height: 168px; }
.ring-lg::after { width: 132px; height: 132px; }

.ring-center {
  position: absolute;
  text-align: center;
}

.ring-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; }

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

.form-grid { display: grid; gap: 16px; max-width: 520px; }
.field-group label, .stack-form label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}
.field-group input, .field-group select, .field-group textarea,
.stack-form input, .stack-form select, .stack-form textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-primary);
  font: 14px var(--font-body);
}
.field-group input:focus, .field-group select:focus, .field-group textarea:focus,
.stack-form input:focus, .stack-form select:focus, .stack-form textarea:focus {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
  border-color: var(--brass);
}
.field-group small { display: block; margin-top: 5px; color: var(--text-muted); font-size: 12px; }
.field-group .errorlist, .form-errors .errorlist, .stack-form .errorlist {
  margin: 6px 0 0;
  padding: 0;
  color: var(--clr-late);
  font-size: 12px;
  list-style: none;
}
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.stack-form { display: grid; gap: 8px; }
.stack-form h4 { margin: 0 0 4px; color: var(--ink-800); font-size: 14px; }
.muted { color: var(--text-muted); }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--card);
  color: var(--text-primary);
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
  border-color: var(--brass);
}

.field .errorlist { list-style: none; padding: 0; margin: 6px 0 0; color: var(--clr-late); font-size: 12.5px; }
.field .help { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field input { width: auto; }

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

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

.search-input {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 13.5px;
  min-width: 240px;
}
.search-input:focus { outline: 2px solid var(--brass); }

.tab-group { display: flex; gap: 6px; }
.tab {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
}
.tab.is-active { background: var(--ink-900); color: #fff; border-color: var(--ink-900); }
.tab:hover:not(.is-active) { border-color: var(--ink-600); color: var(--text-primary); }

/* ---------------------------- Messages ------------------------------------ */

.messages { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 8px; }
.messages li {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: 1px solid var(--border);
}
.messages .success { background: var(--clr-on-time-tint); color: var(--clr-on-time); border-color: transparent; }
.messages .warning { background: var(--clr-warn-tint); color: var(--clr-warn); border-color: transparent; }
.messages .error { background: var(--clr-late-tint); color: var(--clr-late); border-color: transparent; }
.messages .info { background: var(--brass-tint); color: var(--brass-dark); border-color: transparent; }

/* ---------------------------- Misc ----------------------------------------- */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state h3 { color: var(--text-primary); margin-bottom: 6px; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; margin: 28px 0 12px; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

.kv-list { display: flex; flex-direction: column; gap: 12px; }
.kv-list .kv { display: flex; justify-content: space-between; font-size: 13.5px; padding-bottom: 10px; border-bottom: 1px dashed var(--border); }
.kv-list .kv:last-child { border-bottom: none; padding-bottom: 0; }
.kv-list .k { color: var(--text-muted); }
.kv-list .v { font-family: var(--font-mono); font-weight: 600; }

.pagination {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.pagination-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
}

.pagination-inline {
  margin: 0 16px 16px;
}

.pagination__summary {
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.pagination__links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-note {
  margin-top: 22px;
  display: flex;
  gap: 16px;
  font-size: 12.5px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.timeline-note span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.report-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}

.report-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 28px;
}

.report-brand {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass-dark);
  margin-bottom: 10px;
}

.report-header h1 {
  font-size: 34px;
  margin-bottom: 8px;
}

.report-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.report-filter-bar {
  margin-top: 18px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.report-filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.report-filter-field label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.report-filter-field input {
  min-width: 172px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--card);
  color: var(--text-primary);
}

.report-filter-field input:focus {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
  border-color: var(--brass);
}

.report-filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.report-meta {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 220px;
  align-items: flex-end;
}

.report-meta div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.report-meta strong {
  color: var(--text-primary);
  font-size: 13px;
}

.report-grid {
  margin-bottom: 24px;
}

.report-stat-grid {
  margin-bottom: 28px;
}

.report-copy {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.collateral-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.collateral-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  text-decoration: none;
}

.collateral-item img {
  width: 100%;
  height: 128px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
}

@media print {
  body.print-page {
    background: #fff;
  }

  .report-shell {
    max-width: none;
    padding: 0;
  }

  .print-trigger {
    display: none;
  }

  .notification-control {
    display: none !important;
  }

  .report-filter-bar {
    display: none;
  }

  .card,
  .stat-card,
  .pagination-card {
    box-shadow: none;
    break-inside: avoid;
  }

  .section-title {
    break-after: avoid;
  }
}

/* Login page */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, var(--ink-700), var(--ink-900) 60%);
  padding: 20px;
}

.login-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-brand .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: conic-gradient(var(--clr-on-time) 0 50%, var(--clr-late) 50% 100%);
  box-shadow: inset 0 0 0 3px #fff;
  flex-shrink: 0;
}
.login-brand .wordmark {
  font-family: var(--font-display); font-size: 20px; font-weight: 600;
  line-height: 1.2; max-width: 100%; word-break: break-word; overflow-wrap: anywhere;
}
.login-card .tagline { color: var(--text-muted); font-size: 13px; margin: 4px 0 28px; }

/* ------------------------- Portfolio overview ---------------------------- */

.overview-dashboard {
  --overview-blue: #397eb7;
  --overview-mint: #358b68;
  --overview-coral: #bd5d5d;
  --overview-gold: #a77b2f;
  --overview-line: #e9edf0;
  display: grid;
  gap: 18px;
  color: #273647;
}

.overview-welcome {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 2px 0 4px;
}

.overview-eyebrow,
.overview-section-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #788594;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1.3;
  text-transform: uppercase;
}

.overview-eyebrow span { color: #9aa4ae; font-weight: 500; letter-spacing: 0; text-transform: none; }
.overview-welcome h2 { margin-top: 7px; color: #26374a; font: 600 24px/1.2 var(--font-body); letter-spacing: 0; }
.overview-welcome p { margin: 5px 0 0; color: #7a8794; font-size: 12px; }

.overview-primary-action {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border: 1px solid #dce7ee;
  border-radius: 7px;
  background: #fff;
  color: #2d648f;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.overview-primary-action:hover { transform: translateY(-1px); border-color: #aac8de; background: #f7fbfe; }
.overview-action-icon { display: grid; width: 25px; height: 25px; place-items: center; border-radius: 6px; background: #eaf3fa; color: #397eb7; font-size: 21px; font-weight: 400; line-height: 1; }

.overview-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.overview-metric {
  display: grid;
  min-width: 0;
  min-height: 142px;
  grid-template-columns: 38px minmax(0, 1fr);
  grid-template-rows: 38px auto auto;
  align-content: start;
  column-gap: 11px;
  padding: 15px;
  border: 1px solid var(--overview-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 7px rgba(28, 50, 69, .035);
  transition: transform .16s ease, box-shadow .16s ease;
}

.overview-metric:hover { transform: translateY(-2px); box-shadow: 0 7px 18px rgba(28, 50, 69, .08); }
.overview-metric-icon { display: grid; width: 36px; height: 36px; grid-row: 1; place-items: center; border-radius: 8px; }
.overview-metric-icon svg { width: 19px; height: 19px; }
.overview-metric--blue .overview-metric-icon { background: #eaf3fa; color: var(--overview-blue); }
.overview-metric--mint .overview-metric-icon { background: #e9f5ef; color: var(--overview-mint); }
.overview-metric--coral .overview-metric-icon { background: #fbefee; color: var(--overview-coral); }
.overview-metric--gold .overview-metric-icon { background: #f7f1e5; color: var(--overview-gold); }
.overview-metric-label { align-self: center; color: #73808c; font-size: 11px; font-weight: 600; }
.overview-metric strong { grid-column: 1 / -1; align-self: end; margin-top: 9px; color: #26374a; font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.overview-metric--coral strong, .overview-metric--gold strong { font-size: 17px; }
.overview-metric-foot { display: flex; grid-column: 1 / -1; justify-content: space-between; gap: 8px; margin-top: 7px; color: #98a2ad; font-size: 10px; }
.overview-metric-foot span { color: #56a27e; font-size: 14px; line-height: 1; }

.overview-columns { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(265px, .85fr); align-items: start; gap: 15px; }
.overview-primary-column, .overview-rail { display: grid; min-width: 0; gap: 15px; }
.overview-panel { min-width: 0; padding: 17px; border: 1px solid var(--overview-line); border-radius: 8px; background: #fff; box-shadow: 0 2px 7px rgba(28, 50, 69, .035); }
.overview-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.overview-panel-heading h3 { margin-top: 3px; color: #2c3c4d; font: 650 14px/1.35 var(--font-body); letter-spacing: 0; }
.overview-section-kicker { font-size: 9px; letter-spacing: .075em; }
.overview-period { flex: 0 0 auto; padding: 5px 8px; border: 1px solid #edf0f2; border-radius: 5px; color: #82909c; font-size: 10px; }
.overview-chart-wrap { position: relative; height: 205px; }
.overview-stage-chart { position: relative; width: 100%; height: 150px; }
.overview-text-link { flex: 0 0 auto; color: #397eb7; font-size: 10px; font-weight: 700; }
.overview-text-link:hover { color: #245b88; }
.overview-icon-link { display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid #edf0f2; border-radius: 6px; color: #397eb7; font-size: 14px; }

.overview-action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.overview-action-grid a { display: flex; min-width: 0; min-height: 48px; align-items: center; gap: 8px; padding: 7px; border: 1px solid #edf0f2; border-radius: 6px; color: #526171; font-size: 10px; font-weight: 650; transition: background .15s ease, border-color .15s ease; }
.overview-action-grid a:hover { border-color: #d4e1e9; background: #f8fbfd; }
.overview-action-grid .overview-action-icon { flex: 0 0 27px; width: 27px; height: 27px; font-size: 17px; }
.overview-action-icon--blue { background: #eaf3fa; color: var(--overview-blue); }
.overview-action-icon--mint { background: #e9f5ef; color: var(--overview-mint); }
.overview-action-icon--coral { background: #fbefee; color: var(--overview-coral); }
.overview-action-icon--gold { background: #f7f1e5; color: var(--overview-gold); }

.overview-stage-legend { display: grid; gap: 8px; margin-top: 5px; }
.overview-stage-legend > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: #697785; font-size: 10px; }
.overview-stage-legend strong { color: #304153; font-size: 11px; font-variant-numeric: tabular-nums; }
.overview-legend-label { display: inline-flex; align-items: center; gap: 7px; }
.overview-dot { width: 8px; height: 8px; border-radius: 50%; }
.overview-dot--mint { background: #65b98e; }
.overview-dot--coral { background: #ee807e; }
.overview-stage-alert { margin-top: 3px; padding-top: 9px; border-top: 1px solid var(--overview-line); }
.overview-stage-alert strong { color: var(--overview-coral); }

.overview-savings-total { color: #2e7155; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.overview-savings-caption { margin-top: 3px; color: #8a96a1; font-size: 10px; }
.overview-savings-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 13px; padding-top: 10px; border-top: 1px solid var(--overview-line); color: #788592; font-size: 10px; }
.overview-savings-footer strong { color: #304153; font-variant-numeric: tabular-nums; }

.overview-activity-list, .overview-loan-list, .overview-due-list { display: grid; }
.overview-activity-row, .overview-loan-row, .overview-due-row { display: grid; min-width: 0; align-items: center; gap: 10px; border-bottom: 1px solid #eff1f3; transition: background .12s ease; }
.overview-activity-row:last-child, .overview-loan-row:last-child, .overview-due-row:last-child { border-bottom: 0; }
.overview-activity-row:hover, .overview-loan-row:hover, .overview-due-row:hover { background: #f8fafb; }
.overview-activity-row { grid-template-columns: 30px minmax(0, 1fr) auto; padding: 10px 3px; }
.overview-activity-symbol { display: grid; width: 27px; height: 27px; place-items: center; border-radius: 50%; background: #e9f5ef; color: #358b68; font-size: 14px; }
.overview-activity-description, .overview-activity-amount, .overview-loan-person, .overview-loan-principal, .overview-due-person { display: grid; min-width: 0; gap: 2px; }
.overview-activity-description strong, .overview-loan-person strong, .overview-due-person strong { overflow: hidden; color: #354556; font-size: 10px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.overview-activity-description small, .overview-activity-amount small, .overview-loan-person small, .overview-loan-principal small, .overview-due-person small { overflow: hidden; color: #909ba6; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.overview-activity-amount { color: #34815f; font-size: 10px; font-weight: 700; text-align: right; white-space: nowrap; }
.overview-activity-amount small { font-weight: 400; }
.overview-loan-row { grid-template-columns: 38px minmax(90px, 1fr) minmax(95px, auto) auto; padding: 10px 3px; }
.overview-loan-id { color: #85919c; font: 600 10px var(--font-mono); }
.overview-loan-principal { color: #354556; font-size: 10px; font-weight: 650; text-align: right; white-space: nowrap; }
.overview-status { justify-self: end; padding: 4px 7px; border-radius: 999px; font-size: 9px; font-weight: 700; white-space: nowrap; }
.overview-status--on-time, .overview-status--settled { background: #e8f4ed; color: #35815e; }
.overview-status--late, .overview-status--defaulted { background: #fbefee; color: #b45c5b; }
.overview-due-row { grid-template-columns: 34px minmax(0, 1fr) auto; padding: 9px 2px; }
.overview-due-date { display: grid; place-items: center; color: #397eb7; font-size: 15px; font-weight: 700; line-height: 1.05; }
.overview-due-date small { color: #82909c; font-size: 8px; font-weight: 600; text-transform: uppercase; }
.overview-due-amount { color: #354556; font-size: 9px; font-weight: 700; text-align: right; white-space: nowrap; }
.overview-empty { padding: 20px 5px; color: #8995a1; font-size: 11px; text-align: center; }
.overview-empty--compact { padding: 12px 2px 3px; font-size: 10px; }
.overview-pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 10px; color: #8995a1; font-size: 9px; }
.overview-pagination > div { display: flex; gap: 5px; }
.overview-pagination a { display: grid; width: 25px; height: 25px; place-items: center; border: 1px solid #e9edf0; border-radius: 5px; color: #397eb7; font-size: 13px; }
.overview-pagination a:hover { background: #f4f8fb; }
.overview-report-link { min-height: 36px; padding: 7px 10px; font-size: 11px; }

.overview-cashflow { padding: 15px 17px 11px; border: 1px solid var(--overview-line); border-radius: 8px; background: #fff; box-shadow: 0 2px 7px rgba(28, 50, 69, .035); }
.overview-cashflow-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.overview-cashflow-heading h3 { margin-top: 3px; color: #2c3c4d; font: 650 14px/1.35 var(--font-body); letter-spacing: 0; }
.overview-flow-period { flex: 0 0 auto; color: #85919c; font-size: 10px; }
.overview-flow-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; }
.overview-flow-item { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; border-left: 1px solid #edf0f2; }
.overview-flow-item:first-child { padding-left: 0; border-left: 0; }
.overview-flow-item:last-child { padding-right: 0; }
.overview-flow-label { display: grid; gap: 3px; color: #526373; font-size: 11px; font-weight: 700; }
.overview-flow-label i { display: inline-grid; width: 17px; height: 17px; place-items: center; margin-right: 4px; border-radius: 50%; font-size: 11px; font-style: normal; line-height: 1; }
.overview-flow-item--in .overview-flow-label i { background: #e8f4ed; color: #35815e; }
.overview-flow-item--out .overview-flow-label i { background: #fbefee; color: #b45c5b; }
.overview-flow-label small { color: #8a96a1; font-size: 9px; font-weight: 400; }
.overview-flow-item > strong { color: #314659; font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.overview-flow-item--in > strong, .overview-flow-item > strong.is-positive { color: #35815e; }
.overview-flow-item--out > strong, .overview-flow-item > strong.is-negative { color: #b45c5b; }
.overview-flow-note { margin: 8px 0 0; color: #8b96a0; font-size: 9px; }

@media (max-width: 1050px) {
  .overview-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-columns { grid-template-columns: minmax(0, 1fr); }
  .overview-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

@media (max-width: 760px) {
  .overview-welcome { align-items: flex-start; }
  .overview-welcome h2 { font-size: 21px; }
  .overview-rail { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 520px) {
  .overview-welcome { flex-direction: column; gap: 12px; }
  .overview-flow-grid { grid-template-columns: minmax(0, 1fr); }
  .overview-flow-item, .overview-flow-item:first-child, .overview-flow-item:last-child { padding: 9px 0; border-left: 0; border-top: 1px solid #edf0f2; }
  .overview-flow-item:first-child { border-top: 0; }
  .overview-metrics { gap: 8px; }
  .overview-metric { min-height: 132px; padding: 12px; }
  .overview-metric strong { font-size: 18px; }
  .overview-metric--coral strong, .overview-metric--gold strong { font-size: 15px; }
  .overview-panel { padding: 13px; }
  .overview-loan-row { grid-template-columns: 31px minmax(0, 1fr) auto; gap: 7px; }
  .overview-loan-principal { font-size: 9px; }
  .overview-status { grid-column: 2 / -1; justify-self: start; }
  .overview-chart-wrap { height: 185px; }
}

@media (max-width: 360px) {
  .overview-metrics { grid-template-columns: minmax(0, 1fr); }
  .overview-metric { min-height: 118px; }
}

/* -------------------------- Loan settings -------------------------------- */

.loan-settings-page { display: grid; max-width: 1120px; gap: 18px; }
.loan-settings-intro { display: flex; align-items: center; gap: 14px; padding: 3px 0 5px; }
.loan-settings-mark { display: grid; width: 43px; height: 43px; flex: 0 0 43px; place-items: center; border: 1px solid #dce9f0; border-radius: 8px; background: #eaf3fa; color: #397eb7; }
.loan-settings-mark svg { width: 21px; height: 21px; }
.loan-settings-intro h2 { margin-top: 3px; color: #263b4e; font: 650 21px/1.3 var(--font-body); letter-spacing: 0; }
.loan-settings-intro p { margin: 3px 0 0; color: #7c8995; font-size: 11px; }
.loan-settings-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); align-items: start; gap: 15px; }
.loan-settings-panel, .loan-settings-summary { min-width: 0; padding: 19px; border: 1px solid #e5eaee; border-radius: 8px; background: #fff; box-shadow: 0 2px 8px rgba(30, 54, 73, .045); }
.loan-settings-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 15px; border-bottom: 1px solid #edf0f2; }
.loan-settings-panel-heading h3, .loan-settings-summary h3 { margin-top: 4px; color: #304457; font: 650 14px/1.4 var(--font-body); letter-spacing: 0; }
.loan-settings-scope { padding: 5px 8px; border-radius: 5px; background: #eaf3fa; color: #397eb7; font-size: 9px; font-weight: 700; white-space: nowrap; }
.loan-policy-form { display: grid; gap: 17px; padding-top: 17px; }
.loan-policy-field { display: grid; gap: 6px; }
.loan-policy-field[hidden] { display: none; }
.loan-policy-field > label, .loan-policy-toggle-row > div > label { color: #435768; font-size: 11px; font-weight: 700; }
.loan-policy-field > small, .loan-policy-toggle-row small { color: #84919d; font-size: 10px; line-height: 1.5; }
.loan-policy-input { display: flex; width: min(100%, 250px); min-height: 40px; align-items: center; overflow: hidden; border: 1px solid #dfe6eb; border-radius: 6px; background: #fff; }
.loan-policy-input:focus-within { border-color: #75a8cb; box-shadow: 0 0 0 2px rgba(57, 126, 183, .13); }
.loan-policy-input input { width: 100%; min-width: 0; height: 38px; padding: 8px 11px; border: 0; outline: 0; color: #304457; font: 600 13px var(--font-body); font-variant-numeric: tabular-nums; }
.loan-policy-input > span { padding: 0 11px; color: #81909c; font-size: 10px; }
.loan-policy-input--percent > span { font-size: 13px; font-weight: 700; }
.loan-policy-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-top: 1px solid #edf0f2; border-bottom: 1px solid #edf0f2; }
.loan-policy-toggle-row > div { display: grid; gap: 3px; }
.loan-policy-switch { position: relative; display: inline-flex; flex: 0 0 auto; cursor: pointer; }
.loan-policy-switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.loan-policy-switch > span { position: relative; display: block; width: 39px; height: 22px; border-radius: 999px; background: #cbd4da; transition: background .16s ease; }
.loan-policy-switch > span::after { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(26, 45, 59, .18); content: ""; transition: transform .16s ease; }
.loan-policy-switch input:checked + span { background: #4b9a75; }
.loan-policy-switch input:checked + span::after { transform: translateX(17px); }
.loan-policy-switch input:focus-visible + span { outline: 3px solid rgba(57, 126, 183, .25); outline-offset: 2px; }
.loan-settings-actions { display: flex; justify-content: flex-end; padding-top: 2px; }
.loan-settings-summary h3 { margin: 5px 0 15px; }
.loan-settings-rule { display: grid; grid-template-columns: 25px minmax(0, 1fr); gap: 9px; padding: 12px 0; border-top: 1px solid #edf0f2; }
.loan-settings-rule-number { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 6px; background: #f1f5f7; color: #718493; font: 600 9px var(--font-mono); }
.loan-settings-rule p { margin: 0; color: #7b8995; font-size: 10px; line-height: 1.55; }
.loan-settings-rule strong { color: #354a5c; font-size: 11px; }
.loan-settings-notice { display: grid; gap: 4px; margin-top: 10px; padding: 12px; border: 1px solid #dfeaf1; border-radius: 6px; background: #f5f9fb; color: #687b89; font-size: 10px; line-height: 1.5; }
.loan-settings-notice strong { color: #356b91; }
.loan-policy-field .errorlist, .loan-policy-form .errorlist { margin: 0; padding: 0; color: #b45b5a; font-size: 10px; list-style: none; }

@media (max-width: 760px) {
  .loan-settings-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 420px) {
  .loan-settings-panel, .loan-settings-summary { padding: 14px; }
  .loan-settings-panel-heading { align-items: flex-start; flex-direction: column; }
  .loan-settings-actions .btn { width: 100%; justify-content: center; }
}

/* ------------------------------- Insights -------------------------------- */

.insights-page { display: grid; max-width: 1440px; gap: 15px; }
.insights-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 3px 0 4px; }
.insights-intro h2 { margin-top: 4px; color: #263b4e; font: 650 21px/1.3 var(--font-body); letter-spacing: 0; }
.insights-intro p { margin: 4px 0 0; color: #7c8995; font-size: 11px; }
.insights-as-of, .insights-count { flex: 0 0 auto; color: #82909c; font-size: 10px; }
.insights-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.insights-stat { display: grid; min-width: 0; gap: 7px; padding: 14px; border: 1px solid #e5eaee; border-top: 3px solid #397eb7; border-radius: 7px; background: #fff; box-shadow: 0 2px 8px rgba(30, 54, 73, .04); }
.insights-stat > span { color: #73818e; font-size: 10px; font-weight: 650; }
.insights-stat > strong { color: #304457; font-size: 18px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.insights-stat > small { color: #8a96a0; font-size: 9px; }
.insights-stat--coral { border-top-color: #bd5d5d; }
.insights-stat--blue { border-top-color: #397eb7; }
.insights-stat--mint { border-top-color: #358b68; }
.insights-stat--gold { border-top-color: #a77b2f; }
.insights-panel { min-width: 0; padding: 17px; border: 1px solid #e5eaee; border-radius: 8px; background: #fff; box-shadow: 0 2px 8px rgba(30, 54, 73, .04); }
.insights-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.insights-panel-heading h3 { margin-top: 3px; color: #304457; font: 650 14px/1.4 var(--font-body); letter-spacing: 0; }
.insights-chart-wrap { position: relative; height: 250px; }
.insights-legend { display: flex; flex-wrap: wrap; gap: 12px; color: #71808d; font-size: 9px; }
.insights-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.insights-legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.insights-legend-dot--actual { background: #397eb7; }
.insights-legend-dot--forecast { background: #358b68; }
.insights-method { margin: 8px 0 0; color: #87939d; font-size: 9px; line-height: 1.5; }
.insights-lower-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr); align-items: start; gap: 12px; }
.insights-schedule-list { display: grid; }
.insights-schedule-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 2px; border-bottom: 1px solid #edf0f2; color: #667684; font-size: 11px; }
.insights-schedule-row:last-child { border-bottom: 0; }
.insights-schedule-row strong { color: #30475b; font-size: 12px; font-variant-numeric: tabular-nums; }
.insights-upcoming-heading { margin: 12px 0 3px; padding-top: 11px; border-top: 1px solid #edf0f2; color: #788693; font-size: 9px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.insights-upcoming-list { display: grid; }
.insights-upcoming-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 2px; border-bottom: 1px solid #f0f2f4; }
.insights-upcoming-row:last-child { border-bottom: 0; }
.insights-upcoming-row > span { display: grid; min-width: 0; gap: 2px; }
.insights-upcoming-row strong { color: #405465; font-size: 10px; }
.insights-upcoming-row small { color: #8a96a0; font-size: 9px; }
.insights-risk-counts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.insights-risk-counts > div { display: grid; gap: 3px; padding: 9px 7px; border: 1px solid #edf0f2; border-radius: 6px; text-align: center; }
.insights-risk-counts strong { color: #344a5e; font-size: 17px; font-variant-numeric: tabular-nums; }
.insights-risk-counts span { color: #7d8994; font-size: 9px; }
.insights-risk-count--high { background: #fbf1ef; }
.insights-risk-count--moderate { background: #fbf6e9; }
.insights-risk-count--low { background: #edf6f0; }
.insights-risk-count--unrated { background: #f5f7f8; }
.insights-borrower-risk { padding-bottom: 8px; }
.insights-risk-table { min-width: 830px; }
.insights-risk-table td { vertical-align: top; }
.insights-risk-table td:first-child { min-width: 145px; }
.insights-risk-table td:first-child small { display: block; margin-top: 3px; color: #8a96a0; font-size: 9px; }
.insights-risk-table td:last-child { min-width: 190px; color: #778591; font-size: 10px; }
.insights-risk-badge { display: inline-flex; padding: 4px 7px; border-radius: 5px; font-size: 9px; font-weight: 700; white-space: nowrap; }
.insights-risk-badge--high { background: #fbefee; color: #b45b5a; }
.insights-risk-badge--moderate { background: #f8f2e4; color: #96712c; }
.insights-risk-badge--low { background: #eaf5ef; color: #35815e; }
.insights-risk-badge--unrated { background: #eff2f4; color: #758391; }
.insights-empty { padding: 18px 5px; color: #87939d; font-size: 10px; text-align: center; }

@media (max-width: 1000px) {
  .insights-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insights-lower-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .insights-intro { align-items: flex-start; flex-direction: column; }
  .insights-summary { gap: 7px; }
  .insights-stat { padding: 11px; }
  .insights-stat > strong { font-size: 15px; }
  .insights-panel { padding: 13px; }
  .insights-panel-heading { align-items: flex-start; flex-direction: column; }
  .insights-chart-wrap { height: 210px; }
}

@media (max-width: 360px) {
  .insights-summary { grid-template-columns: minmax(0, 1fr); }
  .insights-risk-counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ----------------------- Shared operations screens ----------------------- */

:root {
  --paper: #f3f6f8;
  --card: #fff;
  --border: #e3e9ed;
  --brass: #397eb7;
  --brass-dark: #2d689a;
  --brass-tint: #eaf3fa;
  --ink-900: #24384c;
  --ink-800: #2f4b65;
  --ink-700: #42617a;
  --ink-600: #54758e;
  --text-primary: #2d3c4a;
  --text-muted: #758391;
  --text-inverse: #f7f9fa;
  --radius-md: 8px;
  --radius-lg: 8px;
  --shadow-card: 0 2px 8px rgba(30, 54, 73, .045);
}

.sidenav {
  background: #fff;
  color: #566575;
  border-right: 1px solid #e5eaee;
}

.sidenav__brand { border-bottom-color: #edf0f2; }
.sidenav__brand .wordmark { color: #263b4e; }
.sidenav__brand .wordmark .mark { box-shadow: inset 0 0 0 3px #fff; }
.sidenav__brand .tagline { color: #83909b; }
.sidenav__link { color: #667583; }
.sidenav__link:hover { background: #f4f7f9; color: #304b62; }
.sidenav__link.is-active { background: #eaf3fa; color: #316f9f; border-left-color: #4a97cc; }
.sidenav__user .avatar { background: #e8f1f7; color: #326e9b; }
.sidenav__user .who { color: #33495d; }
.sidenav__user .role { color: #87939f; }
.sidenav__foot { border-top-color: #edf0f2; }
.logout-btn { color: #71808d; }
.logout-btn:hover { color: #315e7c; }

.topbar { background: rgba(255, 255, 255, .96); border-bottom-color: #e4e9ed; }
.topbar h1 { color: #263b4e; font: 650 18px/1.3 var(--font-body); letter-spacing: 0; }
.topbar .subtitle { color: #82909c; font-size: 11px; }
.content { max-width: 1440px; }

.btn { border-radius: 6px; }
.btn-primary { background: #397eb7; color: #fff; }
.btn-primary:hover { background: #2d689a; }
.btn-ghost { border-color: #e1e7eb; background: #fff; color: #536575; }
.btn-ghost:hover { border-color: #bed1df; background: #f7fafc; }
.btn-danger { background: #fbefee; color: #b25857; }
.btn-danger:hover { background: #f5e0de; }

.card, .stat-card, .pagination-card {
  border-color: #e5eaee;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(30, 54, 73, .045);
}
.card-header { border-bottom-color: #edf0f2; }
.card-header h3, .card-pad h3 { color: #304457; font: 650 14px/1.4 var(--font-body); letter-spacing: 0; }
.stat-card { padding: 16px 18px; }
.stat-card .label { color: #7c8995; font-size: 10px; letter-spacing: .06em; }
.stat-card .value { color: #2d4358; font: 650 23px/1.3 var(--font-body); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-card .delta { color: #8a96a0; font-size: 11px; }

.toolbar { align-items: center; margin-bottom: 14px; }
.toolbar form { margin-left: auto; }
.search-input { min-width: min(290px, 40vw); border-color: #e2e8ec; border-radius: 6px; color: #344858; }
.search-input:focus { outline: 2px solid rgba(57, 126, 183, .22); border-color: #78a9cb; }
.tab-group { gap: 4px; padding: 3px; border: 1px solid #e7ecef; border-radius: 7px; background: #f8fafb; }
.tab { padding: 6px 10px; border-color: transparent; border-radius: 5px; background: transparent; font-size: 11px; }
.tab.is-active { background: #fff; border-color: #e3e9ed; color: #326f9f; box-shadow: 0 1px 3px rgba(30, 54, 73, .07); }
.tab:hover:not(.is-active) { border-color: transparent; color: #315e7c; }

table.data { font-size: 12px; }
table.data th { padding: 11px 14px; border-bottom-color: #e8edf0; background: #f9fbfc; color: #758391; font-size: 9px; letter-spacing: .07em; }
table.data td { padding: 12px 14px; border-bottom-color: #edf0f2; color: #4d5d6b; }
table.data tbody tr:hover { background: #f7fafc; }
table.data td a:not(.btn) { color: #3477a9; font-weight: 600; }
.table-wrap { border-radius: 8px; }

.badge { padding: 4px 8px; border-radius: 5px; font-size: 10px; }
.badge::before { width: 6px; height: 6px; }
.badge-on_time, .badge-ACTIVE, .badge-SETTLED { background: #eaf5ef; color: #378362; }
.badge-late_20pct_monthly, .badge-DEFAULTED { background: #fbefee; color: #b45b5a; }

.field input, .field select, .field textarea,
.field-group input, .field-group select, .field-group textarea,
.stack-form input, .stack-form select, .stack-form textarea {
  min-height: 42px;
  border-color: #dfe6eb;
  border-radius: 6px;
  background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus,
.field-group input:focus, .field-group select:focus, .field-group textarea:focus,
.stack-form input:focus, .stack-form select:focus, .stack-form textarea:focus {
  outline: 2px solid rgba(57, 126, 183, .18);
  border-color: #75a8cb;
}
.field label, .field-group label, .stack-form label { color: #687887; font-size: 10px; letter-spacing: .045em; }
.field .help, .field-group small, .field-group .help { color: #87939e; }
.form-grid { max-width: 680px; gap: 16px; }
.form-card { max-width: 680px; border-radius: 8px; }
.form-actions { gap: 8px; }

.section-title { margin: 24px 0 10px; color: #758391; font-size: 10px; letter-spacing: .08em; }
.two-col { gap: 15px; }
.kv-list { gap: 0; }
.kv-list .kv { gap: 14px; padding: 11px 0; border-bottom: 1px solid #edf0f2; font-size: 12px; }
.kv-list .k { color: #82909b; }
.kv-list .v { color: #3b4f60; font: 600 11px/1.5 var(--font-body); text-align: right; overflow-wrap: anywhere; }
.empty-state { padding: 42px 20px; }
.empty-state h3 { color: #35495b; font: 650 15px/1.4 var(--font-body); }
.empty-state p { margin: 0; font-size: 12px; }
.pagination { gap: 10px; }
.pagination__summary { color: #7d8995; font-size: 11px; }
.pagination-card { padding: 11px 14px; }

.interest-log { border-top-color: #e9edf0; }
.interest-log summary { color: #397eb7; }
.interest-log__item { border-bottom-color: #edf0f2; }
.timeline-note { color: #758391; }
.alert.info { border-radius: 6px; }
.collateral-item img { border-radius: 6px; border-color: #e4e9ed; }

@media (max-width: 900px) {
  .toolbar { align-items: stretch; }
  .toolbar form { margin-left: 0; }
  .toolbar form, .toolbar .search-input { width: 100%; min-width: 0; }
}

@media (max-width: 760px) {
  .sidenav__brand { border-bottom: 0; }
  .sidenav__nav { border-bottom: 1px solid #edf0f2; }
  .sidenav__link.is-active { border-bottom-color: #4a97cc; }
}

@media (max-width: 520px) {
  .two-col { grid-template-columns: minmax(0, 1fr); }
  .stat-grid { gap: 8px; }
  .stat-card { padding: 13px; }
  .stat-card .value { font-size: 19px; }
  table.data th, table.data td { padding-right: 10px; padding-left: 10px; }
  .pagination-card { align-items: flex-start; }
}
