/* RentDesk — ledger-and-keys look: slate-green ink, brass key tags, quiet tables. */
:root {
  --ink: #17302e; --ink-2: #21423f; --paper: #f3f5f2; --surface: #ffffff; --line: #d9dfd9;
  --text: #1c2422; --muted: #5d6a66; --brass: #a9822f; --brass-soft: #f3e9d2;
  --ok: #2e7a55; --ok-soft: #e2f1e8; --warn: #a86b12; --warn-soft: #fbefd9; --bad: #b3412f; --bad-soft: #f8e3df;
  --focus: #2f6fd6;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --r-sm: 4px; --r-md: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #0f1f1e; --ink-2: #1a302e; --paper: #121816; --surface: #1a2220; --line: #2d3835;
    --text: #e4e9e6; --muted: #9aa8a3; --brass: #d0a64b; --brass-soft: #3a3020;
    --ok: #6cc095; --ok-soft: #173126; --warn: #e2a64a; --warn-soft: #3a2c14; --bad: #ef8a78; --bad-soft: #3b1f1a;
    --focus: #7aa7ff; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 var(--sans); color: var(--text); background: var(--paper); }
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font: 600 1.9rem/1.15 var(--serif); letter-spacing: -0.01em; }
h2 { font-size: 1rem; font-weight: 650; margin-bottom: .8rem; display: flex; gap: .6rem; align-items: baseline; }
code { font-size: .85em; background: color-mix(in srgb, var(--line) 50%, transparent); padding: .1em .35em; border-radius: var(--r-sm); }
.muted { color: var(--muted); } .small, small { font-size: .82rem; } .block { display: block; } .nowrap { white-space: nowrap; }
.prewrap { white-space: pre-wrap; margin: 0; max-width: 75ch; } .mt { margin-top: 1.4rem; } .bad-text { color: var(--bad); font-weight: 600; }
.is-hidden { display: none; }

