:root {
  --bg: #f6f8f7;
  --panel: #ffffff;
  --ink: #1f2a24;
  --muted: #69756e;
  --line: #dbe4de;
  --head: #eef4f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

.is-hidden {
  display: none !important;
}

.home-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(22, 121, 79, 0.16), transparent 30%),
    linear-gradient(135deg, #eef6f1 0%, #ffffff 46%, #f7faf8 100%);
}

.home-content {
  width: min(1120px, 100%);
  padding: 34px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(31, 42, 36, 0.1);
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  align-items: stretch;
  margin-bottom: 22px;
}

.home-content h1 {
  max-width: 620px;
  font-size: 42px;
  line-height: 1.05;
}

.home-text {
  max-width: 640px;
  margin: 14px 0 24px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.home-actions span {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  color: #0f5739;
  background: #e8f7ef;
  border: 1px solid #bfe5cf;
  border-radius: 8px;
  font-weight: 800;
}

.home-live-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 220px;
  padding: 24px;
  color: #fff;
  background: #16794f;
  border-radius: 8px;
}

.home-live-panel span,
.home-live-panel small {
  color: rgba(255, 255, 255, 0.78);
  font-weight: 800;
  text-transform: uppercase;
}

.home-live-panel strong {
  margin: 16px 0 8px;
  font-size: 38px;
  line-height: 1;
}

.home-live-panel small {
  font-size: 12px;
}

