:root {
  --primary: #1B5E20;
  --primary-light: #E8F0E9;
  --bg: #FAF7FB;
  --card: #ECE8EE;
  --accent: #EADDFF;
  --text: #1c1b1e;
  --muted: #6b6870;
  --green: #2E7D32;
  --yellow: #F9A825;
  --red: #C62828;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  padding-bottom: env(safe-area-inset-bottom);
}
#app { max-width: 640px; margin: 0 auto; padding: 16px; }

.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 0 10px;
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.topbar h1 { font-size: 1.5rem; font-weight: 600; flex: 1; }
.icon-btn {
  border: none; background: none; font-size: 1.35rem; cursor: pointer;
  padding: 6px 10px; border-radius: 10px; color: var(--text); line-height: 1;
}
.icon-btn:active { background: var(--card); }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.card.accent { background: var(--accent); }
.card.clickable { cursor: pointer; }
.card.clickable:active { filter: brightness(0.95); }

.big-number { font-size: 2.4rem; font-weight: 700; color: var(--primary); }
.stat-row { display: flex; gap: 12px; }
.stat-row .card { flex: 1; margin-bottom: 12px; }
.stat-value { font-size: 1.7rem; font-weight: 700; color: var(--primary); }
.label { font-size: .85rem; color: var(--muted); }
.section-title { font-weight: 600; margin: 14px 0 8px; display: flex; align-items: center; }
.section-title .spacer { flex: 1; }

.btn {
  display: block; width: 100%; padding: 14px; border: none; cursor: pointer;
  border-radius: 24px; font-size: 1rem; font-weight: 600;
  background: var(--primary); color: white; margin-bottom: 10px;
}
.btn.tonal { background: var(--accent); color: var(--text); }
.btn.outline { background: none; border: 1px solid var(--muted); color: var(--red); }
.btn.small { display: inline-block; width: auto; padding: 8px 14px; font-size: .85rem; margin: 0; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: .8rem; color: var(--primary); font-weight: 600; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 13px; font-size: 1rem; font-family: inherit;
  border: 1px solid #a9a5ad; border-radius: 10px; background: white; color: var(--text);
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }

.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; flex: none; }
.dot.green { background: var(--green); } .dot.yellow { background: var(--yellow); } .dot.red { background: var(--red); }
.legend { display: flex; gap: 16px; font-size: .85rem; margin-bottom: 10px; align-items: center; }
.legend span { display: flex; align-items: center; }

