/* Mini Storage Guru – large, high-contrast, touch-first styles.
   Rules: >=56px touch targets, ~20px body text, words always accompany colour, no hover-only actions. */
:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --ink: #15171a;
  --ink-2: #3d434b;
  --line: #b9b3a6;
  --brand: #0d4f8b;
  --brand-ink: #ffffff;
  --focus: #ffb000;
  --ok: #1b6e3a;      /* vacant / success */
  --ok-bg: #dff2e5;
  --occ: #1d4f91;     /* occupied */
  --occ-bg: #dce8f8;
  --warn: #8a5300;    /* move-out / past due */
  --warn-bg: #fff0cc;
  --turn: #5b3b8c;    /* turnover */
  --turn-bg: #ece3f8;
  --bad: #a3141e;     /* late / out of service / error */
  --bad-bg: #fde2e2;
  --muted-bg: #e9e5dc;
  --radius: 14px;
  --tap: 56px;
  font-size: 20px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 1rem; line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--brand); }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.6rem; margin: .2rem 0 .8rem; line-height: 1.2; }
h2 { font-size: 1.3rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: 1.1rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0 .8rem; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* ---------- Top bar: Home, Back, property ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--brand); color: var(--brand-ink);
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.topbar .navbtn {
  min-height: var(--tap); min-width: 92px; padding: 0 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: #fff; color: var(--brand); border: 0; border-radius: 12px;
  font-size: 1.05rem; font-weight: 700; text-decoration: none; cursor: pointer;
}
.topbar .propname {
  flex: 1 1 auto; min-width: 0; font-weight: 800; font-size: 1.15rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .propname small { display: block; font-weight: 500; font-size: .8rem; opacity: .9; }
.topbar .propname a { color: #fff; }

.statusbar { display: flex; gap: 8px; flex-wrap: wrap; flex-basis: 100%; font-size: .9rem; }
.statusbar:empty { display: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-weight: 700; border: 2px solid currentColor; background: #fff; }
.pill.offline { color: var(--bad); background: var(--bad-bg); }
.pill.pending { color: var(--warn); background: var(--warn-bg); }
.pill.demo { color: var(--turn); background: var(--turn-bg); }

main { max-width: 1100px; margin: 0 auto; padding: 14px 14px 80px; }

/* ---------- Tiles (POS style) ---------- */
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); margin: 10px 0 18px; }
.tile {
  min-height: 128px; padding: 18px; border-radius: 18px;
  display: flex; flex-direction: column; justify-content: center; gap: 6px;
  background: var(--surface); color: var(--ink); text-decoration: none;
  border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  font-size: 1.35rem; font-weight: 800; line-height: 1.2;
}
.tile .tile-sub { font-size: .9rem; font-weight: 500; color: var(--ink-2); }
.tile .tile-icon { font-size: 2rem; line-height: 1; }
.tile:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.tile.t-blue { background: var(--occ-bg); border-color: var(--occ); box-shadow: 0 3px 0 var(--occ); }
.tile.t-green { background: var(--ok-bg); border-color: var(--ok); box-shadow: 0 3px 0 var(--ok); }
.tile.t-amber { background: var(--warn-bg); border-color: var(--warn); box-shadow: 0 3px 0 var(--warn); }
.tile.t-red { background: var(--bad-bg); border-color: var(--bad); box-shadow: 0 3px 0 var(--bad); }
.tile.t-purple { background: var(--turn-bg); border-color: var(--turn); box-shadow: 0 3px 0 var(--turn); }
.tile .count { display: inline-block; margin-left: 6px; padding: 0 10px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 1rem; }
.tiles.small .tile { min-height: 84px; font-size: 1.1rem; }

/* ---------- Buttons & forms ---------- */
.btn {
  min-height: var(--tap); padding: 10px 22px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 1.05rem; font-weight: 700; text-decoration: none; cursor: pointer;
  border: 3px solid var(--brand); background: var(--brand); color: #fff;
  -webkit-appearance: none; appearance: none;
}
.btn.secondary { background: #fff; color: var(--brand); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.good { background: var(--ok); border-color: var(--ok); }
.btn.big { min-height: 72px; font-size: 1.25rem; width: 100%; }
.btn[disabled], .btn.is-busy { opacity: .6; cursor: progress; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 14px 0; }
.btn-row > .btn { flex: 1 1 220px; }
.btn-col { display: grid; gap: 12px; margin: 14px 0; }

form p, .field { margin: 0 0 16px; }
label, .label { display: block; font-weight: 700; margin-bottom: 6px; }
.help { display: block; font-size: .85rem; color: var(--ink-2); margin-top: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password],
input[type=date], input[type=search], input:not([type]), select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 14px; font-size: 1.1rem;
  border: 2px solid var(--ink-2); border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 120px; }
input.money { font-size: 1.6rem; font-weight: 700; max-width: 320px; }
.checkline { display: flex; align-items: center; gap: 12px; min-height: var(--tap); font-weight: 600; }
.checkline input { width: 32px; height: 32px; flex: none; }
.choice-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); }
.choice-grid label {
  min-height: 64px; display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin: 0;
  border: 3px solid var(--ink-2); border-radius: 12px; background: #fff; cursor: pointer; font-size: 1.1rem;
}
.choice-grid input { width: 28px; height: 28px; flex: none; }
.choice-grid label:has(input:checked) { border-color: var(--brand); background: var(--occ-bg); box-shadow: inset 0 0 0 2px var(--brand); }
.errorlist, .form-error { color: var(--bad); background: var(--bad-bg); border-left: 6px solid var(--bad); padding: 8px 12px; list-style: none; margin: 6px 0 12px; font-weight: 600; }

