:root {
  --bg: #05010f;
  --bg-2: #140329;
  --panel: rgba(19, 9, 39, 0.84);
  --panel-soft: rgba(34, 14, 64, 0.78);
  --panel-line: rgba(199, 113, 255, 0.22);
  --text: #f7f2ff;
  --muted: #c8b8ec;
  --accent: #a900ff;
  --accent-2: #6a00ff;
  --gold: #f7b500;
  --gold-soft: rgba(247, 181, 0, 0.18);
  --success: #20d08a;
  --success-soft: rgba(32, 208, 138, 0.18);
  --danger: #ff6d6d;
  --danger-soft: rgba(255, 109, 109, 0.18);
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at top right, rgba(169, 0, 255, 0.34), transparent 26%),
    radial-gradient(circle at 10% 30%, rgba(247, 181, 0, 0.16), transparent 18%),
    radial-gradient(circle at bottom left, rgba(106, 0, 255, 0.42), transparent 30%),
    linear-gradient(160deg, #040109 0%, #12031f 32%, #090111 70%, #040109 100%);
}

body::before,
body::after {
  content: '';
  position: fixed;
  pointer-events: none;
  z-index: 0;
}

body::before {
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  opacity: 0.22;
}

body::after {
  width: 220px;
  height: 220px;
  right: 24px;
  bottom: 24px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, #ffe38f 0, #f7b500 54%, #c78600 72%, rgba(199, 134, 0, 0.1) 73%);
  filter: blur(0.3px);
  box-shadow:
    -1100px -420px 0 -120px rgba(247, 181, 0, 0.92),
    -540px 120px 0 -140px rgba(247, 181, 0, 0.9);
  opacity: 0.82;
}

a,
button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.auth-shell {
  display: grid;
  place-items: center;
  padding: 36px 22px;
}

.auth-content {
  width: min(100%, 620px);
  position: relative;
  z-index: 1;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  padding: 28px 22px;
  display: grid;
  align-content: space-between;
  gap: 24px;
  background:
    linear-gradient(180deg, rgba(13, 5, 31, 0.96), rgba(7, 1, 17, 0.96)),
    linear-gradient(150deg, rgba(169, 0, 255, 0.2), transparent);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 1;
}

.brand-kicker,
.hero-badge,
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff8d1;
  background: linear-gradient(135deg, rgba(247, 181, 0, 0.22), rgba(169, 0, 255, 0.16));
  border: 1px solid rgba(247, 181, 0, 0.22);
}

.brand-block {
  display: grid;
  gap: 12px;
}

.brand-logo,
.auth-logo {
  display: block;
  width: 100%;
  max-width: 220px;
  border-radius: 22px;
  filter: drop-shadow(0 14px 28px rgba(169, 0, 255, 0.25));
}

.auth-logo {
  max-width: 260px;
  margin-bottom: 18px;
}

.brand {
  margin: 10px 0 0;
  font-family: 'Fraunces', serif;
  font-size: 2.8rem;
  line-height: 0.95;
}

.sidebar-nav {
  display: grid;
  gap: 10px;
}

.sidebar-nav a {
  text-decoration: none;
  padding: 14px 16px;
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  transition: 180ms ease;
}

.sidebar-nav a.active,
.sidebar-nav a:hover {
  color: var(--text);
  background: linear-gradient(135deg, rgba(169, 0, 255, 0.18), rgba(247, 181, 0, 0.14));
  border-color: rgba(247, 181, 0, 0.2);
  transform: translateY(-1px);
}

.content {
  position: relative;
  z-index: 1;
  padding: 28px;
  min-width: 0;
}

.auth-card,
.panel,
.stat-card,
.receipt-card {
  position: relative;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(35, 10, 72, 0.74), rgba(10, 4, 21, 0.9)),
    linear-gradient(135deg, rgba(169, 0, 255, 0.16), rgba(247, 181, 0, 0.06));
  border: 1px solid var(--panel-line);
  border-radius: 34px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.auth-card::before,
.panel::before,
.stat-card::before,
.receipt-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.08), transparent 22%),
    linear-gradient(140deg, transparent 20%, rgba(255, 255, 255, 0.04) 50%, transparent 80%);
  pointer-events: none;
}

.auth-card {
  padding: 34px;
}

.auth-card h2,
.page-head h2,
.receipt-card h2 {
  margin: 14px 0 10px;
  font-family: 'Fraunces', serif;
  font-size: clamp(2.3rem, 4vw, 4.1rem);
  line-height: 0.95;
  max-width: 12ch;
}

.auth-card p,
.page-head p,
.empty-state,
.muted,
.panel-head span,
.receipt-note p,
td span {
  color: var(--muted);
}

