:root {
  /* Brand colours from the Rodenburg Properties business card: navy-to-blue with gold. */
  --brand: #13124a;
  --brand-2: #2b29a8;
  --accent: #f8d848;
  --brand-grad: linear-gradient(160deg, #05050f 0%, #13124a 55%, #2f2cbf 100%);
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f8f9f7;
  --line: #e2e5df;
  --text: #1c2420;
  --muted: #66706b;
  --ok: #1e8e5a;
  --ok-bg: #e5f5ec;
  --warn: #b7791f;
  --warn-bg: #fdf3dc;
  --bad: #c0392b;
  --bad-bg: #fbe9e7;
  --info: #2563eb;
  --info-bg: #e8effd;
  --owner: #6d28d9;
  --owner-bg: #f1eafd;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 52, 43, .06), 0 4px 14px rgba(20, 52, 43, .06);
  --nav-w: 232px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--brand-2); }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: .98rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.boot { padding: 40vh 0 0; text-align: center; color: var(--muted); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }
.sidenav { background: var(--brand-grad); color: #e3e3f5; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.brandmark { display: block; padding: 0 2px 14px; color: #fff; text-decoration: none; }
.brandmark img { display: block; width: 100%; height: auto; border-radius: 10px; }
.brandmark span { display: block; margin-top: 8px; padding-left: 6px; font-size: .72rem; color: var(--accent); text-transform: uppercase; letter-spacing: .1em; }
.logo-banner { display: block; width: 100%; height: auto; border-radius: 12px; margin-bottom: 14px; }
.topbar .mark { width: 30px; height: 30px; border-radius: 50%; flex: none; }
.navlabel { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: #a9a8e6; padding: 14px 10px 6px; }
.navlabel.owner { color: var(--accent); }
.navlink { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #e3e3f5; text-decoration: none; font-size: .94rem; }
.navlink:hover { background: rgba(255, 255, 255, .07); }
.navlink.active { background: rgba(248, 216, 72, .18); color: #fff; }
.navlink .ico { width: 20px; text-align: center; opacity: .9; }
.navlink .count { margin-left: auto; background: var(--bad); color: #fff; border-radius: 10px; font-size: .72rem; padding: 1px 7px; }
.navfoot { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255, 255, 255, .1); font-size: .85rem; }
.navfoot .who { color: #fff; font-weight: 600; }
.main { min-width: 0; padding: 22px 28px 90px; max-width: 1240px; }
.topbar { display: none; }
.tabbar { display: none; }

.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.pagehead p { margin: 0; color: var(--muted); }
.crumbs { font-size: .85rem; margin-bottom: 6px; }
.crumbs a { text-decoration: none; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.cardhead h2, .cardhead h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 1.5rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .82rem; color: var(--muted); }
.stat.bad .value { color: var(--bad); }
.stat.ok .value { color: var(--ok); }
.owner-banner { display: flex; align-items: center; gap: 8px; background: var(--owner-bg); color: var(--owner); border: 1px solid #ddd0f7; border-radius: 10px; padding: 8px 12px; font-size: .85rem; margin-bottom: 16px; }
.demo-banner { background: var(--warn-bg); color: #7a5512; border-bottom: 1px solid #f1dfb0; padding: 7px 16px; font-size: .84rem; text-align: center; }

/* ---------- lists & tables ---------- */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.row:last-child { border-bottom: 0; }
a.row:hover, button.row:hover { background: var(--surface-2); }
button.row { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; font: inherit; cursor: pointer; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .meta { font-size: .84rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.neg { color: var(--bad); }
.pos { color: var(--ok); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.overdue, .badge.high, .badge.bad { background: var(--bad-bg); color: var(--bad); border-color: #f3c9c3; }
.badge.due, .badge.medium, .badge.warn { background: var(--warn-bg); color: var(--warn); border-color: #f0dca8; }
.badge.done, .badge.ok, .badge.approved, .badge.completed, .badge.low { background: var(--ok-bg); color: var(--ok); border-color: #bfe5cf; }
.badge.info, .badge.in_progress, .badge.assigned, .badge.submitted { background: var(--info-bg); color: var(--info); border-color: #c9d8fa; }
.badge.owner { background: var(--owner-bg); color: var(--owner); border-color: #ddd0f7; }
.badge.STR { background: #e0f2fe; color: #0369a1; border-color: #bae6fd; }

/* ---------- forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; text-decoration: none; white-space: nowrap; min-height: 40px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
label.f { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
label.f > input, label.f > select, label.f > textarea { margin-top: 4px; }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--surface); border: 1px solid #cfd5cf; border-radius: 9px; padding: 9px 11px; }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(43, 41, 168, .35); border-color: var(--brand-2); }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select, .filters input { width: auto; min-width: 150px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 7px 12px; font: inherit; font-size: .85rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--brand); color: #fff; }

/* ---------- checklist runner ---------- */
.cl-section { margin-bottom: 14px; }
.cl-section > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-weight: 700; }
.cl-section[open] > summary { border-radius: var(--radius) var(--radius) 0 0; }
.cl-section > summary::-webkit-details-marker { display: none; }
.cl-items { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); background: var(--surface); }
.cl-item { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.cl-item:last-child { border-bottom: 0; }
.cl-line { display: flex; align-items: center; gap: 10px; }
.cl-line .lbl { flex: 1; }
.tri { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; flex: none; }
.tri button { border: 0; background: var(--surface); padding: 0 12px; height: 38px; font: inherit; font-size: .82rem; font-weight: 700; color: var(--muted); cursor: pointer; border-left: 1px solid var(--line); }
.tri button:first-child { border-left: 0; }
.tri button.on.ok { background: var(--ok); color: #fff; }
.tri button.on.issue { background: var(--bad); color: #fff; }
.tri button.on.na { background: #8a948f; color: #fff; }
.cl-extra { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.cl-item.issue { background: #fffaf9; }
.iconbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; height: 38px; min-width: 38px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1rem; position: relative; }
.iconbtn .n { position: absolute; top: -6px; right: -6px; background: var(--brand); color: #fff; font-size: .68rem; border-radius: 9px; padding: 0 5px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { width: 84px; height: 84px; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); position: relative; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.thumb .x { position: absolute; top: 3px; right: 3px; background: rgba(0, 0, 0, .55); color: #fff; border: 0; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; font-size: .8rem; line-height: 22px; padding: 0; }
.thumb.file { display: flex; align-items: center; justify-content: center; font-size: .75rem; text-align: center; padding: 4px; }
.progress { height: 8px; background: var(--line); border-radius: 6px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ok); }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: 14px 0 6px; display: flex; gap: 8px; justify-content: flex-end; z-index: 5; }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px; }
.cal .dow { background: var(--surface-2); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: center; padding: 6px 0; font-weight: 700; }
.cal .day { background: var(--surface); min-height: 108px; padding: 5px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.cal .day.out { background: var(--surface-2); color: #a7aeaa; }
.cal .day.today .dn { background: var(--brand); color: #fff; border-radius: 50%; }
.cal .day.sel { outline: 2px solid var(--brand-2); outline-offset: -2px; }
.cal .dn { font-size: .78rem; font-weight: 700; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.cal .ev { font-size: .72rem; line-height: 1.25; padding: 2px 5px; border-radius: 5px; color: #fff; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal .ev.done { opacity: .45; text-decoration: line-through; }
.cal .ev.owner { background: var(--owner) !important; }
.cal .more { font-size: .72rem; color: var(--muted); padding-left: 4px; }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.empty { text-align: center; padding: 28px 10px; color: var(--muted); }
.warnbox { background: var(--warn-bg); border: 1px solid #f0dca8; color: #7a5512; border-radius: 10px; padding: 10px 12px; font-size: .88rem; margin-bottom: 12px; }
.infobox { background: var(--info-bg); border: 1px solid #c9d8fa; color: #1e3a8a; border-radius: 10px; padding: 10px 12px; font-size: .88rem; margin-bottom: 12px; }
.bar { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.bar .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; height: 100%; justify-content: flex-end; }
.bar .stack { width: 100%; max-width: 34px; display: flex; gap: 2px; align-items: flex-end; height: calc(100% - 20px); }
.bar .stack i { flex: 1; border-radius: 3px 3px 0 0; min-height: 1px; }
.bar .lab { font-size: .7rem; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px); background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .9rem; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--bad); }
.modal-bg { position: fixed; inset: 0; background: rgba(15, 25, 20, .5); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 620px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal.wide { max-width: 900px; }
.modal .cardhead { position: sticky; top: -18px; background: var(--surface); padding: 6px 0; z-index: 1; }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .9); z-index: 60; display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 92vh; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--brand-grad); }
.login .panel { background: var(--surface); border-radius: 16px; padding: 26px; width: 100%; max-width: 420px; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); }
.login .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login .who { display: flex; flex-direction: column; gap: 8px; }
.login .who button { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; text-align: left; font: inherit; }
.login .who button:hover { border-color: var(--brand-2); background: var(--surface-2); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-2); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.avatar.owner { background: var(--owner); }
.avatar.vendor { background: #b45309; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .sidenav { display: none; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; background: var(--brand-grad); color: #fff; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .topbar b { font-size: .98rem; flex: 1; }
  .topbar button { background: none; border: 0; color: #fff; font-size: 1.3rem; cursor: pointer; }
  .main { padding: 16px 16px 96px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 0 7px; font-size: .68rem; color: var(--muted); text-decoration: none; position: relative; }
  .tabbar a .ico { font-size: 1.2rem; }
  .tabbar a.active { color: var(--brand); font-weight: 700; }
  .tabbar a .count { position: absolute; top: 3px; left: 54%; background: var(--bad); color: #fff; border-radius: 9px; font-size: .62rem; padding: 0 5px; }
  .cal .day { min-height: 58px; padding: 3px; }
  .cal .ev { font-size: 0; height: 6px; padding: 0; border-radius: 3px; }
  .cal .more { font-size: .62rem; }
  .cl-line { flex-wrap: wrap; }
  .cl-line .lbl { flex-basis: 100%; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dd { margin-bottom: 8px; }
  .filters select, .filters input { flex: 1; min-width: 0; }
  .hide-sm { display: none; }
  .mobile-menu { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .4); }
  .mobile-menu .sidenav { display: flex; width: 270px; height: 100%; }
}
@media print {
  .sidenav, .topbar, .tabbar, .btns, .sticky-actions, .demo-banner { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
