/* Lease Ledger — quiet ledger-book styling. One loud element: the balance total. */
:root {
  --paper: #f3f5f1;
  --card: #fdfdfb;
  --ink: #222b22;
  --ink-soft: #5c675c;
  --rule: #d7ddd4;
  --green: #27584a;
  --green-soft: #e3ece7;
  --brass: #8d6f26;
  --brick: #a4442e;
  --radius: 6px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #171c18;
    --card: #1f2620;
    --ink: #e4e9e2;
    --ink-soft: #99a496;
    --rule: #333c34;
    --green: #7fb8a2;
    --green-soft: #243830;
    --brass: #c9a84e;
    --brick: #e07a5f;
  }
}
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
*, *::before, *::after { box-sizing: inherit; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 system-ui, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; margin: 1.6rem 0 0.6rem; }
a { color: var(--green); }

header {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.7rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--rule);
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); background: var(--card); z-index: 10; }
.brand { font-family: Georgia, serif; font-size: 1.05rem; }
nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
nav button {
  background: none; border: 0; padding: 0.45rem 0.7rem; cursor: pointer;
  color: var(--ink-soft); font: inherit; border-radius: var(--radius);
}
nav button[aria-current="true"] { color: var(--ink); background: var(--green-soft); }
#logoutBtn { margin-left: auto; }

main { max-width: 860px; margin: 0 auto; padding: 1rem 1rem 4rem; }

/* The one loud element: payoff balance set like a ledger total line */
.total-line {
  margin: 1.2rem 0 1.6rem; padding: 1rem 0 1.1rem;
  border-top: 2px solid var(--ink);
  border-bottom: 3px double var(--ink);
}
.total-line .figure {
  font-family: Georgia, serif; font-size: clamp(2.4rem, 9vw, 3.6rem);
  line-height: 1.05; color: var(--green);
}
.total-line .caption { color: var(--ink-soft); margin-top: 0.2rem; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; }
.stat { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 0.7rem 0.85rem; }
.stat b { display: block; font-size: 1.15rem; }
.stat span { color: var(--ink-soft); font-size: 0.85rem; }

table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
th, td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--rule); }
th { color: var(--ink-soft); font-weight: 500; font-size: 0.85rem; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }

.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.8rem; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.pending { background: color-mix(in srgb, var(--brass) 15%, transparent); color: var(--brass); }
.badge.overdue, .badge.rejected { background: color-mix(in srgb, var(--brick) 14%, transparent); color: var(--brick); }

button, .btn {
  font: inherit; cursor: pointer; border-radius: var(--radius);
  border: 1px solid var(--green); background: var(--green); color: var(--paper);
  padding: 0.5rem 0.9rem;
}
button.quiet, .btn.quiet { background: none; color: var(--ink); border-color: var(--rule); }
button.danger { background: none; color: var(--brick); border-color: var(--brick); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--green); outline-offset: 2px;
}

form.panel, .panel { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem; margin: 0.8rem 0; }
label { display: block; margin: 0.6rem 0; }
input, select, textarea {
  font: inherit; width: 100%; max-width: 420px; padding: 0.45rem 0.55rem;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); margin-top: 0.2rem;
}
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: end; }
.row label { flex: 1 1 160px; }
.hint { color: var(--ink-soft); font-size: 0.88rem; }
.error { color: var(--brick); min-height: 1.2em; }

#login { min-height: 100svh; display: grid; place-items: center; padding: 1rem; }
#loginForm { width: min(380px, 100%); background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.4rem; }
#loginForm h1 { margin: 0 0 0.2rem; font-size: 1.5rem; }
#loginForm .sub { color: var(--ink-soft); margin-top: 0; }
#loginForm button { width: 100%; margin-top: 0.8rem; }

dialog { border: 1px solid var(--rule); border-radius: var(--radius); background: var(--card); color: var(--ink); max-width: min(520px, 92vw); width: 100%; }
dialog::backdrop { background: rgba(0,0,0,0.35); }

@media (prefers-reduced-motion: no-preference) {
  nav button, button { transition: background-color 120ms ease; }
}
