:root {
  --ink: #0b2a3f; --muted: #50667a; --paper: #f6f8fa; --card: #ffffff; --line: #d5dee6;
  --brand: #0b3a5b; --brand-ink: #ffffff;
  --ok: #1f7a4d; --ok-bg: #e3f3ea;
  --notice: #9a6700; --notice-bg: #fff3d1;
  --risk: #b3261e; --risk-bg: #fde7e4;
  --late: #b3261e; --partial: #9a6700; --upcoming: #6a7c8c;
  --focus: #0a64d6;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8eff5; --muted: #9bb0c2; --paper: #0c1620; --card: #12202d; --line: #263747;
    --brand: #7cc0ee; --brand-ink: #06202f;
    --ok: #62d09a; --ok-bg: #12301f; --notice: #f0c05a; --notice-bg: #33280c;
    --risk: #ff8d84; --risk-bg: #3a1613; --late: #ff8d84; --partial: #f0c05a; --upcoming: #8ea3b5;
    --focus: #8cc4ff;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); line-height: 1.5; font-size: 1rem; padding-bottom: env(safe-area-inset-bottom); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .4rem; }
p { margin: 0 0 .75rem; max-width: 68ch; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: .5rem; top: -4rem; background: var(--brand); color: var(--brand-ink); padding: .5rem .8rem; z-index: 50; border-radius: 6px; }
.skip:focus { top: .5rem; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; padding-top: calc(.6rem + env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: .5rem; }
.brand-mark { width: 14px; height: 18px; background: var(--brand); border-radius: 2px; clip-path: polygon(0 0, 100% 0, 100% 85%, 80% 100%, 60% 85%, 40% 100%, 20% 85%, 0 100%); }
.tabs { display: flex; gap: .25rem; margin-left: auto; }
.tabs a { padding: .45rem .7rem; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }
.tabs a[aria-current="page"] { color: var(--ink); background: var(--paper); box-shadow: inset 0 -3px 0 var(--brand); }
.lang { min-width: 44px; min-height: 44px; border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 8px; font-weight: 700; cursor: pointer; }

main { max-width: 780px; margin: 0 auto; padding: 1.25rem 1rem 3rem; outline: none; }
.foot { max-width: 780px; margin: 0 auto; padding: 1rem; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }
.small { font-size: .875rem; } .muted { color: var(--muted); } .lede { font-size: 1.1rem; }
.meta { color: var(--muted); margin-bottom: .35rem; }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 99px; background: var(--paper); border: 1px solid var(--line); font-size: .8rem; color: var(--ink); }
.iban { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .9em; word-break: break-all; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: .55rem 1rem; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-danger { background: var(--risk); color: #fff; }
.btn-danger-outline { background: transparent; color: var(--risk); border-color: var(--risk); }
.link-btn { background: none; border: 0; color: var(--brand); font: inherit; text-decoration: underline; cursor: pointer; padding: .5rem 0; min-height: 44px; }
.link-btn.danger { color: var(--risk); }
.row { display: flex; flex-wrap: wrap; gap: .6rem; margin: .75rem 0; }
.row.end { justify-content: flex-end; }
.actions { margin: 1.25rem 0; }
.add { margin-top: .5rem; }
.back { display: inline-block; margin-bottom: .6rem; min-height: 44px; line-height: 44px; }

.rule-banner { background: var(--notice-bg); border-left: 5px solid var(--notice); padding: .7rem .9rem; border-radius: var(--radius); margin: 0 0 1.2rem; }
.rule-banner p { margin: 0 0 .25rem; } .rule-main { font-weight: 600; } .rule-note { font-size: .875rem; color: var(--muted); }

.hero { padding: .5rem 0 1rem; } .hero h1 { font-size: 2rem; }

/* the month stub: perforated receipt slip */
.ledger { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .6rem; margin: .75rem 0; }
.stub { --c: var(--upcoming); --bg: var(--card);
  position: relative; display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .6rem .3rem .7rem; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-top: 5px solid var(--c); border-radius: 4px 4px 0 0; cursor: pointer; text-align: center;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 12px 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 12px 100%;
  padding-bottom: 1rem; }
.stub[aria-hidden] { cursor: default; }
.stub-month { font-weight: 700; text-transform: capitalize; } .stub-year { font-size: .75rem; color: var(--muted); }
.stub-amount { font-variant-numeric: tabular-nums; font-weight: 600; margin-top: .2rem; }
.stub.is-expected .stub-amount { color: var(--muted); font-weight: 400; }
.stub-state { font-size: .75rem; font-weight: 700; color: var(--c); }
.tone-ok { --c: var(--ok); --bg: var(--ok-bg); }
.tone-notice { --c: var(--notice); --bg: var(--notice-bg); }
.tone-risk { --c: var(--risk); --bg: var(--risk-bg); }
.tone-partial { --c: var(--partial); --bg: var(--notice-bg); }
.tone-late { --c: var(--late); --bg: var(--risk-bg); }
.tone-upcoming { --c: var(--upcoming); }
.stub:hover { filter: brightness(.97); }
.sample .stub { min-width: 0; }

.lease-row { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: 1rem; margin: .75rem 0; background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--c, var(--ok)); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.lease-row h2 { margin: 0 0 .15rem; font-size: 1.1rem; } .lease-row .status { font-weight: 600; margin: 0; }
.lease-side { text-align: right; }
.dots { list-style: none; display: flex; gap: 4px; margin: 0 0 .4rem; padding: 0; justify-content: flex-end; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.readiness progress { width: 100%; height: 10px; accent-color: var(--ok); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .2rem 1rem 1rem; margin: 1.25rem 0; }
.panel.attention { border-left: 5px solid var(--risk); }
.issues { padding-left: 1.1rem; margin: 0; } .issues li { margin-bottom: .5rem; }

.table-wrap { overflow-x: auto; }
.pay-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.pay-table th, .pay-table td { padding: .5rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.pay-table td.num { text-align: right; }
.pill { display: inline-block; padding: .05rem .55rem; border-radius: 99px; font-size: .8rem; font-weight: 700; color: var(--c); background: var(--bg); border: 1px solid var(--c); }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li, .check-row { display: flex; gap: .7rem; align-items: flex-start; padding: .45rem 0; }
.checklist input, .check-row input { width: 22px; height: 22px; margin-top: .15rem; flex: none; }

.field { margin: 0 0 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .25rem; }
.field input[type=text], .field input[type=date], .field input[type=number], .field select, .field textarea {
  width: 100%; min-height: 44px; padding: .55rem .7rem; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.field [aria-invalid="true"] { border-color: var(--risk); border-width: 2px; }
.help { color: var(--muted); font-size: .85rem; margin: .25rem 0 0; }
.error { color: var(--risk); font-weight: 600; font-size: .9rem; margin: .25rem 0 0; }
.page-form { max-width: 520px; }

.dlg { border: 0; border-radius: 14px; padding: 1.2rem; width: min(480px, calc(100vw - 1.5rem)); max-height: 90vh; background: var(--card); color: var(--ink); }
.dlg::backdrop { background: rgba(5, 15, 25, .55); }
.dlg h2 { margin-top: 0; } .dlg-text { font-size: 1.05rem; }
.preview { padding: .6rem .8rem; border-radius: 8px; min-height: 2.6rem; font-weight: 600; background: var(--paper); }
.preview.ok { background: var(--ok-bg); color: var(--ok); }
.preview.notice { background: var(--notice-bg); color: var(--notice); }
.preview.risk { background: var(--risk-bg); color: var(--risk); }

.timeline { padding-left: 1.2rem; } .timeline li { margin-bottom: .4rem; } .timeline li.current { font-weight: 700; }
.prose-list li { margin-bottom: .4rem; max-width: 68ch; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; } .facts dt { color: var(--muted); } .facts dd { margin: 0; }

.toast { position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translate(-50%, 140%); background: var(--ink); color: var(--paper); padding: .7rem 1rem; border-radius: 10px; max-width: calc(100vw - 2rem); opacity: 0; transition: transform .2s ease, opacity .2s ease; z-index: 100; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media (max-width: 520px) {
  .lease-row { flex-direction: column; align-items: flex-start; } .lease-side { text-align: left; width: 100%; } .dots { justify-content: flex-start; }
  .ledger { grid-template-columns: repeat(3, 1fr); } h1 { font-size: 1.4rem; } .hero h1 { font-size: 1.7rem; }
}
@media print {
  .top, .foot, .toast, .no-print, .skip { display: none !important; }
  body { background: #fff; color: #000; } main { max-width: none; padding: 0; }
  .pay-table th, .pay-table td { border-color: #999; }
}
