*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  min-height: 100vh;
}

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

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

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

.page-header h1 { font-size: 1.6rem; font-weight: 700; color: #0f172a; }
.page-header h2 { font-size: 1.3rem; font-weight: 600; }

.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #2563eb;
  font-size: 0.9rem;
  margin-bottom: 18px;
  cursor: pointer;
}
.back-link:hover { text-decoration: underline; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary   { background: #2563eb; color: #fff; }
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-danger    { background: #dc2626; color: #fff; }
.btn-sm        { padding: 5px 12px; font-size: 0.82rem; }

.card {
  background: #fff;
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-block {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  margin-bottom: 14px;
}

.client-name { font-size: 1.05rem; font-weight: 600; margin-bottom: 3px; }
.client-desc { font-size: 0.85rem; color: #64748b; }

.amount-due     { font-size: 1rem; font-weight: 600; color: #dc2626; }
.amount-paid-ok { font-size: 1rem; font-weight: 600; color: #16a34a; }
.amount-neutral { font-size: 1rem; font-weight: 600; color: #1e293b; }

.month-card {
  background: #fff;
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  margin-bottom: 14px;
}

.month-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.month-dates { font-weight: 600; font-size: 0.95rem; }
.month-meta  { font-size: 0.85rem; color: #64748b; margin-top: 3px; }

.month-amounts { display: flex; gap: 20px; flex-wrap: wrap; }

.amount-item { text-align: right; }
.amount-label { font-size: 0.75rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.03em; }
.amount-value { font-size: 0.95rem; font-weight: 600; margin-top: 2px; }

.installments-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 12px 0 8px;
}

.installment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 0.88rem;
  gap: 8px;
  flex-wrap: wrap;
}
.installment-row a { color: #2563eb; font-size: 0.82rem; }
.installment-row a:hover { text-decoration: underline; }

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  font-size: 0.93rem;
  color: #1e293b;
  background: #fff;
  font-family: inherit;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-hint { font-size: 0.8rem; color: #64748b; margin-top: 5px; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 28px 24px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.modal-box h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 20px; }

.hidden { display: none !important; }

.pending-month-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 10px;
  background: #fff;
  flex-wrap: wrap;
}

.pending-month-row.selected { border-color: #2563eb; background: #eff6ff; }

.pending-month-row input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; flex-shrink: 0; }

.pending-month-info { flex: 1; min-width: 140px; }
.pending-month-dates { font-size: 0.9rem; font-weight: 600; }
.pending-month-due   { font-size: 0.82rem; color: #dc2626; margin-top: 2px; }

.pay-status { font-size: 0.78rem; font-weight: 600; margin-top: 4px; }
.pay-status-full    { color: #16a34a; }
.pay-status-partial { color: #d97706; }

.pending-month-input { width: 120px; flex-shrink: 0; }

.pending-month-input input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  text-align: right;
}
.pending-month-input input:focus { outline: none; border-color: #2563eb; }
.pending-month-input input:disabled { background: #f1f5f9; color: #94a3b8; }

.summary-bar {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 16px;
  margin: 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.summary-bar .label { font-size: 0.88rem; color: #64748b; }
.summary-bar .value { font-size: 1rem; font-weight: 700; }
.summary-bar .value.match    { color: #16a34a; }
.summary-bar .value.no-match { color: #dc2626; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.info-item .info-label { font-size: 0.78rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.info-item .info-value { font-size: 1rem; font-weight: 600; }

.empty-state { text-align: center; color: #94a3b8; padding: 48px 16px; font-size: 0.95rem; }

.section-title { font-size: 1rem; font-weight: 700; color: #0f172a; margin: 24px 0 14px; }

.divider { border: none; border-top: 1px solid #e2e8f0; margin: 20px 0; }

.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.tag-due  { background: #fee2e2; color: #b91c1c; }
.tag-paid { background: #dcfce7; color: #15803d; }

.alloc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 7px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  flex-wrap: wrap;
  gap: 8px;
}
.alloc-dates  { font-weight: 500; }
.alloc-amount { font-weight: 700; color: #1e293b; }

.loading { text-align: center; color: #64748b; padding: 48px 0; font-size: 0.95rem; }
.error-msg { color: #dc2626; background: #fee2e2; border-radius: 8px; padding: 12px 16px; font-size: 0.9rem; }

@media (max-width: 520px) {
  .card { flex-direction: column; align-items: flex-start; }
  .month-header { flex-direction: column; }
  .month-amounts { justify-content: flex-start; }
  .amount-item { text-align: left; }
}
