:root {
  /* Vermont Green Mountains theme */
  --bg: #eef2ef;
  --panel: #ffffff;
  --ink: #15241c;
  --muted: #5f7268;
  --teal: #1f5c42;        /* evergreen (primary) */
  --teal-light: #3a8c66;
  --line: #dde5e0;
  --good: #2e7d32;
  --warn: #b5651d;
  --bad: #c0392b;
  --topbar: #14402e;      /* deep evergreen */
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
  padding: 12px 18px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: linear-gradient(120deg, #14402e, #1f5c42);
  color: #fff;
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 30px; height: 30px; flex: none; }
.brand-logo { height: 24px; background: #fff; padding: 5px 9px; border-radius: 8px; max-width: 62vw; }
.brand-sub { color: #cfe6da; font-size: 13px; font-weight: 600; }
.topbar h1 { font-size: 19px; margin: 0; }

/* event-day markers on the availability calendar */
.avail-table th.eventday { box-shadow: inset 0 3px 0 #e07a3a; }
.avail-table th .evdot { color: #e07a3a; font-size: 9px; line-height: 1; }
.avail-table th .evdot-none { height: 9px; }
.lg-event { color: #e07a3a; font-weight: 600; font-size: 12px; }

/* upcoming events list */
.events-list { margin: 4px 0 14px; }
.events-list summary { cursor: pointer; font-weight: 600; color: var(--teal); padding: 6px 0; }
.events-list .ev-rows { max-height: 280px; overflow: auto; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel); }
.ev-row { display: flex; gap: 12px; align-items: baseline; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.ev-row:last-child { border-bottom: 0; }
.ev-date { color: var(--muted); white-space: nowrap; min-width: 150px; font-variant-numeric: tabular-nums; }
.ev-title { flex: 1; }
.ev-title a { color: var(--ink); }
.ev-cat { font-size: 11px; color: var(--teal); background: #e7f1ec; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
@media (max-width: 760px) {
  .ev-row { flex-wrap: wrap; gap: 4px 10px; }
  .ev-date { min-width: 0; }
}
.corr-up { color: var(--good); font-weight: 600; }

/* village map hotspots */
.map-stage.has-hotspots .map-img { cursor: default; }
.hotspot { position: absolute; transform: translate(-50%, -50%); background: rgba(20,64,46,.92);
  color: #fff; font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 999px;
  border: 2px solid #fff; cursor: pointer; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.hotspot:hover { background: var(--teal-light); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.last-run { font-size: 12px; color: #b9c6cc; }
.last-run.bad { color: #ffb4a8; }

.btn-primary {
  background: var(--teal-light); color: #07201f; border: 0;
  padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: 600;
}
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-link { color: #b9c6cc; font-size: 13px; text-decoration: none; }
.btn-link:hover { color: #fff; }

.update-status {
  margin: 12px 22px 0; padding: 8px 12px; border-radius: 6px;
  background: #eef2f3; font-size: 13px; border: 1px solid var(--line);
}
.update-status.ok  { background: #e7f5e9; border-color: #b9e0bd; }
.update-status.err { background: #fbe6e3; border-color: #f0b8b0; }

.scope-banner { margin: 12px 22px 0; padding: 8px 12px; border-radius: 6px;
  background: #e6eefb; color: #2c5fb5; border: 1px solid #c2d4f5; font-size: 13px; }

/* ---------- what's new ---------- */
.wn-build { grid-column: 1 / -1; background: #e7f1ec; border: 1px solid #b9e0cf; color: var(--teal);
  border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 4px; }
.whatsnew { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.wn-group { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.wn-group h3 { margin: 0 0 10px; font-size: 15px; color: var(--teal); }
.wn-item { padding: 10px 0; border-top: 1px solid var(--line); }
.wn-item:first-of-type { border-top: 0; }
.wn-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wn-date { font-weight: 400; font-size: 11px; color: var(--muted); margin-left: auto; white-space: nowrap; }
.wn-where { font-size: 12px; color: var(--muted); margin: 3px 0; }
.wn-verify { font-size: 13px; color: var(--ink); }

/* ---------- owners admin ---------- */
.owners-admin { display: grid; grid-template-columns: 280px 1fr; gap: 18px; align-items: start; }
.owner-list { list-style: none; margin: 12px 0 0; padding: 0; max-height: 70vh; overflow: auto;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.owner-li { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.owner-li:hover { background: #f5f9f9; }
.owner-li .small { font-size: 11px; }
.owners-form-pane { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.owners-form-pane .fld { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.owners-form-pane .fld input { display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 6px; font-size: 14px; box-sizing: border-box; }
.opt-row { display: flex; gap: 18px; margin-bottom: 12px; }
.chk { font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.unit-picker-head { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.unit-picker-head input { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; }
.unit-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 14px;
  max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.unit-opt { font-size: 13px; display: flex; align-items: center; gap: 6px; padding: 2px 0; white-space: nowrap; }
.form-actions { display: flex; align-items: center; gap: 14px; margin-top: 16px; }

/* ---------- cards ---------- */
.cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; padding: 18px 22px 4px;
}
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px;
}
.card-val { font-size: 28px; font-weight: 700; color: var(--teal); }
.card-label { font-size: 12px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .03em; }
.card.good .card-val { color: var(--good); }
.card.warn .card-val { color: var(--warn); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; padding: 14px 22px 0; border-bottom: 1px solid var(--line); }
.tab {
  background: transparent; border: 0; border-bottom: 3px solid transparent;
  padding: 10px 16px; cursor: pointer; font-size: 14px; color: var(--muted);
}
.tab.active { color: var(--ink); border-bottom-color: var(--teal-light); font-weight: 600; }

.panel { display: none; padding: 20px 22px; }
.panel.active { display: block; }

/* ---------- charts ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.chart-card h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); font-weight: 600; }
.chart-card.chart-wide { grid-column: 1 / -1; }
.chart-card.chart-wide canvas { max-height: 420px; }
#chartByProperty, #chartByPropertyRental { min-height: 360px; max-height: none !important; }

.btn-export {
  padding: 7px 12px; border: 1px solid var(--teal); border-radius: 6px;
  color: var(--teal); text-decoration: none; font-size: 13px; font-weight: 600;
}
.btn-export:hover { background: var(--teal); color: #fff; }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.filters input, .filters select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; background: #fff;
}
.filters input[type=search] { min-width: 240px; }
.row-count { font-size: 12px; color: var(--muted); margin-left: auto; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.data-table th { background: #f7f9fa; position: sticky; top: 0; cursor: pointer; user-select: none; }
.data-table th[data-sort]::after { content: ' ⇕'; color: #c2cbd1; font-size: 11px; }
.data-table th.sorted-asc::after  { content: ' ↑'; color: var(--teal); }
.data-table th.sorted-desc::after { content: ' ↓'; color: var(--teal); }
.data-table tbody tr:hover { background: #f5f9f9; }
.data-table td.num, .data-table th.num { text-align: right; }
.data-table th.num.sorted-asc::after, .data-table th.num.sorted-desc::after { margin-left: 2px; }
.data-table tr.is-cancelled { background: #fff0ee; }
.data-table tr.is-cancelled td { color: #b04040; text-decoration: line-through; }
.data-table tr.is-vacant td { color: #97a2a8; }
code.raw { font-size: 11px; color: var(--muted); white-space: normal; word-break: break-all; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.active { background: #e7f5e9; color: var(--good); }
.badge.cancelled { background: #fbe6e3; color: var(--bad); }
.badge.ev-new { background: #e7f5e9; color: var(--good); }
.badge.ev-changed { background: #fff4e0; color: var(--warn); }
.badge.ev-cancelled { background: #fbe6e3; color: var(--bad); }
.badge.ev-reappeared { background: #e6eefb; color: #2c5fb5; }
.badge.share-badge { font-size: 10px; padding: 1px 6px; }
.badge.sh-a { background: #fff4e0; color: #8a5c00; }
.badge.sh-b { background: #e6eefb; color: #2c5fb5; }
.badge.sh-c { background: #f3e6fb; color: #6a2c91; }
.cal td.share-a { background: #e3f2fd; }
.cal td.share-b { background: #e8f5e9; }
.cal td.share-c { background: #fffde7; }
.cal td.share-other { background: #d8d8d8 !important; }
.cal td.share-transition::after { display: none; }
.avail-table td.cell.share-dim { background: #d8d8d8 !important; }

.muted { color: var(--muted); }

.app-version { text-align: center; color: var(--muted); font-size: 11px; padding: 18px 12px 26px; }
.soon-tag { display: inline-block; background: #fff4e0; color: #b5651d; font-size: 10px; font-weight: 600;
  padding: 1px 7px; border-radius: 999px; vertical-align: middle; }

/* ---------- owner month calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.cal-range { display: flex; gap: 6px; }
.rangebtn { font-size: 13px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 6px;
  text-decoration: none; color: var(--teal); background: #fff; }
button.rangebtn { cursor: pointer; font: inherit; }
.rangebtn.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.cal-legend { flex-wrap: wrap; gap: 12px; }
.lg-unit { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.lg-unit .sw { width: 13px; height: 13px; border-radius: 3px; display: inline-block; }
.cal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.cal-month { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.cal-month h4 { margin: 0 0 8px; font-size: 14px; color: var(--teal); }
table.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.cal th { font-size: 10px; color: var(--muted); padding: 2px 0; font-weight: 600; }
table.cal td { height: 40px; vertical-align: top; border: 1px solid #c8ced2; padding: 2px; position: relative; }
table.cal td.empty { background: #fafbfb; border-color: #dde1e4; }
table.cal td.today { outline: 2px solid var(--teal-light); outline-offset: -2px; }
.cal .dn { font-size: 10px; color: var(--muted); }
.cal .chips { display: flex; justify-content: space-between; margin-top: 1px; }
.cal .chip-lgrp, .cal .chip-rgrp { display: flex; flex-wrap: wrap; gap: 1px; }
.cal .chip { display: inline-flex; align-items: center; justify-content: center; min-width: 13px; height: 13px;
  border-radius: 3px; color: #fff; font-size: 9px; font-weight: 700; }
.cal .chip.chip-cancelled { opacity: 0.35; text-decoration: line-through; }
@media (max-width: 760px) {
  .cal-grid { grid-template-columns: 1fr; }
  table.cal td { height: 44px; }
}

.scrape-log { background: #0d1f17; color: #cfe6da; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.5; padding: 12px 14px; border-radius: 10px; max-height: 360px;
  overflow: auto; white-space: pre-wrap; word-break: break-word; }
.report-h3 .btn-export { margin-left: 10px; font-size: 12px; }

/* ---------- owner tag ---------- */
.badge.owner-tag { background: #17252a; color: #fff; }

.inline-label { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.inline-label input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }

/* ---------- availability calendar ---------- */
.legend { display: flex; gap: 14px; align-items: center; margin: 4px 0 12px; font-size: 12px; color: var(--muted); }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.legend .lg::before { content: ''; width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.1); }
.legend .lg.owner::before { background: #2b7a78; }
.legend .lg.guest::before { background: #3aafa9; }
.legend .lg.rci::before   { background: #ef8354; }
.legend .lg.other::before { background: #bfc0c0; }
.legend .lg.free::before  { background: #eef5f4; }

.avail-wrap { overflow: auto; max-height: 74vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.avail-table { border-collapse: separate; border-spacing: 0; font-size: 11px; }
.avail-table th, .avail-table td { border-bottom: 1px solid #eef1f3; border-right: 1px solid #eef1f3; }

.avail-table thead th { position: sticky; top: 0; z-index: 2; background: #f7f9fa; padding: 4px 3px;
  text-align: center; font-weight: 600; min-width: 26px; }
.avail-table thead th.weekend { background: #eef2f3; }
.avail-table thead th .daycount { color: var(--teal); font-size: 10px; }

.avail-table th.corner { left: 0; z-index: 3; text-align: left; padding: 4px 8px; min-width: 150px; }
.avail-table th.rowhead { position: sticky; left: 0; z-index: 1; background: #fff; text-align: left;
  padding: 3px 8px; white-space: nowrap; font-weight: 600; }
.avail-table th.rowhead .rowsize { color: var(--muted); font-weight: 400; margin-left: 6px; }
.avail-table th.rowhead .owner-tag { font-size: 10px; padding: 1px 6px; }

.avail-table td.cell { width: 24px; height: 22px; }
.avail-table td.cell.free  { background: #fbfdfc; }
.avail-table td.cell.owner { background: #2b7a78; }
.avail-table td.cell.guest { background: #3aafa9; }
.avail-table td.cell.rci   { background: #ef8354; }
.avail-table td.cell.other { background: #bfc0c0; }

/* ---------- reports ---------- */
.report-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.report-head { margin-bottom: 12px; }
.report-head h2 { margin: 0 0 4px; font-size: 20px; }
.report-meta { font-size: 13px; color: var(--muted); }
.report-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 14px 0 20px; }
.report-h3 { margin: 24px 0 8px; font-size: 15px; }

.occ { position: relative; background: #eef2f3; border-radius: 4px; height: 18px; min-width: 120px; }
.occ-bar { height: 100%; border-radius: 4px; }
.occ-pct { position: absolute; top: 0; left: 6px; font-size: 11px; line-height: 18px; color: #17252a; font-weight: 600; }

/* ---------- print / PDF ---------- */
@media print {
  .topbar, .tabs, .cards, #updateStatus, .no-print, .install-banner, .scope-banner { display: none !important; }
  .panel { display: none !important; }
  .panel.active { display: block !important; padding: 0; }
  body { background: #fff; }
  /* force background colours to actually print (cells are colour-coded) */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .avail-wrap { overflow: visible !important; max-height: none !important; }
  .map-pan { position: static !important; transform: none !important; }
  .avail-table { font-size: 8px; }
  .avail-table td.cell { width: auto; height: 12px; }
  .avail-table th.rowhead { font-size: 8px; position: static; }
  .avail-table thead th { position: static; }
  .chart-card, .table-wrap, tr { break-inside: avoid; }
  .chart-card canvas { max-height: 260px; }
  .data-table th { position: static; }
  a[href]::after { content: ""; }
}

/* ---------- PWA install banner ---------- */
.install-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 12px 18px 0; padding: 10px 14px; border-radius: 10px;
  background: #dff0e7; color: #14402e; border: 1px solid #b9e0cf; font-size: 14px;
}
.install-banner .ib-text { color: #14402e; font-weight: 500; }
.install-banner .ib-actions { display: flex; gap: 10px; align-items: center; }
.install-banner .btn-link { color: #1f5c42; }

/* ---------- maps (zoom/pan viewer) ---------- */
.map-stage { position: relative; overflow: hidden; min-height: 280px;
  background: #0d1f17; border: 1px solid var(--line); border-radius: 10px;
  touch-action: none; cursor: grab; }
.map-stage:active { cursor: grabbing; }
.map-pan { position: absolute; top: 0; left: 0; width: 100%; transform-origin: 0 0; }
.map-img { display: block; width: 100%; user-select: none; -webkit-user-drag: none; }
.map-pdf { width: 100%; height: 75vh; border: 0; border-radius: 10px; background: #fff; }
.map-empty { padding: 50px 20px; text-align: center; }

/* ---------- location map ---------- */
.locmap { width: 100%; height: 340px; border: 0; border-radius: 8px; background: var(--line); }
.map-attr { font-size: 11px; color: var(--muted); margin-top: 6px; }
.map-attr a { color: var(--teal); }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .topbar { padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
  .topbar h1 { font-size: 17px; }
  .last-run { display: none; }
  .tabs { padding: 8px 10px 0; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; padding: 10px 13px; }
  .panel { padding: 14px 12px; }
  .cards { padding: 14px 12px 4px; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); }
  .card-val { font-size: 22px; }
  .chart-grid { grid-template-columns: 1fr; }
  .owners-admin { grid-template-columns: 1fr; }
  .owner-list { max-height: 220px; }
  .unit-picker { grid-template-columns: 1fr 1fr; max-height: 240px; }
  .filters { gap: 8px; }
  .filters input[type=search], .filters input { min-width: 0; width: 100%; }
  .filters select { flex: 1 1 42%; }
  button, .btn-primary, .btn-export, .tab, .filters select, .filters input { min-height: 40px; }
  .data-table th, .data-table td { padding: 8px; }
  .scope-banner, .install-banner, .update-status { margin-left: 12px; margin-right: 12px; }
  .locmap { height: 250px; }
  .report-toolbar { flex-direction: column; align-items: flex-start; }
}

/* ---------- login ---------- */
.login-body { display: flex; justify-content: center; align-items: center; height: 100vh; background: var(--ink); }
.login-box { background: #fff; padding: 32px; border-radius: 12px; width: 300px; display: flex; flex-direction: column; gap: 12px; }
.login-box h2 { margin: 0 0 6px; }
.login-box input { padding: 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
.login-box button { padding: 10px; background: var(--teal); color: #fff; border: 0; border-radius: 6px; cursor: pointer; font-weight: 600; }
.login-error { background: #fbe6e3; color: var(--bad); padding: 8px; border-radius: 6px; font-size: 13px; }