/* Layout */
body.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #dfe7e3; display: flex; flex-direction: column; padding: 1.2rem 0; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 0 1.25rem 1.4rem; font: 600 1.15rem var(--serif); color: #fff; text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 50% 50% 50% 4px; background: var(--brass); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--ink); }
.brand-mark.big { width: 40px; height: 40px; } .brand-mark.big::after { inset: 13px; background: var(--paper); }
.side nav { display: flex; flex-direction: column; }
.side nav a { padding: .55rem 1.25rem; color: #c8d4cf; text-decoration: none; border-left: 3px solid transparent; }
.side nav a:hover { color: #fff; background: var(--ink-2); }
.side nav a.on { color: #fff; border-left-color: var(--brass); background: var(--ink-2); font-weight: 600; }
.side-foot { margin-top: auto; padding: 1rem 1.25rem 0; border-top: 1px solid var(--ink-2); display: grid; gap: .7rem; font-size: .88rem; }
.who { display: grid; gap: .25rem; } .who strong { color: #fff; font-weight: 600; }
.langs { display: flex; gap: .4rem; } .langs a { padding: .15rem .5rem; border-radius: var(--r-sm); text-decoration: none; border: 1px solid transparent; }
.side .langs a { color: #c8d4cf; } .langs a.on { border-color: var(--brass); color: var(--brass); }
.side .link { color: #c8d4cf; }
.main { padding: 2rem clamp(1rem, 3vw, 2.6rem) 4rem; max-width: 1240px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head p { margin: .35rem 0 0; }
.back { display: inline-block; font-size: .85rem; color: var(--muted); text-decoration: none; margin-bottom: .4rem; }
.deed { font-size: 2.1rem; }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .95rem; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: 600 .9rem var(--sans); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: var(--ink-2); }
@media (prefers-color-scheme: dark) { .btn.primary { background: var(--brass); border-color: var(--brass); color: #1b1407; } }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.warn { color: var(--warn); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: .28rem .6rem; font-size: .8rem; }
.btn.wide { width: 100%; justify-content: center; padding: .7rem; }
.btn-row, .actions-cell { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }
.btn-row form, .actions-cell form { margin: 0; }
button.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; color: inherit; }
button.link.danger-text, .danger-text { color: var(--bad); font-size: .8rem; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: .5rem .65rem; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: 2px solid color-mix(in srgb, var(--focus) 25%, transparent); outline-offset: 0; }
input[aria-invalid="true"] { border-color: var(--bad); }
input[type="checkbox"] { width: 1.05rem; height: 1.05rem; accent-color: var(--ink); padding: 0; }
textarea { resize: vertical; min-height: 6rem; }
label { display: grid; gap: .3rem; font-size: .88rem; font-weight: 600; color: var(--text); }
label small { font-weight: 400; }
label.check { display: flex; align-items: center; gap: .55rem; font-weight: 500; margin: .3rem 0 .7rem; }
label.inline { display: flex; align-items: center; gap: .55rem; font-weight: 500; }
input.short { width: 5rem; }
.err { color: var(--bad); font-weight: 500; font-size: .8rem; }
.hint { color: var(--muted); font-size: .82rem; margin: .4rem 0 0; max-width: 70ch; }
.form { display: grid; gap: 1.2rem; max-width: 900px; } .form.narrow { max-width: 620px; }
fieldset { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-md); padding: 1.1rem 1.25rem 1.25rem; margin: 0; display: grid; gap: .9rem; }
legend { font: 600 1.05rem var(--serif); padding: 0 .4rem; }
.row { display: flex; gap: .9rem; flex-wrap: wrap; } .row > label { flex: 1 1 160px; } .row > label.grow { flex: 3 1 260px; }
.row > label.check, .row > label.inline { flex: 0 1 auto; }
.actions { display: flex; gap: .6rem; }
.stack { display: grid; gap: .9rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input[type="search"], .filters input[name="user"] { flex: 1 1 220px; width: auto; }
.filters select, .filters input[type="date"], .filters .short-input { width: auto; flex: 0 1 auto; }

/* Messages */
.flash { padding: .7rem 1rem; border-radius: var(--r-sm); margin-bottom: 1rem; border-left: 4px solid; background: var(--surface); }
.flash-ok { border-color: var(--ok); background: var(--ok-soft); } .flash-error { border-color: var(--bad); background: var(--bad-soft); }
.flash-warn { border-color: var(--warn); background: var(--warn-soft); } .flash-info { border-color: var(--ink); }
.note { font-size: .85rem; color: var(--muted); margin: -.8rem 0 1.2rem; }
.reveal { border: 2px dashed var(--brass); background: var(--brass-soft); border-radius: var(--r-md); padding: 1rem 1.2rem; margin-bottom: 1.2rem; }
.reveal p { margin: .3rem 0; } .secret { font-size: 1.15rem; letter-spacing: .06em; padding: .25rem .6rem; background: var(--surface); }
.empty { text-align: center; padding: 3rem 1rem; border: 1px dashed var(--line); border-radius: var(--r-md); }
.empty h2 { justify-content: center; font: 600 1.3rem var(--serif); }

/* Key tag — the one signature element */
.keytag { display: flex; align-items: stretch; text-decoration: none; margin-bottom: 1.6rem; max-width: 720px;
  background: var(--brass-soft); border: 1px solid color-mix(in srgb, var(--brass) 45%, transparent);
  border-radius: 999px 14px 14px 999px; padding: .9rem 1.4rem .9rem .9rem; gap: 1.1rem; position: relative; }
.keytag:hover { border-color: var(--brass); }
.keytag-hole { width: 18px; height: 18px; border-radius: 50%; background: var(--paper); border: 2px solid color-mix(in srgb, var(--brass) 55%, transparent); align-self: center; flex: none; }
.keytag-days { display: grid; place-items: center; min-width: 5.2rem; padding-right: 1.1rem; border-right: 1px dashed color-mix(in srgb, var(--brass) 60%, transparent); text-align: center; }
.keytag-days strong { font: 600 2.6rem/1 var(--serif); color: var(--brass); font-variant-numeric: tabular-nums; }
.keytag-days small { color: var(--muted); }
.keytag.is-warn .keytag-days strong { color: var(--warn); } .keytag.is-bad .keytag-days strong { color: var(--bad); }
.keytag-body { display: grid; gap: .15rem; align-content: center; min-width: 0; }
.keytag-body small { color: var(--muted); }
.keytag-body .addr { font: 600 1.3rem/1.2 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Stats & panels */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); margin-bottom: 1.4rem; }
.stat { padding: 1rem 1.15rem; display: grid; gap: .15rem; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat span { font-size: .82rem; color: var(--muted); font-weight: 600; }
.stat strong { font-size: 1.55rem; font-variant-numeric: tabular-nums; font-weight: 650; }
.stat small { color: var(--muted); }
.stat.warn strong { color: var(--warn); } .stat.bad strong { color: var(--bad); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 1.15rem 1.25rem; margin-bottom: 1.4rem; }
.panel h2 .small { font-weight: 500; margin-left: auto; }
.notes { border-left: 4px solid var(--brass); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 0 1.4rem; }
.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: .45rem 1.2rem; margin: 0 0 1rem; }
.kv dt { color: var(--muted); font-size: .88rem; } .kv dd { margin: 0; }
.due-line { display: flex; gap: .7rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }

/* Bars (width classes because CSP blocks inline styles) */
.bars { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; }
.bars li { display: grid; grid-template-columns: 8.5rem 1fr 2.5rem; align-items: center; gap: .7rem; font-size: .88rem; }
.bars b { text-align: right; font-variant-numeric: tabular-nums; }
.bar { display: block; height: 10px; background: color-mix(in srgb, var(--line) 60%, transparent); border-radius: 2px; overflow: hidden; }
.bar.inline { display: inline-block; width: 90px; vertical-align: middle; margin-right: .4rem; }
.bar i { display: block; height: 100%; background: var(--ink); }
@media (prefers-color-scheme: dark) { .bar i { background: var(--brass); } }
.w-0{width:0}.w-5{width:5%}.w-10{width:10%}.w-15{width:15%}.w-20{width:20%}.w-25{width:25%}.w-30{width:30%}.w-35{width:35%}.w-40{width:40%}.w-45{width:45%}.w-50{width:50%}
.w-55{width:55%}.w-60{width:60%}.w-65{width:65%}.w-70{width:70%}.w-75{width:75%}.w-80{width:80%}.w-85{width:85%}.w-90{width:90%}.w-95{width:95%}.w-100{width:100%}

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.panel .table-wrap { border: 0; border-radius: 0; margin: 0 -1.25rem; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: .65rem .9rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .65rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--paper) 70%, transparent); }
.num { text-align: right; font-variant-numeric: tabular-nums; } .c { text-align: center; }
tr.dim td { opacity: .55; }
a.strong { font-weight: 600; }
.thumb { width: 64px; padding-right: 0; }
.thumb img, .nophoto { width: 56px; height: 42px; object-fit: cover; border-radius: var(--r-sm); display: block; }
.nophoto { background: repeating-linear-gradient(135deg, var(--line) 0 2px, transparent 2px 7px); }
.audit .details { font-size: .82rem; max-width: 420px; word-break: break-word; }
.audit del { color: var(--bad); } .audit ins { color: var(--ok); text-decoration: none; }
.matrix td.c input { margin: auto; }
.ua { max-width: 360px; }

/* Badges */
.badge { display: inline-block; white-space: nowrap; font-size: .76rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.role { font-size: .74rem; font-weight: 600; padding: .1rem .45rem; border-radius: var(--r-sm); border: 1px solid; width: fit-content; }
.role-admin { color: var(--brass); } .role-manager { color: var(--ok); } .role-user { color: var(--muted); }
.side .role-user { color: #b8c6c1; }

.tabs { display: flex; gap: .3rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tabs a { padding: .5rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--text); border-color: var(--brass); font-weight: 600; }
.pager { display: flex; gap: .3rem; margin-top: 1rem; }
.pager a, .pager span { padding: .3rem .65rem; border: 1px solid var(--line); border-radius: var(--r-sm); text-decoration: none; background: var(--surface); }
.pager .on { background: var(--ink); color: #fff; border-color: var(--ink); }

.gallery { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .8rem; }
.gallery li { display: grid; gap: .3rem; }
.gallery img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--r-sm); display: block; border: 1px solid var(--line); }
.gallery form { margin: 0; }

/* Login */
body.bare { min-height: 100vh; display: grid; place-items: center; background: var(--ink); }
.center { width: 100%; display: grid; place-items: center; padding: 2rem 1rem; }
.login { width: min(400px, 100%); background: var(--surface); border-radius: 14px; padding: 2rem 2rem 1.4rem; border-top: 6px solid var(--brass); }
.login-brand { display: flex; align-items: center; gap: .8rem; }
.login .lede { color: var(--muted); margin: .5rem 0 1.4rem; }
.center-row { display: flex; flex-wrap: wrap; justify-content: center; text-align: center; margin-top: 1.2rem; font-size: .88rem; }
.login .langs a { color: var(--muted); }

/* Responsive */
@media (max-width: 860px) {
  body.app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: .7rem 0 .5rem; }
  .brand { padding-bottom: .6rem; }
  .side nav { flex-direction: row; overflow-x: auto; }
  .side nav a { border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; padding: .45rem .9rem; }
  .side nav a.on { border-bottom-color: var(--brass); }
  .side-foot { flex-direction: row; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; padding-top: .6rem; }
  .stat { border-right: 0; border-bottom: 1px solid var(--line); }
  .keytag { border-radius: 14px; }
  .keytag-hole { display: none; }
  h1 { font-size: 1.55rem; } .deed { font-size: 1.7rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .side, .btn, .filters, form { display: none !important; } body.app { display: block; } }

/* Reset-password menu */
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > summary::after { content: "▾"; font-size: .7em; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; width: 290px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: 0 6px 24px rgba(10, 30, 28, .14); padding: .3rem; }
.menu-pop form { margin: 0; }
.menu-item { display: grid; gap: .1rem; width: 100%; text-align: left; background: none; border: 0; border-radius: var(--r-sm);
  padding: .55rem .65rem; font: inherit; color: var(--text); cursor: pointer; white-space: normal; }
.menu-item:hover, .menu-item:focus-visible { background: var(--paper); }
.menu-item small { color: var(--muted); font-size: .78rem; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.login h2 { font: 600 1.25rem var(--serif); }
.hint.flush, .flush { margin-top: 0; margin-bottom: 0; }
.linkbox { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .8rem 0 1rem; }
.linkbox code { flex: 1 1 320px; padding: .45rem .6rem; word-break: break-all; font-size: .82rem; }
.contract-file { display: flex; gap: .8rem; align-items: center; margin: 0 0 1rem; }
.doc-icon { width: 42px; height: 52px; border: 1px solid var(--line); border-radius: 4px 12px 4px 4px; display: grid; place-items: center;
  font-size: .7rem; font-weight: 700; color: var(--bad); background: var(--paper); flex: none; }
code.iban { letter-spacing: .04em; }

/* Tenant page (public) */
body.bare:has(.tpage) { display: block; background: var(--paper); }
.tpage { width: min(920px, 100%); margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.tpage-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 1rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
.tpage-brand { display: flex; gap: .55rem; align-items: center; font: 600 1.1rem var(--serif); }
.tpage-brand .brand-mark::after { background: var(--paper); }
.tpage .langs a { color: var(--muted); }
.tpage-hero { margin-bottom: 1.4rem; } .tpage-hero p { margin: .3rem 0; }
.tpage .keytag { max-width: none; }
.pay { border-left: 4px solid var(--ok); }
.copyrow { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.tpage-foot { text-align: center; margin: 2rem auto 0; }
.tpage .gallery img { aspect-ratio: 4/3; }
