:root {
  --paper: #f3efe6;
  --paper-2: #ebe5d8;
  --card: #fbf9f4;
  --ink: #17140f;
  --ink-2: #3b352c;
  --muted: #736b5e;
  --line: #d8d0bf;
  --accent: #8c1c13;
  --accent-ink: #fff6f2;
  --accent-soft: #f3dcd6;
  --ok: #2f5d3a;
  --ok-soft: #dde8d9;
  --warn: #8c1c13;
  --radius: 14px;
  --display: "Fraunces", Georgia, serif;
  --body: "Public Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-feature-settings: "tnum"; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px; background: var(--ink); color: var(--paper);
  display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -0.5px;
}
.brand-name { font-family: var(--display); font-weight: 600; font-size: 19px; letter-spacing: -0.2px; line-height: 1.1; }
.brand-name small { display: block; font-family: var(--body); font-weight: 500; font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--muted); margin-top: 2px; }

/* ---------- form bits ---------- */
label.field { display: block; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field > em { display: block; font-style: normal; font-size: 12px; color: var(--muted); margin-top: 5px; }
input, select, textarea {
  width: 100%; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(23,20,15,.08); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; border-radius: 10px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  font-weight: 600; cursor: pointer; transition: transform .05s, opacity .15s, background .15s;
}
.btn:hover { background: #000; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.accent:hover { background: #741710; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--paper-2); }
.btn.danger { background: transparent; color: var(--accent); border-color: var(--accent-soft); }
.btn.danger:hover { background: var(--accent-soft); }
.btn.block { width: 100%; }
.btn.small { padding: 8px 12px; font-size: 14px; }

.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.alert.error { background: var(--accent-soft); color: #5e120c; }
.alert.ok { background: var(--ok-soft); color: #1f3f27; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .2px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.late { background: var(--accent-soft); color: var(--accent); }
.pill.done { background: var(--paper-2); color: var(--muted); }

/* ---------- customer page ---------- */
.site { min-height: 100vh; display: flex; flex-direction: column; }
.site-head { padding: 22px 24px; display: flex; justify-content: space-between; align-items: center; max-width: 1080px; width: 100%; margin: 0 auto; }
.site-head .head-note { font-size: 13px; color: var(--muted); }
.site-main { flex: 1; display: grid; place-items: start center; padding: 24px 16px 64px; }
.site-foot { padding: 24px; text-align: center; font-size: 12px; color: var(--muted); }

.panel { width: 100%; max-width: 460px; }
.hero-title { font-family: var(--display); font-weight: 600; font-size: clamp(34px, 7vw, 46px); line-height: 1.02; letter-spacing: -1px; margin: 28px 0 10px; }
.hero-title em { font-style: italic; color: var(--accent); font-weight: 500; }
.hero-sub { color: var(--muted); margin: 0 0 28px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: 0 1px 0 rgba(0,0,0,.02), 0 12px 30px -18px rgba(40,30,10,.25); }
.stack > * + * { margin-top: 16px; }

.loan-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.loan-head .who { font-family: var(--display); font-size: 24px; font-weight: 600; letter-spacing: -.3px; line-height: 1.15; }
.loan-head .contract { font-size: 13px; color: var(--muted); margin-top: 2px; }

.balance-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--muted); }
.balance-row strong { font-family: var(--mono); color: var(--ink); font-size: 15px; }
.bar { height: 6px; border-radius: 99px; background: var(--paper-2); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--ink); border-radius: 99px; }

.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.meta { background: var(--paper); border-radius: 10px; padding: 12px 14px; }
.meta span { display: block; font-size: 12px; color: var(--muted); }
.meta b { font-weight: 600; }

.due-box { border: 1px solid var(--ink); border-radius: 12px; padding: 18px; background: #fff; }
.due-box.late { border-color: var(--accent); }
.due-label { font-size: 12px; font-weight: 600; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); }
.due-amount { font-family: var(--display); font-size: 44px; font-weight: 600; letter-spacing: -1px; line-height: 1.1; margin: 4px 0 12px; }
.lines { border-top: 1px dashed var(--line); padding-top: 10px; font-size: 14px; }
.lines div { display: flex; justify-content: space-between; padding: 3px 0; }
.lines div span:last-child { font-family: var(--mono); }
.lines .fee { color: var(--accent); }
.late-note { margin-top: 10px; font-size: 13px; color: var(--accent); }

.test-note { font-size: 12px; color: var(--muted); text-align: center; }
.linkish { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: transparent; cursor: pointer; font-size: 13px; font-family: var(--mono); }
.tab.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.receipt { text-align: center; }
.receipt .tick { width: 56px; height: 56px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; margin: 0 auto 8px; }
.receipt h2 { font-family: var(--display); font-size: 28px; font-weight: 600; margin: 4px 0; letter-spacing: -.4px; }
.receipt-lines { text-align: left; background: var(--paper); border-radius: 10px; padding: 12px 16px; font-size: 14px; }
.receipt-lines div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.receipt-lines div span:last-child { font-family: var(--mono); text-align: right; }

.history { font-size: 14px; }
.history h3 { font-size: 13px; font-weight: 600; margin: 0 0 6px; color: var(--ink-2); }
.history div { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--paper-2); }
.history div:last-child { border-bottom: 0; }

@media (max-width: 480px) {
  .card { padding: 18px; }
  .meta-grid { grid-template-columns: 1fr; }
  .due-amount { font-size: 38px; }
  .site-head .head-note { display: none; }
}
