/* PropPay — Indigo design tokens and all styles. Mobile-first, single 480px column. */

:root {
  --bg: #F6F7FB;
  --surface: #FFFFFF;
  --surface-muted: #F0F1F7;
  --border: #E4E6EF;
  --border-strong: #CDD1E0;
  --text: #111827;
  --text-muted: #5B6275;
  /* Indigo carries actions and links; cyan is decoration only (it fails contrast as text or on white). */
  --accent: #4338CA;
  --accent-hover: #3730A3;
  --accent-soft: #EEF0FF;
  --accent-text: #FFFFFF;
  --link: #4338CA;
  --cyan: #22D3EE;
  --green: #15803D;
  --green-bg: #DCFCE7;
  --red: #B91C1C;
  --red-bg: #FEE2E2;
  --amber-bg: #FEF3C7;
  --amber: #92400E;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B0D17;
    --surface: #151827;
    --surface-muted: #1C2033;
    --border: #272B3F;
    --border-strong: #3A3F58;
    --text: #EEF0F7;
    --text-muted: #A3A8BD;
    --accent: #4F46E5;
    --accent-hover: #6366F1;
    --accent-soft: #1F2148;
    --link: #A5B4FC;
    --green: #4ADE80;
    --green-bg: #0F2E1C;
    --red: #F87171;
    --red-bg: #3B1212;
    --amber-bg: #3A2A0A;
    --amber: #FCD34D;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-color-scheme: dark) { :focus-visible { outline-color: var(--link); } }

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 0;
}
.wordmark { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.1875rem; letter-spacing: -0.02em; }
.logo-mark { width: 30px; height: 30px; flex-shrink: 0; }
.topbar .link-button { color: var(--text-muted); font-weight: 500; }

.page { max-width: 480px; margin: 0 auto; padding: 24px 16px 48px; }

h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 8px; letter-spacing: -0.02em; }
h2 { font-size: 1.0625rem; margin: 32px 0 0; letter-spacing: -0.01em; }

.muted { color: var(--text-muted); }
.small { font-size: 0.875rem; }
.step { margin: 0 0 4px; font-size: 0.8125rem; font-weight: 600; color: var(--accent); text-transform: none; }
@media (prefers-color-scheme: dark) { .step { color: var(--link); } }
.late { color: var(--red); font-weight: 600; }

.money { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* Messages */
.flash, .notice {
  margin: 0 0 20px;
  padding: 12px 16px;
  border-radius: var(--radius);
}
.flash { background: var(--green-bg); color: var(--text); transition: opacity 0.4s ease, transform 0.4s ease; }
.flash.is-leaving { opacity: 0; transform: translateY(-4px); }
.flash-error { background: var(--red-bg); color: var(--red); }
.notice { background: var(--amber-bg); }
.notice p { margin: 0 0 8px; }
.notice p:last-child { margin-bottom: 0; }
.sheet .notice { margin: 12px 0 0; }
/* "or Sign in with a passkey" under the code form */
.passkey-signin { margin-top: 0; gap: 12px; }
.passkey-signin .or { margin: 0; text-align: center; }

/* Stripe's embedded Connect components (onboarding, payouts, bank details) draw their own UI. */
.connect-embed {
  margin: 16px 0 24px;
  padding: 20px;
  min-height: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.connect-embed[data-connect-component="notification-banner"] { padding: 0; border: 0; background: none; }
.connect-steps { margin: 16px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.connect-steps li { display: flex; gap: 10px; align-items: baseline; }
.connect-steps li::before { content: ""; flex: 0 0 8px; height: 8px; border-radius: 50%; background: var(--cyan); transform: translateY(-1px); }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 16px; margin: 24px 0 16px; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; font-weight: 500; font-size: 0.9375rem; }
.field-row { display: flex; gap: 12px; }
.stack.address { margin: 6px 0 0; gap: 10px; }
/* Labels screen readers announce but the placeholder already shows (the address fields). */
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 1rem var(--font);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--text-muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.input-validation-error, select.input-validation-error, textarea.input-validation-error { border-color: var(--red); }
textarea { min-height: 140px; padding: 12px 14px; line-height: 1.5; resize: vertical; }
input[type="file"] { min-height: 0; padding: 10px 14px; }
.field-error { color: var(--red); font-size: 0.875rem; font-weight: 400; }
.field-error:empty { display: none; }

.money-input { position: relative; display: block; }
.money-input > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.money-input input { padding-left: 28px; font-variant-numeric: tabular-nums; }

.code-input { font-size: 1.5rem; font-variant-numeric: tabular-nums; letter-spacing: 0.35em; text-align: center; }

.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; }
.check input { width: 22px; min-height: 22px; height: 22px; accent-color: var(--accent); }
fieldset.choice { margin: 0; padding: 0; border: 0; }
fieldset.choice legend { margin-bottom: 4px; padding: 0; font-weight: 500; }

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font: 600 1rem var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}
.button:hover { background: var(--accent-hover); }
.button:active { transform: scale(0.98); }
.button[aria-busy="true"] { opacity: 0.7; cursor: progress; }
.button-small { min-height: 44px; padding: 0 16px; font-size: 0.9375rem; }
.button-block { display: flex; width: 100%; margin-top: 24px; }
.button-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.button-secondary:hover { background: var(--surface-muted); }
.button-danger { background: var(--red); }
.button-danger:hover { background: var(--red); opacity: 0.9; }
@media (prefers-color-scheme: dark) { .button-danger { background: #DC2626; } }

.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--link);
  font: 600 0.9375rem var(--font);
  text-decoration: none;
  cursor: pointer;
}
.link-button:hover { text-decoration: underline; }
.back-link { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 8px; color: var(--text-muted); text-decoration: none; font-size: 0.9375rem; }
.back-link:hover { color: var(--text); }
.danger-link { color: var(--red); }