/* ---------- Messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 12px; }
.msg { padding: 14px 16px; border-radius: 12px; margin-bottom: 10px; font-weight: 700; border-left: 8px solid; }
.msg.success { background: var(--ok-bg); border-color: var(--ok); }
.msg.error { background: var(--bad-bg); border-color: var(--bad); }
.msg.warning, .msg.info { background: var(--warn-bg); border-color: var(--warn); }

/* ---------- Cards / lists ---------- */
.card { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; }
.card.alert { border-color: var(--bad); background: var(--bad-bg); }
.card.notice { border-color: var(--warn); background: var(--warn-bg); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { font-weight: 700; color: var(--ink-2); }
.kv dd { margin: 0; }
.big-number { font-size: 1.8rem; font-weight: 800; }
.list { list-style: none; padding: 0; margin: 0; }
.list > li { border-bottom: 2px solid var(--muted-bg); }
.list > li:last-child { border-bottom: 0; }
.row-link {
  display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 10px 6px;
  text-decoration: none; color: var(--ink);
}
.row-link .main { flex: 1 1 auto; min-width: 0; }
.row-link .main strong { display: block; font-size: 1.1rem; }
.row-link .chev { font-size: 1.6rem; color: var(--ink-2); }
.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.stat { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat .n { font-size: 1.7rem; font-weight: 800; display: block; }
.stat .d { font-size: .8rem; color: var(--ink-2); }

table.data { width: 100%; border-collapse: collapse; background: #fff; font-size: .95rem; }
table.data th, table.data td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { background: var(--muted-bg); }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Status chips (always words + colour + shape) ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 8px; font-size: .85rem; font-weight: 800; letter-spacing: .02em; border: 2px solid; white-space: normal; max-width: 100%; }
.chip.vacant { color: var(--ok); background: var(--ok-bg); }
.chip.occupied { color: var(--occ); background: var(--occ-bg); }
.chip.moveout { color: var(--warn); background: var(--warn-bg); }
.chip.turnover { color: var(--turn); background: var(--turn-bg); }
.chip.late, .chip.oos, .chip.bad { color: var(--bad); background: var(--bad-bg); }
.chip.issue, .chip.pastdue, .chip.recovery, .chip.task { color: var(--warn); background: var(--warn-bg); border-style: dashed; }
.chip.current, .chip.good { color: var(--ok); background: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }

/* ---------- Map ---------- */
.map-toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.map-toolbar .btn { flex: 1 1 0; min-width: 0; padding: 8px 10px; }
.filter-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.filter-grid a { min-height: 52px; padding: 8px 16px; display: inline-flex; align-items: center; border: 3px solid var(--ink-2); border-radius: 12px; text-decoration: none; color: var(--ink); background: #fff; font-weight: 700; }
.filter-grid a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.map-frame {
  position: relative; width: 100%; aspect-ratio: var(--ar, 16 / 10); max-height: 75vh; min-height: 320px; background: #e6e2d6;
  border: 3px solid var(--ink-2); border-radius: var(--radius); overflow: hidden;
  touch-action: pan-y; /* up/down swipes scroll the page; sideways drags and the arrow buttons move the map */
}
.map-frame svg { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; }
.map-hint { font-size: .85rem; color: var(--ink-2); }
svg .u rect { stroke: #111; stroke-width: .6; }
svg .u.vacant rect { fill: #9fdcb2; }
svg .u.occupied rect { fill: #a9c6ef; }
svg .u.moveout rect { fill: #ffd27a; }
svg .u.turnover rect { fill: #cdb6ef; }
svg .u.dim { opacity: .25; }
svg .u.sel rect { stroke: #ff7a00; stroke-width: 1.6; }
svg .u text { font-weight: 800; fill: #111; pointer-events: none; }
svg .u .badge { fill: #a3141e; }
svg .u .hatch { fill: url(#hatch); pointer-events: none; }
svg .feat rect { fill: #cfc8b8; stroke: #6d665a; stroke-width: .5; stroke-dasharray: 2 1; }
svg .feat.drive rect { fill: #bdb9b0; stroke: none; }
svg .feat.office rect { fill: #f5e7c4; }
svg .feat text { fill: #3d3a33; font-weight: 700; pointer-events: none; }
.legend { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); font-size: .9rem; }
.legend .sw { display: inline-block; width: 30px; height: 22px; border: 2px solid #111; vertical-align: middle; margin-right: 8px; border-radius: 3px; }

/* ---------- Photos ---------- */
.photo-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.photo-grid figure { margin: 0; background: #fff; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; }
.photo-grid img { width: 100%; height: 130px; object-fit: cover; display: block; }
.photo-grid figcaption { padding: 6px 8px; font-size: .8rem; }
.upload-preview img { max-width: 100%; max-height: 50vh; border-radius: 12px; border: 2px solid var(--line); }
.upload-state { padding: 12px 16px; border-radius: 12px; font-weight: 800; margin: 10px 0; border-left: 8px solid; }
.upload-state.pending { background: var(--warn-bg); border-color: var(--warn); }
.upload-state.saved { background: var(--ok-bg); border-color: var(--ok); }
.upload-state.failed { background: var(--bad-bg); border-color: var(--bad); }
progress { width: 100%; height: 24px; }

/* ---------- Walk ---------- */
.walk-panel { margin: 12px 0; }
.walk-panel > summary { list-style: none; width: 100%; }
.walk-panel > summary::-webkit-details-marker { display: none; }
.walk-panel[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.walk-panel > form.card { border-top-left-radius: 0; border-top-right-radius: 0; margin-top: 0; }
.walk-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.walk-unit { font-size: 2.6rem; font-weight: 900; line-height: 1; }
.progressbar { height: 18px; background: var(--muted-bg); border-radius: 999px; overflow: hidden; border: 2px solid var(--line); }
.progressbar > span { display: block; height: 100%; background: var(--ok); }

/* ---------- Receipt print ---------- */
@media print {
  .topbar, .statusbar, .no-print, .btn-row, nav { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  main { padding: 0; }
  .card { border: 0; padding: 0; }
  .qr-sheet { gap: 0; }
}
.qr-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.6in, 1fr)); gap: 12px; }
.qr-label { border: 2px dashed #999; border-radius: 8px; padding: 10px; text-align: center; page-break-inside: avoid; background: #fff; }
.qr-label img { width: 1.6in; height: 1.6in; image-rendering: pixelated; }
.qr-label .qn { font-size: 26pt; font-weight: 900; line-height: 1.1; }
.qr-label .qp { font-size: 11pt; }

@media (max-width: 520px) {
  .filter-grid a { min-height: 48px; padding: 6px 12px; font-size: .95rem; }
  :root { font-size: 19px; }
  .topbar .navbtn { min-width: 76px; padding: 0 12px; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dt { margin-top: 8px; }
}


/* ---------- Touch-size and safe-area fixes (v1.0.5) ---------- */
.topbar { padding-left: calc(12px + env(safe-area-inset-left)); padding-right: calc(12px + env(safe-area-inset-right)); }
main { padding-left: calc(14px + env(safe-area-inset-left)); padding-right: calc(14px + env(safe-area-inset-right)); }
.propbtn { display: inline-flex; align-items: center; gap: 6px; min-height: 56px; padding: 0 14px; margin-top: 4px;
  border-radius: 12px; background: rgba(255,255,255,.15); color: #fff; border: 2px solid rgba(255,255,255,.6);
  font-weight: 700; font-size: 1rem; text-decoration: none; }
details > summary { min-height: 56px; display: flex; align-items: center; cursor: pointer; padding: 6px 0; }
.filter-grid a { min-height: 56px; }
@media (max-width: 520px) { .filter-grid a { min-height: 56px; } }
.statusbar .btn { min-height: 56px; }
/* Links inside text and tables get a finger-sized hit area */
main p a:not(.btn), main td a:not(.btn), main dd a:not(.btn), main li > a:not(.btn):not(.row-link):not(.tile), .card > a:not(.btn) {
  display: inline-block; padding: 14px 4px; margin: -8px 0; }
.map-pan { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0; }
.map-pan .btn { min-height: 56px; padding: 6px; }
@media print { .messages, .statusbar { display: none !important; } }
.topbar .propname { overflow: visible; white-space: normal; }