.unit { display: flex; align-items: center; padding: 12px 16px; }
.unit .info { flex: 1; min-width: 0; }
.unit .name { font-weight: 600; }
.unit .status { font-size: .82rem; }
.unit .status.green { color: var(--green); } .unit .status.red { color: var(--red); }
.unit .status.yellow { color: #9a6d00; }
.unit .next { font-size: .78rem; color: var(--muted); }
.unit .price { font-weight: 600; color: var(--primary); font-size: .9rem; }

.row { display: flex; justify-content: space-between; padding: 3px 0; font-size: .95rem; }
.row .k { color: var(--muted); }
.divider { border: none; border-top: 1px solid #c9c5cd; margin: 8px 0; }
.error { color: var(--red); font-size: .9rem; margin: 8px 0; }
.hint { color: var(--muted); font-size: .82rem; text-align: center; margin-top: 12px; }
.money-due { color: var(--red); font-weight: 700; }
.money-ok { color: var(--green); font-weight: 700; }
.tel { color: var(--primary); font-weight: 600; text-decoration: none; font-size: .85rem; }

.pill { font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 12px; }
.pill.BOOKED { background: #fff3d6; color: #9a6d00; }
.pill.CHECKED_IN { background: #dcedde; color: var(--green); }
.pill.CHECKED_OUT { background: #e3e1e6; color: var(--muted); }
.pill.CANCELLED { background: #f6dcdc; color: var(--red); }

.progress { height: 6px; border-radius: 3px; background: #dcd7e0; overflow: hidden; margin: 8px 0 6px; }
.progress > div { height: 100%; background: var(--primary); }

.login-wrap { padding-top: 12vh; text-align: center; }
.login-logo { font-size: 3.4rem; }
.login-logo img { max-width: 160px; max-height: 96px; object-fit: contain; }
.login-wrap h1 { margin: 6px 0 2px; }
.login-wrap .sub { color: var(--muted); margin-bottom: 26px; }
.login-wrap form { text-align: left; }

.month-nav { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 12px; }
.month-nav h2 { font-size: 1.15rem; }

/* Filter chips on the bookings list */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid #c9c5cd; background: var(--bg); color: var(--text);
  padding: 7px 14px; border-radius: 18px; font-size: .85rem; cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 24px;
}
.modal {
  background: var(--bg); border-radius: 20px; padding: 20px; width: 100%; max-width: 420px;
  max-height: 88vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 10px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.modal .actions button {
  border: none; background: none; color: var(--primary); font-weight: 600;
  font-size: .95rem; padding: 8px 12px; cursor: pointer; border-radius: 8px;
}
.modal .actions button.danger { color: var(--red); }

.payment-line { font-size: .85rem; color: var(--muted); padding: 2px 0; }
.payment-line.refund { color: var(--red); }

/* Brief confirmation that something saved */
#toast-host {
  position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none;
}
.toast {
  background: #23212a; color: #fff; padding: 11px 18px; border-radius: 22px;
  font-size: .9rem; font-weight: 500; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  max-width: min(90vw, 420px); animation: toast-in .22s ease-out;
}
.toast.err { background: var(--red); }
.toast.leaving { opacity: 0; transition: opacity .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

#offline-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 70;
  background: var(--red); color: #fff; text-align: center;
  padding: calc(7px + env(safe-area-inset-top)) 12px 7px; font-size: .85rem; font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; transition: none; }
}

/* Activity log: a cancellation is the entry an owner most needs to notice */
.card.act-flag { border-left: 4px solid var(--red); }

/* Today's highlights: three counts side by side */
.hl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; text-align: center; }
.hl-cell .stat-value { font-size: 1.6rem; }
.hl-cell .label { font-size: .78rem; }

.table-card { padding: 8px 12px; overflow-x: auto; }
.mini-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.mini-table th { text-align: right; font-size: .75rem; color: var(--muted); font-weight: 600; padding: 6px 4px; }
.mini-table th:first-child, .mini-table td:first-child { text-align: left; }
.mini-table td { text-align: right; padding: 7px 4px; border-top: 1px solid #d6d1da; font-weight: 600; }
.mini-table td:first-child { font-weight: 500; }

/* Booking: dates first, then units */
.step { font-weight: 700; color: var(--primary); margin-bottom: 10px; }
.dt-row { display: flex; gap: 10px; }
.dt-row .field { flex: 1.4; min-width: 0; }
.dt-row .dt-time { flex: 1; }
.card.pick { cursor: pointer; border: 2px solid transparent; margin-bottom: 8px; }
.card.pick.on { border-color: var(--primary); background: var(--primary-light); }
.card.pick input { width: 20px; height: 20px; margin-right: 12px; accent-color: var(--primary); flex: none; }
.card.pick .price .label { font-weight: 400; margin-left: 2px; }
.pick-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--bg); border-top: 1px solid #d6d1da; box-shadow: 0 -4px 14px rgba(0,0,0,.08);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
  max-width: 640px; margin: 0 auto;
}
.pick-sum { flex: 1; min-width: 0; }
.pick-bar .btn { width: auto; margin: 0; padding: 12px 22px; flex: none; }

/* Booking form: extra beds, GST, the running bill */
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper input { width: 80px; text-align: center; }
.stepper .icon-btn { background: var(--accent); width: 44px; height: 44px; font-size: 1.3rem; }
.check-row { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 4px 0 14px; cursor: pointer; }
.check-row input { width: 20px; height: 20px; accent-color: var(--primary); }
.card.bill { background: var(--primary-light); }
.row.total { font-size: 1.1rem; }

/* Settings */
.logo-card { display: flex; gap: 14px; align-items: center; }
.logo-card .btn.small { margin: 0 6px 0 0; }
.logo-preview {
  width: 96px; height: 96px; flex: none; border-radius: 12px; background: white;
  display: flex; align-items: center; justify-content: center; overflow: hidden; border: 1px solid #d6d1da;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

@media (max-width: 380px) {
  .hl-cell .stat-value { font-size: 1.35rem; }
  .dt-row { gap: 8px; }
}

/* Packages and discounts */
.pkg-tag { display: inline-block; margin-top: 6px; font-size: .85rem; font-weight: 600; color: var(--primary); }
.card.pkg-card.off { opacity: .6; }
.pkg-card .btn-row .btn.small { flex: 1; }
.disc-row { display: flex; gap: 8px; }
.disc-row input { flex: 1; min-width: 0; }
.disc-row select { width: 110px; flex: none; }
.stepper .label { margin-left: 6px; }

/* Rooms setup */
.card.rs-unit { display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 8px; }
.rs-unit .info { flex: 1; min-width: 0; }
.rs-unit .name { font-weight: 600; }
.rs-actions { display: flex; gap: 6px; flex: none; }
.rs-actions .btn.small { padding: 7px 11px; }
.card.rs-unit.off { opacity: .65; }
.topbar .btn.small { flex: none; }

/* Room pictures */
.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: none; margin-right: 12px; cursor: zoom-in; background: #ddd; }
.thumb-empty { display: flex; align-items: center; justify-content: center; font-size: 1.2rem; opacity: .45; cursor: default; }
.card.pick .thumb { margin-right: 10px; }
.card.rs-unit .thumb { margin-right: 0; }
.detail-thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.detail-thumbs .thumb { width: 64px; height: 64px; margin: 0; }
.gallery-main img { width: 100%; max-height: 60vh; object-fit: contain; border-radius: 12px; background: #111; display: block; }
.gallery-strip { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; padding-bottom: 2px; }
.gal-thumb { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; cursor: pointer; opacity: .6; border: 2px solid transparent; flex: none; }
.gal-thumb.on { opacity: 1; border-color: var(--primary); }
.photo-empty { height: 140px; border-radius: 12px; border: 2px dashed #c9c5cd; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .9rem; text-align: center; padding: 10px; }
.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.photo-tile { background: var(--card); border-radius: 12px; overflow: hidden; }
.photo-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; cursor: zoom-in; }
.photo-tile-actions { display: flex; gap: 6px; padding: 8px; }
.photo-tile-actions .btn.small { flex: 1; padding: 7px 4px; }