/* Lists */
.list { list-style: none; margin: 16px 0 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.list-row + .list-row, .list > li + li { border-top: 1px solid var(--border); }
.list-title { font-weight: 600; }
.list-link { color: inherit; text-decoration: none; transition: background-color 0.15s ease; }
.list-link:hover { background: var(--surface-muted); }
.list-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row-tags { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.row-tags form { margin: 0; }
.empty { margin: 24px 0 0; padding: 28px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius); text-align: center; color: var(--text-muted); }

/* Initials badge for tenants and landlords */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.875rem; font-weight: 700; letter-spacing: 0.02em;
}
@media (prefers-color-scheme: dark) { .avatar { color: var(--link); } }
.avatar-large { width: 56px; height: 56px; font-size: 1.125rem; }

/* Status pills: a dot plus the word, so state doesn't rely on color alone */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.8125rem; font-weight: 600; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-paid { background: var(--green-bg); color: var(--green); }
.pill-due { background: var(--surface-muted); color: var(--text); }
.pill-late { background: var(--red-bg); color: var(--red); }
.tag { padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 0.75rem; color: var(--text-muted); }

/* Landlord home */
.stat { margin: 0 0 8px; padding: 20px; border-radius: var(--radius); background: var(--accent); color: var(--accent-text); }
.stat-label { margin: 0; font-size: 0.875rem; opacity: 0.85; }
.stat-value { margin: 4px 0 0; font-size: 2.5rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.03em; }
.stat-note { margin: 8px 0 0; font-size: 0.875rem; }
.stat-note::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--cyan); }
@media (prefers-color-scheme: dark) { .stat { background: #2A2675; } }

/* Tenant sheet */
.sheet { padding: 20px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.sheet h1 { font-size: 1.5rem; margin: 0; }
.sheet p { margin: 4px 0 0; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sheet-title { display: flex; align-items: center; gap: 14px; }
.sheet .status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.actions form { margin: 0; }

/* The tenant card: who, where they stand (a tinted strip), their details as labeled rows, then actions. */
.tenant-card { padding: 20px 16px; }
.tenant-head { display: flex; align-items: center; gap: 14px; }
.tenant-head h1 { margin: 0; font-size: 1.375rem; line-height: 1.25; }
.tenant-head p { margin: 2px 0 0; }
.tenant-status { display: flex; align-items: center; gap: 10px; margin: 18px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-muted); }
.tenant-status-detail { flex: 1; min-width: 0; font-size: 0.9375rem; }
.tenant-status-amount { font-weight: 600; }
.tenant-status.tone-late { background: var(--red-bg); }
.tenant-status.tone-late .tenant-status-detail { color: var(--red); font-weight: 500; }
.tenant-status.tone-paid { background: var(--green-bg); }
.tenant-status .pill { background: var(--surface); }
.tenant-details { margin: 14px 0 0; }
.tenant-details > div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; font-size: 0.9375rem; }
.tenant-details > div + div { border-top: 1px solid var(--border); }
.tenant-details dt { margin: 0; color: var(--text-muted); }
.tenant-details dd { margin: 0; min-width: 0; text-align: right; overflow-wrap: anywhere; }
.tenant-details a { color: var(--text); text-decoration: none; }
.tenant-details a:hover { color: var(--link); text-decoration: underline; }
.icon { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tenant-actions { display: grid; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.tenant-actions .button-block { margin: 0; }
.button-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 10px; }
.button-pair form { margin: 0; display: grid; }
.button-pair .button { width: 100%; padding: 0 8px; gap: 6px; white-space: nowrap; font-size: 0.9375rem; }
.button-pair .icon { width: 16px; height: 16px; }
.quiet-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; }
.quiet-actions form { margin: 0; }

/* Tenant pay page */
.payee { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; }
.payee p { margin: 0; }
.breakdown { margin: 24px 0 0; padding: 4px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.breakdown > div { display: flex; justify-content: space-between; padding: 10px 0; }
.breakdown > div + div { border-top: 1px solid var(--border); }
.breakdown dt, .breakdown dd { margin: 0; }
.breakdown .total { font-weight: 700; }
.stack .breakdown { margin: 0; }
.secure { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 12px 0 0; color: var(--text-muted); font-size: 0.8125rem; }
.secure svg { width: 14px; height: 14px; }

fieldset.methods { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; }
fieldset.methods legend { margin-bottom: 4px; padding: 0; font-weight: 500; }
.method {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  min-height: 52px; padding: 0 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  font-weight: 500; cursor: pointer; transition: border-color 0.15s ease, background-color 0.15s ease;
}
.method:hover { border-color: var(--text-muted); }
.method:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.method input { width: 22px; min-height: 22px; height: 22px; accent-color: var(--accent); }
[hidden] { display: none !important; }

/* Result screen */
.done-mark {
  display: flex; align-items: center; justify-content: center;
  width: 72px; height: 72px; margin: 8px 0 20px;
  border-radius: 50%; background: var(--green-bg); color: var(--green);
}
.done-mark svg { width: 36px; height: 36px; }
.big-amount { margin: 0 0 4px; font-size: 2.5rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.03em; }

/* Development outbox */
.outbox-message { margin-top: 16px; }
.outbox-message h2 { margin: 8px 0; font-size: 1rem; }
.outbox-message p { overflow-wrap: anywhere; }
.outbox-frame { width: 100%; height: 400px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* Tenant autopay card */
.autopay { margin-top: 12px; }
.autopay form { margin: 0; }
.autopay > .button, .autopay .button-row { margin-top: 16px; }
.autopay .muted.small { margin-top: 12px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* The tenant's pay page when nothing is due: who rent goes to, and the next rent */
.payee-name { font-weight: 600; font-size: 1.0625rem; }
.next-rent { margin-top: 16px; }
.next-rent-amount { font-size: 1.25rem; font-weight: 600; }
.next-rent form { margin: 16px 0 0; }
.contact { margin-top: 12px; }
.contact p + p { margin-top: 12px; }
.receipt .big-amount { margin: 12px 0 0; }
.receipt + .button { margin-top: 16px; }

@media print {
  .topbar, .site-footer, .no-print, .flash { display: none !important; }
  body { background: #fff; color: #000; }
  .sheet, .breakdown { border-color: #ccc; }
}

/* Legal */
.agreement { margin: 12px 0 0; color: var(--text-muted); font-size: 0.8125rem; text-align: center; }
.site-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; max-width: 480px; margin: 0 auto; padding: 8px 16px 32px; color: var(--text-muted); font-size: 0.8125rem; }
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--text); }