.home-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.home-stats article {
  min-height: 96px;
  padding: 14px;
  background: #fafcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.home-stats span,
.home-stats strong {
  display: block;
}

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

.home-stats strong {
  margin-top: 12px;
  font-size: 20px;
  line-height: 1.15;
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.contact-grid div {
  min-height: 86px;
  padding: 14px;
  background: #fafcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.social-icon {
  display: inline-grid !important;
  width: 36px;
  height: 36px;
  place-items: center;
  margin-bottom: 12px;
  color: #fff !important;
  background: #16794f;
  border-radius: 8px;
  font-size: 12px !important;
  font-weight: 900;
  text-transform: uppercase;
}

.contact-grid div:nth-child(2) .social-icon {
  background: #25d366;
}

.contact-grid div:nth-child(3) .social-icon {
  background: #2c6f9f;
}

.contact-grid div:nth-child(4) .social-icon {
  background: #c13584;
}

.contact-grid span,
.contact-grid strong {
  display: block;
}

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

.contact-grid strong {
  margin-top: 10px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.page {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.portal-page {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.portal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.portal-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.portal-brand img {
  width: clamp(30px, 8vw, 42px);
  height: clamp(30px, 8vw, 42px);
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(31, 42, 36, 0.12);
}

.portal-brand strong {
  font-size: 20px;
}

.portal-nav div {
  display: flex;
  gap: 12px;
}

.portal-nav a {
  color: #0f5739;
  font-weight: 800;
  text-decoration: none;
}

.portal-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: stretch;
  padding: 34px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(31, 42, 36, 0.1);
}

.portal-hero h1 {
  font-size: 44px;
  line-height: 1.05;
}

.portal-status {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 220px;
  padding: 24px;
  color: #fff;
  background: #16794f;
  border-radius: 8px;
}

.portal-status img {
  width: clamp(58px, 16vw, 76px);
  height: clamp(58px, 16vw, 76px);
  object-fit: contain;
  margin-bottom: 16px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.18);
}

.portal-status span,
.portal-status small {
  color: rgba(255, 255, 255, 0.78);
  font-weight: 800;
  text-transform: uppercase;
}

.portal-status strong {
  margin: 16px 0 8px;
  font-size: 42px;
  line-height: 1;
}

.portal-status small {
  font-size: 12px;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.portal-grid article {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.portal-grid h2 {
  margin: 0;
  font-size: 22px;
}

.portal-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 26px;
}

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

.client-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(120px, 180px) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.san-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.san-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.san-form label,
.san-selector {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.san-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.san-card {
  display: grid;
  gap: 18px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.san-card-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.danger-button {
  background: #b42318;
}

.danger-button:hover {
  background: #8f1c13;
}

.san-card span,
.san-card p {
  color: var(--muted);
}

.san-card span {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.san-card strong {
  display: block;
  font-size: 26px;
}

.san-card p {
  margin: 8px 0 0;
  font-size: 14px;
}

.toggle-form-button {
  margin-bottom: 18px;
}

.client-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select,
button,
.button-link {
  min-height: 42px;
  font: inherit;
  border-radius: 8px;
}

input,
select {
  width: 100%;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  color: #fff;
  background: #16794f;
  border: 0;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.button-link:hover {
  background: #0f5739;
}

.secondary-button {
  color: #0f5739;
  background: #e8f7ef;
  border: 1px solid #bfe5cf;
}

.secondary-button:hover {
  color: #fff;
  background: #0f5739;
  border-color: #0f5739;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.table-section {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

.summary-panel {
  position: sticky;
  top: 18px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-panel h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.summary-list {
  display: grid;
  gap: 10px;
}

.summary-list div {
  padding: 12px;
  background: #fafcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-list span,
.summary-list strong {
  display: block;
}

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

.summary-list strong {
  margin-top: 6px;
  font-size: 16px;
}

.loan-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

.loan-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.loan-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.loan-form button {
  grid-column: span 2;
}

.loan-cards {
  display: grid;
  gap: 16px;
}

.loan-card,
.empty-panel {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.loan-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.loan-card-head span,
.loan-detail,
.loan-metrics span {
  color: var(--muted);
}

.loan-card-head span,
.loan-metrics span {
  display: block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.loan-card-head strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.loan-card-head p,
.loan-detail {
  margin: 8px 0 0;
  font-size: 14px;
}

.loan-status {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  color: #0f5739;
  background: #e8f7ef;
  border: 1px solid #bfe5cf;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.loan-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.loan-metrics div {
  padding: 12px;
  background: #fafcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.loan-metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 16px;
}

.loan-table-section {
  margin-top: 18px;
}

.loan-table-toolbar {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.client-search-input {
  max-width: 320px;
  margin-right: auto;
}

.loan-table input {
  min-height: 36px;
  padding: 7px 5px;
  font-size: 11px;
}

.loan-table input[type="number"],
.loan-table td[data-label="Capital"],
.loan-table td[data-label="Reditos"],
.loan-table td[data-label="Interes"],
.loan-table td[data-label="Saldo"] {
  font-variant-numeric: tabular-nums;
}

.finance-panel {
  margin-bottom: 18px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.finance-panel h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.finance-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.finance-grid div {
  padding: 12px;
  background: #fafcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.finance-grid span,
.finance-grid strong {
  display: block;
}

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

.finance-grid strong {
  margin-top: 8px;
  color: var(--ink);
  font-size: 18px;
}

#financeBankValue {
  cursor: pointer;
}

.finance-insights {
  display: grid;
  grid-template-columns: minmax(220px, 1fr);
  gap: 12px;
}

.finance-chart {
  padding: 14px;
  background: #fafcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.finance-chart-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.finance-chart-head span,
.finance-legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.finance-chart-head strong {
  font-size: 20px;
}

.finance-bar {
  display: flex;
  overflow: hidden;
  height: 18px;
  background: #eef4f0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.finance-bank-bar,
.finance-loan-bar {
  min-width: 0;
  transition: width 220ms ease;
}

.finance-bank-bar {
  background: #16794f;
}

.finance-loan-bar {
  background: #2c6f9f;
}

.finance-legend {
  display: flex;
  gap: 14px;
  margin-top: 12px;
}

.finance-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.finance-legend i {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 50%;
}

.legend-bank {
  background: #16794f;
}

.legend-loan {
  background: #2c6f9f;
}

.loan-table th:nth-child(1),
.loan-table td:nth-child(1) {
  width: 14%;
}

.loan-table th:nth-child(2),
.loan-table td:nth-child(2),
.loan-table th:nth-child(3),
.loan-table td:nth-child(3),
.loan-table th:nth-child(6),
.loan-table td:nth-child(6) {
  width: 9%;
  white-space: nowrap;
}

.loan-table th:nth-child(4),
.loan-table td:nth-child(4) {
  width: 8%;
  text-align: center;
}

.loan-table th:nth-child(5),
.loan-table td:nth-child(5),
.loan-table th:nth-child(6),
.loan-table td:nth-child(6) {
  width: 9%;
}

.loan-table th:nth-child(7),
.loan-table td:nth-child(7),
.loan-table th:nth-child(8),
.loan-table td:nth-child(8),
.loan-table th:nth-child(10),
.loan-table td:nth-child(10) {
  width: 11%;
}

.loan-table th:nth-child(11),
.loan-table td:nth-child(11),
.loan-table th:nth-child(12),
.loan-table td:nth-child(12),
.loan-table th:nth-child(13),
.loan-table td:nth-child(13) {
  width: 7%;
}

.loan-table td strong,
.loan-table td small {
  display: block;
}

.loan-table td small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.loan-table-action {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  align-items: center;
}

.loan-table-action .danger-button {
  grid-column: 1 / -1;
}

.loan-table-action input,
.loan-table-action button {
  min-height: 36px;
}

.loan-table-action button {
  padding: 7px 8px;
  font-size: 11px;
  white-space: nowrap;
}

.loan-row-actions {
  display: grid;
  gap: 6px;
}

.row-action-button {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  font-size: 12px;
}

.loan-status-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.loan-status-pill.is-active {
  color: #0f5739;
  background: #e8f7ef;
  border: 1px solid #bfe5cf;
}

.loan-status-pill.is-paid {
  color: #2c6f9f;
  background: #eaf4fb;
  border: 1px solid #bdd9ef;
}

.loan-status-pill.is-late,
.loan-status-pill.is-missing {
  color: #8f1c13;
  background: #fff1f0;
  border: 1px solid #f3b8b3;
}

.history-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(31, 42, 36, 0.42);
}

.history-card {
  width: min(560px, 100%);
  max-height: min(680px, 90vh);
  overflow: auto;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(31, 42, 36, 0.18);
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.history-head h2 {
  margin: 0;
  font-size: 20px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-list article,
.history-list p {
  padding: 12px;
  background: #fafcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history-list article div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.history-list span,
.history-list small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.history-list strong {
  white-space: nowrap;
}

.history-list p {
  margin: 8px 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
}

.budget-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.budget-summary div,
.budget-table-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.budget-summary div {
  padding: 14px;
}

.budget-summary span,
.budget-summary strong {
  display: block;
}

.budget-summary span,
.budget-card-total span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.budget-summary strong {
  margin-top: 8px;
  font-size: 18px;
}

.budget-table-section {
  overflow: hidden;
}

.budget-table {
  table-layout: fixed;
}

.budget-table input {
  min-height: 36px;
  padding: 7px 8px;
  font-size: 13px;
}

.budget-table th:nth-child(1),
.budget-table td:nth-child(1) {
  width: 18%;
}

.budget-table th:nth-child(2),
.budget-table td:nth-child(2) {
  width: 34%;
}

.budget-table th:nth-child(3),
.budget-table td:nth-child(3),
.budget-table th:nth-child(4),
.budget-table td:nth-child(4) {
  width: 18%;
  white-space: nowrap;
}

.budget-table th:nth-child(5),
.budget-table td:nth-child(5) {
  width: 12%;
}

.budget-section-row td {
  background: var(--head);
}

.budget-section-row div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.budget-section-row strong {
  font-size: 15px;
}

.budget-section-row button,
.budget-table .row-action-button {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 12px;
}

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

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

.loan-table {
  table-layout: fixed;
}

.loan-table th {
  white-space: normal;
  line-height: 1.15;
}

.loan-table td {
  overflow-wrap: anywhere;
}

th,
td {
  height: 54px;
  padding: 9px 8px;
  text-align: left;
  border-top: 1px solid var(--line);
  overflow-wrap: normal;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: var(--head);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  background: #fff;
  font-size: 12px;
}

th:nth-child(1), td:nth-child(1) { width: 9%; }
th:nth-child(2), td:nth-child(2) { width: 8%; white-space: nowrap; }
th:nth-child(3), td:nth-child(3) { width: 8%; white-space: nowrap; }
th:nth-child(4), td:nth-child(4) { width: 11%; }
th:nth-child(5), td:nth-child(5) { width: 5%; text-align: center; }
th:nth-child(6), td:nth-child(6) { width: 9%; white-space: nowrap; }
th:nth-child(7), td:nth-child(7) { width: 14%; color: #b42318; font-weight: 800; }
th:nth-child(8), td:nth-child(8) { width: 9%; white-space: nowrap; }
th:nth-child(9), td:nth-child(9) { width: 7%; white-space: nowrap; }
th:nth-child(10), td:nth-child(10) { width: 10%; }
th:nth-child(11), td:nth-child(11) { width: 10%; }

.editable-cell {
  cursor: text;
}

.editable-cell:hover {
  outline: 2px solid #cfe4d8;
  outline-offset: -2px;
}

.editable-cell input,
.editable-cell select {
  min-height: 34px;
  width: 100%;
  padding: 6px 8px;
}

.quota-cell {
  min-width: 104px;
}

.quota-button {
  min-height: 38px;
  width: 100%;
  padding: 6px 7px;
  font-size: 12px;
  white-space: nowrap;
}

.quota-button span,
.quota-button strong {
  display: inline;
  line-height: 1;
}

.quota-button span {
  font-size: 11px;
  text-transform: uppercase;
  margin-right: 4px;
}

.quota-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

tbody tr:nth-child(even) td {
  background: #fafcfb;
}

.delivery-cell {
  min-width: 170px;
}

.delivery-button {
  min-height: 38px;
  width: 100%;
  padding: 6px 8px;
  color: #b42318;
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
  line-height: 1.25;
}

.delivery-button:hover {
  color: #8f1c13;
  background: #fff1f0;
  border-color: #f3b8b3;
}

.delivered-date,
.delivered-date .delivery-button {
  color: #0f7a45;
  background: #e8f7ef;
}

.delivered-date .delivery-button:hover {
  color: #095f34;
  background: #daf1e5;
  border-color: #a9dec1;
}

@media (max-width: 1100px) {
  .loan-table,
  .loan-table thead,
  .loan-table tbody,
  .loan-table tr,
  .loan-table th,
  .loan-table td {
    display: block;
    width: 100%;
  }

  .loan-table thead {
    display: none;
  }

  .loan-table tbody {
    display: grid;
    gap: 12px;
    padding: 12px;
  }

  .loan-table tr {
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .loan-table td {
    display: grid;
    grid-template-columns: minmax(110px, 34%) minmax(0, 1fr);
    gap: 10px;
    min-height: 42px;
    height: auto;
    padding: 10px 12px;
    border-top: 1px solid var(--line);
    white-space: normal;
    text-align: left;
  }

  .loan-table td:first-child {
    border-top: 0;
  }

  .loan-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .loan-table input {
    min-width: 0;
  }

  .loan-table-action,
  .loan-row-actions {
    grid-template-columns: 1fr;
  }

  .loan-table-action button,
  .row-action-button {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .header {
    align-items: stretch;
    flex-direction: column;
  }

  .page {
    padding: 16px;
  }

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

  .home-content {
    padding: 22px;
  }

  .home-content h1 {
    font-size: 31px;
  }

  .home-hero {
    grid-template-columns: 1fr;
  }

  .portal-page {
    padding: 16px;
  }

  .portal-nav {
    align-items: stretch;
    flex-direction: column;
  }

  .portal-brand {
    justify-content: center;
  }

  .portal-brand img {
    width: 34px;
    height: 34px;
  }

  .portal-status {
    align-items: center;
    min-height: auto;
    text-align: center;
  }

  .portal-status img {
    width: 62px;
    height: 62px;
    margin-bottom: 12px;
  }

  .portal-nav div,
  .portal-hero,
  .portal-grid {
    grid-template-columns: 1fr;
  }

  .portal-nav div {
    display: grid;
  }

  .portal-hero {
    padding: 22px;
  }

  .portal-hero h1 {
    font-size: 32px;
  }

  .contact-grid {
    grid-template-columns: 1fr 1fr;
  }

  .home-stats {
    grid-template-columns: 1fr 1fr;
  }

  .san-panel,
  .san-form {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .loan-layout,
  .loan-form {
    grid-template-columns: 1fr;
  }

  .loan-table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .client-search-input {
    max-width: none;
    margin-right: 0;
  }

  .loan-form button {
    grid-column: auto;
  }

  .loan-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .finance-grid {
    grid-template-columns: 1fr;
  }

  .budget-summary {
    grid-template-columns: 1fr;
  }

  .budget-table,
  .budget-table thead,
  .budget-table tbody,
  .budget-table tr,
  .budget-table th,
  .budget-table td {
    display: block;
    width: 100%;
  }

  .budget-table thead {
    display: none;
  }

  .budget-table tbody {
    display: grid;
    gap: 12px;
    padding: 12px;
  }

  .budget-table tr {
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .budget-table td {
    display: grid;
    grid-template-columns: minmax(110px, 34%) minmax(0, 1fr);
    gap: 10px;
    min-height: 42px;
    height: auto;
    padding: 10px 12px;
    border-top: 1px solid var(--line);
    white-space: normal;
    text-align: left;
  }

  .budget-table td:first-child {
    border-top: 0;
  }

  .budget-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .budget-section-row td {
    display: block;
  }

  .budget-section-row td::before {
    content: "";
  }

  .budget-section-row div {
    align-items: stretch;
    flex-direction: column;
  }

  .budget-table input {
    min-width: 0;
  }

  .finance-insights {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    position: static;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
    padding: 12px;
  }

  tr {
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  td {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    min-height: 42px;
    height: auto;
    padding: 10px 12px;
    border-top: 1px solid var(--line);
    font-size: 13px;
  }

  td:first-child {
    border-top: 0;
  }

  td::before {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  td:nth-child(1)::before { content: "Nombres"; }
  td:nth-child(2)::before { content: "SAN"; }
  td:nth-child(3)::before { content: "Aporte"; }
  td:nth-child(4)::before { content: "Cuota"; }
  td:nth-child(5)::before { content: "Turno"; }
  td:nth-child(6)::before { content: "Acumulado"; }
  td:nth-child(7)::before { content: "Entrega"; }
  td:nth-child(8)::before { content: "Pendiente"; }
  td:nth-child(9)::before { content: "Pagos"; }
  td:nth-child(10)::before { content: "Estado"; }
  td:nth-child(11)::before { content: "Fecha de pago"; }

  .loan-table td::before {
    content: attr(data-label);
  }

  .loan-table td:nth-child(1),
  .loan-table td:nth-child(2),
  .loan-table td:nth-child(3),
  .loan-table td:nth-child(4),
  .loan-table td:nth-child(5),
  .loan-table td:nth-child(6),
  .loan-table td:nth-child(7),
  .loan-table td:nth-child(8),
  .loan-table td:nth-child(9),
  .loan-table td:nth-child(10),
  .loan-table td:nth-child(11),
  .loan-table td:nth-child(12),
  .loan-table td:nth-child(13) {
    width: 100%;
    white-space: normal;
    text-align: left;
  }

  .loan-table {
    min-width: 0;
  }

  .loan-table td {
    grid-template-columns: minmax(96px, 34%) minmax(0, 1fr);
    gap: 10px;
  }

  .loan-table input {
    min-width: 0;
  }

  .loan-table-action,
  .loan-row-actions {
    grid-template-columns: 1fr;
  }

  .loan-table-action button,
  .row-action-button {
    width: 100%;
  }

  .quota-button,
  .delivery-button {
    font-size: 12px;
  }
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  min-width: 240px;
  max-width: 380px;
  padding: 12px 16px;
  background: #1f2a24;
  color: #fff;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(31, 42, 36, 0.22);
  animation: toast-in 0.22s ease;
  pointer-events: auto;
}

.toast.is-error {
  background: #b42318;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
  .page {
    padding: 10px;
  }

  .header,
  .client-form,
  .summary-panel {
    padding: 14px;
  }

  h1 {
    font-size: 21px;
  }

  .helper-text {
    font-size: 13px;
  }

  .summary-list {
    grid-template-columns: 1fr;
  }

  .contact-grid {
    grid-template-columns: 1fr;
  }

  .home-stats {
    grid-template-columns: 1fr;
  }

  .loan-card-head {
    flex-direction: column;
  }

  .loan-metrics,
  .san-card-actions {
    grid-template-columns: 1fr;
  }
}