.auth-banner {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-banner span {
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.flash {
  margin-bottom: 18px;
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.flash-success {
  background: var(--success-soft);
  color: #dffced;
}

.flash-error {
  background: var(--danger-soft);
  color: #ffe7e7;
}

.page-head,
.panel-head,
.receipt-top,
.page-head-actions,
.search-loan-head,
.search-loan-actions {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.page-head {
  margin-bottom: 24px;
}

.page-head-actions {
  align-items: center;
  flex-wrap: wrap;
}

.stats-grid,
.panel-grid,
.receipt-grid,
.stack-form,
.detail-list,
.search-result,
.list-stack {
  display: grid;
  gap: 18px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 24px;
}

.panel-grid {
  grid-template-columns: 1.05fr 1fr;
  margin-bottom: 24px;
}

.stat-card,
.panel,
.receipt-card {
  padding: 24px;
}

.stat-card {
  min-height: 168px;
}

.stat-card::after {
  content: '';
  position: absolute;
  width: 120px;
  height: 120px;
  right: -16px;
  top: -16px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18), transparent 72%);
}

.stat-card span {
  display: block;
  margin-bottom: 10px;
  color: #e9defd;
}

.stat-card strong {
  font-size: clamp(1.7rem, 3vw, 2.8rem);
  line-height: 1;
}

.stat-card.accent {
  background:
    linear-gradient(160deg, rgba(169, 0, 255, 0.86), rgba(68, 0, 148, 0.95)),
    linear-gradient(135deg, rgba(247, 181, 0, 0.14), transparent);
}

.stat-card.warning {
  background:
    linear-gradient(160deg, rgba(255, 119, 0, 0.88), rgba(131, 34, 0, 0.95)),
    linear-gradient(135deg, rgba(255, 232, 176, 0.12), transparent);
}

label {
  display: grid;
  gap: 8px;
  color: #f2ecff;
  font-size: 0.92rem;
}

input,
select,
textarea {
  width: 100%;
  min-height: 50px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
}

select {
  color: #fff6cf;
  background:
    linear-gradient(180deg, rgba(34, 14, 64, 0.96), rgba(13, 5, 31, 0.96));
}

select option {
  color: #fff6cf;
  background: #160626;
}

input::placeholder,
textarea::placeholder {
  color: #bdaeda;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(247, 181, 0, 0.56);
  box-shadow: 0 0 0 4px rgba(247, 181, 0, 0.12);
}

textarea {
  resize: vertical;
}

.form-grid,
.client-search-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border: none;
  border-radius: 18px;
  color: #12011f;
  background: linear-gradient(135deg, #f7b500, #ffd875 46%, #ffefb1);
  box-shadow: 0 14px 30px rgba(247, 181, 0, 0.24);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

.button:hover {
  transform: translateY(-2px);
  filter: brightness(1.03);
}

.button-ghost {
  color: var(--text);
  background: linear-gradient(135deg, rgba(169, 0, 255, 0.22), rgba(255, 255, 255, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.button-small {
  padding: 10px 14px;
  border-radius: 14px;
}

.full-width {
  width: 100%;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.search-field {
  margin: 0;
}

.stats-grid-search {
  margin-bottom: 0;
}

.list-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-radius: 24px;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.list-card-column {
  display: grid;
  gap: 18px;
}

.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

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

th,
td {
  padding: 14px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

th {
  color: #ffecb0;
  font-weight: 700;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  border: 1px solid transparent;
}

.status-em_dia {
  color: #dffced;
  background: var(--success-soft);
  border-color: rgba(32, 208, 138, 0.22);
}

.status-vencido {
  color: #ffe7e7;
  background: var(--danger-soft);
  border-color: rgba(255, 109, 109, 0.22);
}

.status-quitado {
  color: #f8e6ff;
  background: rgba(169, 0, 255, 0.2);
  border-color: rgba(169, 0, 255, 0.24);
}

.inline-link {
  color: #ffd875;
  text-decoration: none;
  font-weight: 700;
}

.detail-list div,
.receipt-grid div,
.receipt-note {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.detail-list div {
  display: grid;
  gap: 6px;
}

.payment-history {
  display: grid;
  gap: 4px;
}

.settlement-loan {
  margin-bottom: 24px;
}

.payment-card {
  min-width: 260px;
}

.payment-card-wide {
  min-width: 320px;
}

.payment-card summary {
  list-style: none;
}

.payment-card summary::-webkit-details-marker {
  display: none;
}

.compact-form {
  margin-top: 12px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(4, 1, 9, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.payment-card[open],
.payment-card-wide[open] {
  width: 100%;
}

.receipt-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 22px;
}

.receipt-note {
  margin-top: 22px;
}

.receipt-declaration {
  margin-top: 22px;
  padding: 20px 22px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.receipt-declaration p {
  margin: 0;
  line-height: 1.7;
  color: var(--text);
}

.receipt-signatures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.signature-box {
  min-height: 132px;
  display: grid;
  align-content: end;
  gap: 10px;
  padding: 20px 16px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.signature-box::before {
  content: '';
  display: block;
  height: 58px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.26);
}

.signature-box span {
  color: var(--muted);
  font-size: 0.9rem;
}

.signature-box strong {
  font-size: 1rem;
}

@media (max-width: 1180px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
    padding: 18px;
    gap: 18px;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .content {
    padding: 18px;
  }

  .brand-block {
    gap: 8px;
  }

  .brand-logo {
    max-width: 170px;
  }

  .sidebar-nav {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: none;
  }

  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }

  .sidebar-nav a {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .full-width {
    width: auto;
  }
}

@media (max-width: 760px) {
  body::after {
    width: 140px;
    height: 140px;
  }

  .stats-grid,
  .receipt-grid,
  .form-grid,
  .client-search-summary,
  .search-form,
  .receipt-signatures {
    grid-template-columns: 1fr;
  }

  .page-head,
  .panel-head,
  .receipt-top,
  .search-loan-head,
  .search-loan-actions,
  .page-head-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-card,
  .panel,
  .stat-card,
  .receipt-card {
    border-radius: 26px;
    padding: 18px;
  }

  .payment-card-wide,
  .payment-card {
    min-width: 0;
  }

  .auth-shell {
    padding: 18px 14px;
  }

  .auth-card {
    padding: 24px 18px;
  }

  .auth-card h2,
  .page-head h2,
  .receipt-card h2 {
    font-size: clamp(1.9rem, 9vw, 2.7rem);
    max-width: none;
  }

  .content {
    padding: 14px;
  }

  .panel-head h3,
  .page-head h2 + p {
    max-width: 100%;
  }

  .table-wrap {
    border-radius: 18px;
    margin: 0 -4px;
  }

  table {
    min-width: 0;
  }

  th,
  td {
    padding: 12px 10px;
    font-size: 0.92rem;
  }

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

  thead {
    display: none;
  }

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

  tr {
    padding: 12px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }

  td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 10px 0;
    text-align: left;
  }

  td:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 6px;
    color: #ffecb0;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .button,
  .button-ghost,
  .button-small {
    width: 100%;
  }

  .search-form .button,
  .page-head-actions .button,
  .page-head-actions .button-ghost,
  .search-loan-actions .inline-link,
  .search-loan-actions .status-chip {
    width: 100%;
  }

  .list-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .receipt-declaration,
  .receipt-note,
  .signature-box {
    padding: 16px;
  }

  .search-result .stats-grid-search,
  .panel .stats-grid-search,
  .stats-grid {
    gap: 12px;
  }

  .table-wrap {
    overflow: visible;
    background: transparent;
    border: none;
  }

  .signature-box {
    min-height: 116px;
  }

  input,
  select,
  textarea {
    padding: 13px 14px;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 15px;
  }

  .sidebar {
    padding: 14px;
  }

  .content {
    padding: 12px;
  }

  .stat-card {
    min-height: 138px;
  }

  .stat-card strong {
    font-size: 1.9rem;
  }

  .page-head,
  .panel-head,
  .receipt-top {
    gap: 10px;
  }

  .eyebrow,
  .hero-badge,
  .brand-kicker {
    padding: 7px 12px;
    font-size: 0.68rem;
  }

  .brand {
    font-size: 2.1rem;
  }

  .brand-logo,
  .auth-logo {
    max-width: 150px;
  }

  .compact-form {
    padding: 14px;
  }

  .detail-list div,
  .receipt-grid div {
    padding: 14px;
  }

  .table-wrap {
    margin: 0 -2px;
  }

  .search-form {
    gap: 12px;
  }

  .page-head p,
  .empty-state {
    line-height: 1.6;
  }
}

@media print {
  @page {
    margin: 12mm;
    size: A4 portrait;
  }

  body {
    background: #fff;
    color: #111;
  }

  body::before,
  body::after,
  .sidebar,
  .flash,
  .button,
  .button-ghost {
    display: none !important;
  }

  .content,
  .auth-content {
    padding: 0;
  }

  .app-shell {
    display: block;
  }

  .content {
    display: block;
    width: 100%;
    max-width: none;
  }

  .printable-receipt,
  .printable-receipt *,
  .receipt-note,
  .receipt-grid div,
  .receipt-declaration,
  .signature-box {
    color: #111 !important;
  }

  .printable-receipt {
    margin: 0;
    padding: 0;
    background: #fff !important;
    border: none !important;
    border-radius: 0;
    box-shadow: none !important;
    overflow: visible;
  }

  .printable-receipt::before {
    display: none !important;
  }

  .receipt-card,
  .receipt-note,
  .receipt-grid div,
  .receipt-declaration,
  .signature-box {
    color: #111;
    background: #fff;
    border: 1px solid #ddd;
    box-shadow: none;
  }

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

  .receipt-top {
    margin-bottom: 18px;
  }

  .receipt-note,
  .receipt-declaration,
  .receipt-signatures {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
