/*
 * Copyright (c) 2026 Headstart Consult CC. All rights reserved.
 * Proprietary and confidential. See LICENSE and AI_NOTICE.md.
 * Headstart colours: navy #06406e, cyan #01b0f1, dark cyan #0479b0, tint #e3f4fd. Headings Poppins, body Inter
 * (system fonts as fallback, so no font service is needed).
 */
:root {
  --navy: #06406e; --cyan: #01b0f1; --dcyan: #0479b0; --tint: #e3f4fd;
  --bg: #f5f8fb; --card: #ffffff; --text: #13202b; --muted: #5b6b78; --line: #d6e1ea;
  --ok: #157a3c; --ok-bg: #e5f5ea; --warn: #8a5a00; --warn-bg: #fff4dc; --err: #b42318; --err-bg: #fdecea; --info-bg: var(--tint);
  --radius: 12px; --nav-h: 64px;
  --head: Poppins, Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --body: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1620; --card: #12212e; --text: #e6eef5; --muted: #9db0bf; --line: #24394b; --tint: #10324d; --info-bg: #10324d;
    --ok-bg: #12351f; --ok: #6fd69a; --warn-bg: #3a2c0b; --warn: #f2c464; --err-bg: #3d1512; --err: #ff8a80; color-scheme: dark; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 var(--body); color: var(--text); background: var(--bg); padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
h1, h2, h3 { font-family: var(--head); line-height: 1.25; margin: .2em 0 .5em; }
h1 { font-size: 1.45rem; color: var(--navy); }
@media (prefers-color-scheme: dark) { h1 { color: #8fd3ff; } }
h2 { font-size: 1.1rem; } h3 { font-size: 1rem; margin-top: 1em; }
a { color: var(--dcyan); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .pre { white-space: pre-wrap; }
.lead { font-size: 1.05rem; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: var(--navy); color: #fff; }
.logo { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-family: var(--head); font-weight: 600; }
.logo img { border-radius: 6px; background: #fff; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: #9aa9b5; display: inline-block; }
.sync-dot.ok { background: #3ddc84; } .sync-dot.busy { background: var(--cyan); } .sync-dot.err { background: #ff6b5e; }
.banner { display: block; padding: 8px 16px; background: var(--warn-bg); color: var(--warn); text-decoration: none; font-weight: 600; }
.banner.err { background: var(--err-bg); color: var(--err); }

main { max-width: 900px; margin: 0 auto; padding: 16px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.help-btn { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--cyan); background: transparent; color: var(--cyan);
  font: 700 1rem var(--head); cursor: pointer; }
.topbar .help-btn { border-color: #fff; color: #fff; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .75rem; }
.nav a.on { color: var(--dcyan); font-weight: 600; }
.nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 200px; }
  .nav { top: 0; right: auto; width: 200px; height: auto; flex-direction: column; justify-content: flex-start; padding-top: 70px; border-top: 0; border-right: 1px solid var(--line); }
  .nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 20px; font-size: .95rem; }
  .topbar { margin-left: -200px; padding-left: 20px; }
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; }
.card > h2:first-child { margin-top: 0; }
.row { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
.row.wrap { flex-wrap: wrap; }
.sticky-actions { position: sticky; bottom: calc(var(--nav-h) + 8px); background: var(--bg); padding: 8px 0; }
@media (min-width: 900px) { .sticky-actions { bottom: 0; } }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: 600 .92rem var(--body); text-decoration: none; cursor: pointer; text-align: center; }
.btn:hover { border-color: var(--cyan); }
.btn.primary { background: var(--dcyan); border-color: var(--dcyan); color: #fff; }
.btn.primary:hover { background: var(--navy); }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.disabled { opacity: .55; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: .82rem; }
.btn.big { width: 100%; min-height: 52px; font-size: 1.05rem; margin-top: 12px; }
.topbar .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.linkish { background: none; border: 0; padding: 0 4px; color: var(--dcyan); text-decoration: underline; cursor: pointer; font: inherit; }

.form .field { margin: 10px 0; }
.field label { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; min-height: 42px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--cyan) 45%, transparent); outline-offset: 1px; border-color: var(--cyan); }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; flex: none; margin: 2px 0 0; accent-color: var(--dcyan); }
input:disabled { opacity: .5; }
.hint { color: var(--muted); font-size: .8rem; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; font-weight: 400; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 12px; }
.grid2, .grid3 { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid3 { grid-template-columns: 1fr 1fr 1fr; } }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 0; padding: 4px 12px 10px; }
legend { font-weight: 700; padding: 0 6px; }
.info-btn { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--dcyan); background: transparent; color: var(--dcyan); font: italic 700 12px Georgia, serif; cursor: pointer; padding: 0; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; }
a.list-item:hover { border-color: var(--cyan); }
.card .list-item { background: var(--bg); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--tint); color: var(--navy); margin-right: 4px; }
@media (prefers-color-scheme: dark) { .badge { color: #cfeaff; } }
.badge.paid, .badge.green { background: var(--ok-bg); color: var(--ok); }
.badge.partly, .badge.amber, .badge.due { background: var(--warn-bg); color: var(--warn); }
.badge.unpaid, .badge.red { background: var(--err-bg); color: var(--err); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; }
.stat span { color: var(--muted); font-size: .8rem; } .stat b { font-size: 1.1rem; font-family: var(--head); }
.stat.paid b { color: var(--ok); } .stat.unpaid b { color: var(--err); } .stat.partly b, .stat.due b { color: var(--warn); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.alert { display: block; padding: 10px 12px; border-radius: 10px; margin: 10px 0; text-decoration: none; }
.alert.warn { background: var(--warn-bg); color: var(--warn); } .alert.error { background: var(--err-bg); color: var(--err); }
.alert.info { background: var(--info-bg); color: var(--text); } .alert .linkish { margin-left: 6px; }
.result { border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; }
.result.green { background: var(--ok-bg); } .result.amber { background: var(--warn-bg); } .result.red { background: var(--err-bg); }
.result ul { margin: 6px 0 0; padding-left: 20px; }
.consents { list-style: none; padding: 0; } .consents li.no { color: var(--err); }
.overdue { color: var(--err); }

.kv { display: grid; grid-template-columns: minmax(110px, 35%) 1fr; gap: 4px 12px; margin: 8px 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
table.num td:nth-child(n+3) { text-align: right; white-space: nowrap; }
table.compare td:first-child { white-space: nowrap; }
table.mini { font-size: .85rem; }

.modal-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(4, 20, 35, .55); display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .modal-wrap { align-items: center; } }
.modal { background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; display: flex; flex-direction: column; border-radius: 16px 16px 0 0; }
@media (min-width: 640px) { .modal { border-radius: 16px; } }
.modal.wide { max-width: 760px; }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px; }
.modal header h2 { margin: 0; }
.modal-body { padding: 4px 16px 12px; overflow-y: auto; }
.modal footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.x { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); }
.form-err:empty { display: none; }
.msg-text { font-size: .92rem; }

#help-panel { position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: var(--card); border-left: 1px solid var(--line);
  padding: calc(14px + env(safe-area-inset-top)) 16px 90px; overflow-y: auto; transform: translateX(100%); transition: transform .2s; box-shadow: -8px 0 24px rgba(0,0,0,.12); }
