:root {
  --ink: #173f35;
  --muted: #6a7d76;
  --green: #1f6a55;
  --green-soft: #e8f3ee;
  --paper: #ffffff;
  --canvas: #f3f6f2;
  --line: #dfe7e2;
  --gold: #b78a2d;
  --danger: #a33a2c;
  --shadow: 0 14px 42px rgba(23, 63, 53, .08);
}

* { box-sizing: border-box; }
html { font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; color: var(--ink); background: var(--canvas); }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

.site-header { position: sticky; top: 0; z-index: 20; display: flex; min-height: 70px; padding: 0 max(24px, calc((100vw - 1160px) / 2)); align-items: center; justify-content: space-between; background: rgba(244,247,243,.92); border-bottom: 1px solid rgba(210,222,215,.85); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; letter-spacing: .02em; }
.brand-mark { display: grid; width: 36px; height: 36px; place-items: center; color: white; background: var(--green); border-radius: 11px 11px 15px 15px; font-family: serif; }
.shell { width: min(1160px, calc(100% - 32px)); margin: 0 auto; padding: 44px 0 72px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-family: Georgia, "Songti SC", serif; font-size: clamp(34px, 5vw, 54px); line-height: 1.08; }
h2 { margin-bottom: 22px; font-size: 22px; }
.eyebrow { margin-bottom: 10px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .18em; }
.lead { max-width: 680px; color: var(--muted); line-height: 1.65; }
.small-text { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.primary-button, .secondary-button, .danger-button, .quiet-button { min-height: 46px; padding: 0 20px; border: 0; border-radius: 13px; cursor: pointer; font-weight: 750; transition: transform .15s, filter .15s; }
.primary-button { color: white; background: var(--green); }
.secondary-button { color: var(--green); background: var(--green-soft); }
.danger-button { color: white; background: var(--danger); }
.quiet-button { min-height: 36px; color: var(--muted); background: transparent; }
.primary-button:hover, .secondary-button:hover { filter: brightness(.96); transform: translateY(-1px); }

.auth-card { width: min(500px, 100%); margin: 5vh auto 0; padding: 40px; }
.stack-form { display: grid; gap: 20px; }
.stack-form.compact { gap: 15px; }
label { display: grid; gap: 8px; color: #52645e; font-size: 14px; font-weight: 650; }
input, select, textarea { width: 100%; padding: 0 15px; color: var(--ink); background: #f8faf8; border: 1px solid #dce5e0; border-radius: 13px; outline: none; }
input, select { height: 50px; }
textarea { padding-top: 13px; line-height: 1.6; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #68a38f; box-shadow: 0 0 0 3px rgba(31,106,85,.1); }
.flash { margin-bottom: 22px; padding: 14px 18px; border-radius: 13px; }
.flash.error { color: #84392f; background: #fff0ed; border: 1px solid #f2c5bd; }

.dashboard-head { display: flex; margin-bottom: 34px; align-items: end; justify-content: space-between; gap: 24px; }
.dashboard-head h1 { margin-bottom: 8px; }
.dashboard-head .lead { margin-bottom: 0; }
.invite-card { margin-bottom: 24px; padding: 28px; border-color: #c9ddd4; background: linear-gradient(135deg, #fff, #eef7f2); }
.invite-card h2 { margin-bottom: 14px; }
.copy-row { display: flex; gap: 10px; }
.copy-row input { flex: 1; background: white; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 34px; }
.stat { display: flex; padding: 24px; align-items: end; justify-content: space-between; }
.stat span { color: var(--muted); }
.stat strong { font-family: Georgia, serif; font-size: 38px; }
.section-heading { display: flex; margin-bottom: 16px; align-items: center; justify-content: space-between; }
.section-heading h2 { margin: 0; }
.live-dot { color: var(--green); font-size: 12px; }
.live-dot::before { display: inline-block; width: 7px; height: 7px; margin-right: 7px; content: ""; background: #36a477; border-radius: 50%; }
.loan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.loan-card { display: block; padding: 25px; transition: border-color .15s, transform .15s; }
.loan-card:hover { border-color: #a8c9bb; transform: translateY(-2px); }
.loan-card-top, .loan-meta { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.loan-card-top strong { display: block; font-size: 20px; }
.loan-card-top span:not(.badge) { display: block; margin-top: 5px; color: var(--muted); font-size: 13px; }
.badge { padding: 6px 11px; color: #80611e; background: #fff4d5; border-radius: 99px; font-size: 12px; white-space: nowrap; }
.amount { margin: 26px 0; font-family: Georgia, serif; font-size: 38px; font-weight: 800; }
.loan-meta { padding-top: 16px; color: var(--muted); border-top: 1px solid #edf1ee; font-size: 12px; }
.empty { padding: 58px 30px; text-align: center; }
.empty-mark, .message-mark { display: grid; width: 62px; height: 62px; margin: 0 auto 18px; place-items: center; color: var(--green); background: var(--green-soft); border-radius: 50%; font-family: serif; font-size: 26px; }
.empty p, .message-card p { color: var(--muted); }

.form-intro { margin-bottom: 30px; }
.application-form { display: grid; gap: 20px; }
.form-section { padding: 30px; }
.form-section h2 { display: flex; align-items: center; gap: 10px; }
.form-section h2 span { display: grid; width: 31px; height: 31px; place-items: center; color: var(--green); background: var(--green-soft); border-radius: 9px; font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 18px; }
.form-grid .wide { grid-column: 1 / -1; }
.optional-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.optional-head h2 { margin-bottom: 0; }
.optional-head b { padding: 6px 11px; color: var(--green); background: var(--green-soft); border-radius: 99px; font-size: 12px; white-space: nowrap; }
.optional-section h3 { margin: 30px 0 16px; padding-bottom: 10px; border-bottom: 1px solid #edf1ee; font-size: 16px; }
.section-note { margin: 14px 0 4px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.identity-upload { padding: 18px; background: #f7f9f7; border: 1px solid var(--line); border-radius: 16px; }
.identity-upload h3 { margin: 0 0 6px; }
.identity-upload p { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.identity-upload input[type="file"] { height: auto; padding: 12px; background: white; }
.estimate { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 28px; padding: 20px; background: #edf6f1; border-radius: 16px; }
.estimate div { display: grid; gap: 8px; padding: 0 20px; border-right: 1px solid #d2e3da; }
.estimate div:last-child { border: 0; }
.estimate span { color: var(--muted); font-size: 13px; }
.estimate strong { font-size: 20px; }
.estimate-total strong { color: var(--green); }
.consent { display: flex; padding: 22px; align-items: flex-start; gap: 12px; line-height: 1.6; }
.consent input { width: 20px; height: 20px; margin-top: 1px; flex: 0 0 auto; accent-color: var(--green); }
.submit-button { width: 100%; height: 56px; font-size: 17px; }
.message-card { max-width: 560px; margin: 8vh auto; padding: 55px 35px; text-align: center; }
.message-mark.success { color: white; background: var(--green); }
.inline-button { display: inline-grid; margin-top: 14px; place-items: center; }
.auth-switch { display: flex; margin-top: 24px; padding-top: 20px; justify-content: space-between; gap: 14px; color: var(--muted); border-top: 1px solid var(--line); font-size: 13px; }
.auth-switch a { color: var(--green); font-weight: 750; }

.back-link { display: inline-block; margin-bottom: 20px; color: var(--green); font-weight: 700; }
.loan-hero { display: grid; grid-template-columns: 1fr auto; margin-bottom: 22px; padding: 34px; color: white; background: linear-gradient(145deg, #173f35, #246d59); border-radius: 24px; box-shadow: 0 18px 45px rgba(23,63,53,.18); }
.loan-hero p { margin-bottom: 4px; color: #b9d9cf; }
.loan-hero h1 { margin: 0; font-family: Georgia, serif; }
.hero-badge { align-self: start; padding: 7px 12px; color: var(--ink); background: #d8efe7; border-radius: 99px; font-size: 12px; }
.hero-summary { display: flex; grid-column: 1 / -1; margin-top: 26px; padding-top: 18px; justify-content: space-between; gap: 12px; color: #d7ebe4; border-top: 1px solid rgba(255,255,255,.15); font-size: 13px; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .7fr); gap: 20px; align-items: start; }
.detail-layout aside { display: grid; gap: 20px; }
.detail-layout .card { padding: 28px; }
.details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.details div { padding: 15px 0; border-bottom: 1px solid #edf1ee; }
.details div:nth-child(even) { padding-left: 18px; }
.details dt { margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.details dd { margin: 0; overflow-wrap: anywhere; font-weight: 700; }
.subheading { margin: 28px 0 6px; }
.self-reported { margin-left: 7px; color: var(--gold); font-size: 11px; font-weight: 650; }
.protected-note { margin: 14px 0; padding: 15px; color: var(--muted); background: #f7f9f7; border-radius: 12px; font-size: 13px; }
.danger-label { color: var(--danger); font-size: 12px; }
.reveal-form { display: grid; grid-template-columns: 1fr auto; margin-top: 24px; align-items: end; gap: 10px; }
.repayment { display: flex; padding: 15px 0; align-items: center; justify-content: space-between; border-bottom: 1px solid #edf1ee; }
.repayment:last-child { border-bottom: 0; }
.repayment strong, .repayment span { display: block; }
.repayment span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.repayment b { color: var(--green); }
.workflow-card { margin-bottom: 22px; padding: 28px; }
.workflow { display: grid; grid-template-columns: repeat(5, 1fr); margin: 0; padding: 0; list-style: none; }
.workflow li { position: relative; display: grid; justify-items: center; gap: 8px; color: #8b9994; text-align: center; font-size: 12px; }
.workflow li::before { position: absolute; top: 16px; right: 50%; width: 100%; height: 3px; content: ""; background: #dfe7e2; z-index: 0; }
.workflow li:first-child::before { display: none; }
.workflow li span { position: relative; z-index: 1; display: grid; width: 34px; height: 34px; place-items: center; color: #72817b; background: #eef2ef; border-radius: 50%; }
.workflow li.done span, .workflow li.current span { color: white; background: var(--green); }
.workflow li.done::before, .workflow li.current::before { background: var(--green); }
.workflow li.current b, .workflow li.done b { color: var(--ink); }
.workflow li small { color: var(--green); }
.workflow-actions { display: flex; margin-top: 22px; align-items: center; flex-wrap: wrap; gap: 10px; }
.workflow-actions .small-text { max-width: 520px; margin: 0; }
.workflow-message { margin: 0; font-weight: 700; }
.success-text { color: var(--green); }
.workflow-rejected { padding: 16px; color: var(--danger); background: #fff0ed; border-radius: 13px; }
.assessment-form { margin-top: 26px; padding-top: 24px; border-top: 1px solid var(--line); }
.assessment-form .secondary-button { justify-self: start; }
.assessment-result { margin-top: 24px; padding: 18px; background: #f7f9f7; border-radius: 13px; }
.assessment-result p { margin: 8px 0 0; white-space: pre-wrap; line-height: 1.7; }
.qr-card { text-align: center; }
.qr-card img { display: block; width: min(240px, 100%); margin: 0 auto 14px; padding: 8px; background: white; border: 1px solid var(--line); border-radius: 16px; }
.qr-card p { line-height: 1.6; }
.qr-card small { color: var(--muted); line-height: 1.5; }
.identity-images { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.identity-images figure { margin: 0; }
.identity-images img { display: block; width: 100%; aspect-ratio: 1.58 / 1; object-fit: contain; background: #eef2ef; border: 1px solid var(--line); border-radius: 14px; }
.identity-images figcaption { margin-top: 7px; color: var(--muted); font-size: 12px; text-align: center; }
.confirmation-head { position: relative; margin-bottom: 24px; }
.confirmation-head .badge { display: inline-block; }
.confirmation-card, .receipt-form, .waiting-card { max-width: 900px; margin: 0 auto 22px; padding: 30px; }
.receipt-form .consent { margin-bottom: 16px; background: var(--green-soft); border-radius: 14px; }
.waiting-card { text-align: center; }
.verify-card { margin-top: 3vh; text-align: left; }
.verify-card .message-mark, .verify-card h1, .verify-card > p { text-align: center; }
.borrower-head { margin-bottom: 24px; }
.portal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.portal-card { padding: 28px; }
.portal-notice { margin: 18px 0 0; padding: 15px; color: var(--green); background: var(--green-soft); border-radius: 13px; font-weight: 700; }
.rejected-text { color: var(--danger); background: #fff0ed; }

@media (max-width: 760px) {
  .site-header { padding: 0 16px; }
  .shell { width: min(100% - 22px, 600px); padding: 28px 0 50px; }
  .dashboard-head { display: grid; align-items: stretch; }
  .dashboard-head .primary-button { width: 100%; }
  .loan-grid, .form-grid, .detail-layout, .details, .portal-grid { grid-template-columns: 1fr; }
  .details div:nth-child(even) { padding-left: 0; }
  .copy-row { display: grid; }
  .estimate { grid-template-columns: 1fr; }
  .estimate div { padding: 12px 4px; border-right: 0; border-bottom: 1px solid #d2e3da; }
  .estimate div:last-child { border-bottom: 0; }
  .form-section, .auth-card, .detail-layout .card { padding: 22px; }
  .loan-hero { padding: 25px; }
  .hero-summary { display: grid; }
  .reveal-form { grid-template-columns: 1fr; }
  .identity-images { grid-template-columns: 1fr; }
  .workflow { grid-template-columns: 1fr; gap: 10px; }
  .workflow li { grid-template-columns: 34px 1fr; justify-items: start; align-items: center; text-align: left; }
  .workflow li::before { top: -10px; left: 16px; width: 3px; height: 20px; }
}