#help-panel.open { transform: none; }
#help-panel header { display: flex; justify-content: space-between; align-items: center; }
#help-panel input[type=search] { margin: 8px 0; }
.help-body ul { padding-left: 20px; }
.help-hit { display: block; width: 100%; text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 6px 0; cursor: pointer; color: var(--text); font: inherit; }
.help-hit span { display: block; color: var(--muted); font-size: .85rem; }
.help-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.pop { position: absolute; z-index: 60; max-width: 320px; background: var(--navy); color: #fff; padding: 10px 30px 10px 12px; border-radius: 10px; font-size: .88rem; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.pop .x { position: absolute; top: 4px; right: 6px; color: #fff; font-size: 1.2rem; }
.tips { background: var(--tint); border-left: 4px solid var(--cyan); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.tips ul { margin: 6px 0; padding-left: 20px; }
#toast { position: fixed; z-index: 70; left: 50%; bottom: calc(var(--nav-h) + 16px); transform: translateX(-50%) translateY(20px); opacity: 0; background: var(--navy); color: #fff;
  padding: 10px 16px; border-radius: 10px; transition: .2s; max-width: 90vw; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%); }

.sig-wrap { margin: 10px 0; } .sig { width: 100%; height: auto; aspect-ratio: 10 / 3; border: 2px dashed var(--line); border-radius: 10px; background: #fff; touch-action: none; }
.lease-preview { background: #fff; color: #13202b; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; font-size: .92rem; margin-top: 12px; }
.lease-preview h1, .lease-preview h2, .lease-preview h3 { color: #06406e; }
.lease-preview table { font-size: .88rem; } .lease-preview th, .lease-preview td { border: 1px solid #c9d6e2; color: #13202b; }
.lease-preview .draft { border-left: 4px solid #c8891c; padding: 6px 10px; background: #fff7e6; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin: 8px 0; }
.thumbs img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; }
.thumbs figure { margin: 0; } .thumbs figcaption { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; font-size: .8rem; margin-top: 4px; }
.refund { border-top: 1px solid var(--line); margin-top: 12px; }
body.apply { padding-bottom: 24px; }
.table-wrap table.num { min-width: 520px; }

/* Inspections (map 11.11): Cleanliness green, Damage amber, Function red; selected button filled. */
details.area { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 0; padding: 0 12px; }
details.area > summary { padding: 12px 0; cursor: pointer; font-size: 1.02rem; }
details.area[open] > summary { border-bottom: 1px solid var(--line); }
.item { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.item:last-child { border-bottom: 0; }
.item-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.cond { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.cond button { --c: #157a3c; min-height: 36px; padding: 4px 10px; border-radius: 99px; border: 2px solid var(--c); background: transparent; color: var(--c); font: 600 .82rem var(--body); cursor: pointer; }
.cond.c-damage button { --c: #b26a00; } .cond.c-func button { --c: #b42318; }
@media (prefers-color-scheme: dark) { .cond button { --c: #6fd69a; } .cond.c-damage button { --c: #f2c464; } .cond.c-func button { --c: #ff8a80; } }
.cond button.on { background: var(--c); color: #fff; }
@media (prefers-color-scheme: dark) { .cond button.on { color: #0b1620; } }
.item textarea { min-height: 38px; margin-top: 4px; }
.thumbs figcaption { color: var(--muted); }
img.preview { width: 100%; border-radius: 8px; }
.mrow { display: grid; grid-template-columns: 84px 1fr; gap: 12px; align-items: start; }
.mthumb { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: .7rem; text-align: center; background: var(--tint); color: var(--muted); }
table.cmp tr.changed td { background: var(--warn-bg); }
.cmp-photo { width: 120px; border-radius: 6px; display: block; margin-top: 4px; }
