/* Same vocabulary as the other apps on the box — cards, rows, tags, tabs, metric
 * tiles — so moving between them doesn't feel like moving between products.
 *
 * What's new here is the calendar and the property cards. Both are drawn with
 * plain CSS grid and no library: the calendar is a 7-column grid whose cells
 * carry a background band, and a run of booked nights reads as one bar because
 * only the ends of the run get a border radius.
 */
:root {
  --bg: #0f1317;
  --card: #171c22;
  --card-2: #20272f;
  --line: #2b333c;
  --text: #e9edf2;
  --dim: #929ba7;
  --accent: #6fa8ff;
  --spot: #d4b25a;
  --good: #4ade80;
  --warm: #ffb340;
  --bad: #ff6b6b;
  --radius: 14px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7f8; --card: #fff; --card-2: #eef1f4; --line: #dee3e9;
    --text: #14181d; --dim: #64707e; --accent: #2b62d4; --spot: #8a6d13;
    --good: #17803d; --warm: #b8730f; --bad: #d43f3f;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

/* Room for the tab bar, which is fixed over the bottom of the page. */
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 14px calc(76px + env(safe-area-inset-bottom));
}
/* The login pages have no tab bar, so they get the space back and sit narrower. */
main.narrow { max-width: 400px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
body.plain main { padding-top: 6vh; }

/* A laptop has room for the place and the calendar at once; a phone never will.
 *
 * main goes where the other apps on the box go, so moving between them on the
 * same screen does not feel like changing products. What the width is FOR here
 * is the places grid and the stay lists — this app has no wide table.
 *
 * The calendar is the exception and it is worth spelling out. A month grid is
 * seven square cells across (.cal-day is aspect-ratio: 1), so width does not
 * make it more readable, it makes it TALLER — at 1,052px the cells are 150px
 * and August does not fit on a 900px screen at all. So the calendar is capped
 * near the size it already had and the width goes to what sits beside it.
 *
 * Below 900 nothing changes, and the login pages keep their own 400px. */
@media (min-width: 900px) {
  main { max-width: 1080px; }

  /* Three places side by side rather than three banners stacked down a page.
     A property card is a photograph with a caption, which is the one thing on
     the box that genuinely wants to be in a grid. auto-fit so it is two across
     at 900 and three by the time there is room for three, without a second
     breakpoint to keep in step. */
  .places { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

  /* See the note above: capped, not stretched. 660 keeps a day cell at about
     the 90px it has on a tablet, which is a comfortable tap target and still
     lets a whole month sit above the fold. */
  .cal { max-width: 660px; }

  /* The calendar and what is coming up, side by side — the question this page
     answers is "who is where", and on a laptop both halves of the answer fit
     on one screen. The calendar column is the wider one because it is a fixed
     grid and the list beside it will take whatever it is given.
     align-items: start so the short column does not stretch to match the tall
     one and leave a card with a long empty tail. */
  .split { display: grid; grid-template-columns: 1.7fr 1fr; gap: 12px; align-items: start; }
  .split > .card { margin-bottom: 0; }
}

a { color: inherit; text-decoration: none; }
h2 { margin: 0 0 10px; font-size: 13px; color: var(--dim); font-weight: 600;
     text-transform: uppercase; letter-spacing: .06em; }
h3 { margin: 16px 0 6px; font-size: 14px; font-weight: 600; }
h2.bad { color: var(--bad); }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace;
       background: var(--card-2); padding: 1px 5px; border-radius: 5px; }

.num, .money, td.num, .amount { font-variant-numeric: tabular-nums; }
.pos, .good { color: var(--good); }
.neg, .bad { color: var(--bad); }
.flat, .dim { color: var(--dim); }
.centred { text-align: center; }

/* ----------------------------------------------------------------- tabbar */

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: flex; background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; display: grid; gap: 2px; place-items: center;
  padding: 8px 2px 7px; font-size: 10.5px; color: var(--dim); letter-spacing: .01em;
}
.tabs a svg {
  width: 23px; height: 23px; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.tabs a.on { color: var(--accent); }

/* ---------------------------------------------------------------- topbar */

.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 0 14px; }
.topbar .title { flex: 1; min-width: 0; }
.topbar h1 { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: -.015em;
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .sub, .sub { color: var(--dim); font-size: 13px; margin: 2px 0 0; }
.topbar .nav {
  flex: 0 0 42px; height: 42px; display: grid; place-items: center;
  font-size: 22px; line-height: 1; color: var(--dim);
  background: var(--card); border-radius: var(--radius);
  border: 0; font-family: inherit; cursor: pointer; padding: 0;
}
.topbar .nav.word { flex: 0 0 auto; font-size: 14px; font-weight: 550; padding: 0 14px; }

/* ------------------------------------------------------------------ login */

.hello { text-align: center; padding: 8px 0 20px; }
.hello .mark { font-size: 46px; line-height: 1; }
.hello h1 { margin: 10px 0 2px; font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
.hello .sub { margin: 0; }

/* Wide, spaced and monospaced. Six digits typed on a phone want to look like
   six digits, not like a name field. */
.code-input {
  font: 600 26px/1 ui-monospace, SFMono-Regular, Menlo, monospace !important;
  letter-spacing: .35em; text-align: center; padding: 16px 12px !important;
}
.code-input::placeholder { letter-spacing: .35em; opacity: .3; }

/* ---------------------------------------------------------------- metrics */

.metrics {
  display: grid; gap: 8px; margin-bottom: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.metric { background: var(--card); border-radius: var(--radius); padding: 12px 14px; }
.metric .label { color: var(--dim); font-size: 12px; text-transform: uppercase;
                 letter-spacing: .05em; font-weight: 600; }
.metric .value { font-size: clamp(17px, 5.2vw, 22px); font-weight: 650;
                 letter-spacing: -.02em; margin-top: 4px; white-space: nowrap;
                 font-variant-numeric: tabular-nums; }
@media (min-width: 460px) { .metric .value { font-size: 22px; } }
.metric .note { color: var(--dim); font-size: 12px; margin-top: 3px; }

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card .head { display: flex; align-items: baseline; gap: 10px; }
.card .head h2 { flex: 1; }
.card .head a { color: var(--accent); font-size: 13px; }

details.fold { padding: 0; }
details.fold > summary {
  padding: 14px; cursor: pointer; font-size: 13px; color: var(--dim);
  font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
}
details.fold[open] > summary { padding-bottom: 4px; }
details.fold > *:not(summary) { padding: 0 14px; }
details.fold > *:last-child { margin-bottom: 14px; }

.divider { height: 1px; background: var(--line); margin: 14px 0; }
.empty { color: var(--dim); text-align: center; padding: 22px 12px; margin: 0; }

.banner { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px;
          background: var(--card); font-size: 14px; }
.banner.good { color: var(--good); }
.banner.warm { color: var(--warm); box-shadow: inset 0 0 0 1px var(--warm); }
.banner.bad { color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
.banner p { margin: 0 0 6px; }
.banner p:last-child { margin: 0; }
.banner a { color: inherit; text-decoration: underline; }

.snippet {
  background: var(--card-2); border-radius: 10px; padding: 10px 12px; margin: 8px 0 0;
  font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}

/* ---------------------------------------------------------------- places */

/* The property cards on the home page. A photo, then everything else. */
.places { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 12px; }
.place { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.place.off { opacity: .62; }
.place .shot {
  width: 100%; height: 178px; object-fit: cover; display: block;
  background: var(--card-2);
}
.place .shot.empty {
  display: grid; place-items: center; font-size: 40px;
  background: linear-gradient(150deg, var(--tint, var(--accent)) -60%, var(--card-2) 65%);
}
.place-body { padding: 12px 14px 14px; }
.place-head { display: flex; align-items: baseline; gap: 8px; }
.place-head h3 { margin: 0; font-size: 17px; font-weight: 620; flex: 1; min-width: 0;
                 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place .sub { margin: 2px 0 0; }
.place .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
               font-size: 13px; color: var(--dim); margin: 8px 0 0; }
.place .price { color: var(--text); font-weight: 600; }
.place .meta.dim { margin-top: 4px; font-size: 12.5px; }

/* A horizontal strip of photos on the property page. Scrolls sideways rather
   than stacking, so the page below stays reachable on a phone. */
.shots {
  display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory; margin: 0 -14px 12px; padding: 0 14px;
  scrollbar-width: none;
}
.shots::-webkit-scrollbar { display: none; }
.shots figure { margin: 0; flex: 0 0 86%; scroll-snap-align: center; }
.shots img {
  width: 100%; height: 220px; object-fit: cover; display: block;
  border-radius: var(--radius); background: var(--card-2);
}
.shots figcaption { font-size: 12px; color: var(--dim); margin-top: 5px; }
@media (min-width: 560px) { .shots figure { flex: 0 0 58%; } }

/* ------------------------------------------------------------------ rows */

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.row.faded { opacity: .55; }
.row .body { flex: 1; min-width: 0; display: grid; gap: 3px; }
.row .label { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
             font-size: 12.5px; color: var(--dim); }
.row .amount { flex: 0 0 auto; text-align: right; font-variant-numeric: tabular-nums;
               font-weight: 600; }
.row .amount small { display: block; font-weight: 400; font-size: 11.5px; }
.row + .row { border-top: 1px solid var(--line); }

/* The coloured pip that says which property a row is about. */
.dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 99px; background: var(--accent); }

/* Initials, where a photo would be on a real product. */
.who {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 99px;
  display: grid; place-items: center; background: var(--card-2);
  font-size: 12.5px; font-weight: 650; color: var(--dim); letter-spacing: .02em;
}

.thumb {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 10px;
  background: var(--card-2) center/cover no-repeat; border: 1px solid var(--line);
}
.thumb.empty { display: grid; place-items: center; font-size: 18px; }

/* -------------------------------------------------------------- controls */

.btn {
  flex: 1; min-height: 48px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  border-radius: 10px; font: inherit; font-weight: 550; padding: 0 14px;
  user-select: none; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #04122b; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn.danger { color: var(--bad); background: transparent; }
.btn.ghost { background: transparent; color: var(--dim); }
.btn.small { min-height: 36px; font-size: 13px; padding: 0 12px; flex: 0 0 auto; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.btn-row .btn { flex: 1 1 120px; }
.btn-row form { display: contents; }

@media (prefers-color-scheme: light) { .btn.primary { color: #fff; } }

.hint { color: var(--dim); font-size: 13px; margin: 6px 0 0; }
.hint.warm { color: var(--warm); }
.hint b { color: var(--text); }

.range { display: flex; gap: 0; background: var(--card-2); border-radius: 10px;
         padding: 3px; border: 1px solid var(--line); margin-bottom: 12px; }
.range a {
  flex: 1; text-align: center; color: var(--dim); font-size: 13px; font-weight: 550;
  padding: 8px 4px; border-radius: 8px;
}
.range a.on { background: var(--card); color: var(--text); }

.search { display: grid; gap: 8px; margin-bottom: 14px; }
.search input[type=search] {
  width: 100%; border: 1px solid var(--line); background: var(--card);
  color: var(--text); border-radius: 10px; padding: 12px; font: inherit; min-height: 46px;
}
.filters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
           margin: 0 -14px 12px; padding: 0 14px; }
.filters::-webkit-scrollbar { display: none; }
.filters select { flex: 0 0 auto; }

/* A property pill on the calendar page. */
.chip {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 99px;
  padding: 8px 13px; font-size: 13px; color: var(--dim); white-space: nowrap;
}
.chip.on { color: var(--text); border-color: var(--accent); }
.chip i { width: 8px; height: 8px; border-radius: 99px; }

select, input[type=date], input[type=month] {
  min-width: 0; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 10px; font: inherit; min-height: 46px;
  -webkit-appearance: none; appearance: none;
}

/* ------------------------------------------------------------------ tags */

.tag {
  font-size: 11px; padding: 1.5px 8px; border-radius: 99px;
  background: var(--card-2); color: var(--dim); white-space: nowrap;
}
.tag.warm { color: var(--warm); }
.tag.bad { color: var(--bad); }
.tag.good { color: var(--good); }
.tag.action { color: var(--accent); }

/* ----------------------------------------------------------------- forms */

.stack { display: grid; gap: 12px; }
.stack > .card { margin: 0; }
.card .stack { gap: 10px; }

/* minmax(0,1fr) rather than the default auto: a date input's intrinsic width is
   around 170px, and two side by side would push the page wider than the phone. */
label { display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px;
        font-size: 13px; color: var(--dim); }
label > input:not([type=checkbox]):not([type=radio]), label > textarea, label > select,
.stack > input:not([type=checkbox]):not([type=radio]), .stack > select, .stack > textarea {
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  border-radius: 10px; padding: 12px; font: inherit; min-height: 48px; width: 100%;
}
label > textarea, .stack > textarea { min-height: 72px; resize: vertical; }
label > input:focus, label > textarea:focus, label > select:focus {
  outline: 2px solid var(--accent); outline-offset: -1px;
}
input[inputmode=decimal], input[type=number] { font-variant-numeric: tabular-nums; }
.narrow-field { max-width: 160px; }

.pair { display: flex; gap: 10px; flex-wrap: wrap; }
.pair > label { flex: 1 1 140px; min-width: 0; }

.check { display: flex; gap: 10px; align-items: flex-start; color: var(--text);
         font-size: 14px; padding: 4px 0; }
.check input[type=checkbox], .check input[type=radio] {
  flex: 0 0 auto; width: 20px; height: 20px; min-height: 0; padding: 0;
  margin: 2px 0 0; accent-color: var(--accent);
}
.check .meta { display: block; color: var(--dim); font-size: 12px; margin-top: 2px; }

.file input[type=file] { font-size: 13px; color: var(--dim); }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.facts dt { color: var(--dim); }
.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.facts dt.total, .facts dd.total { font-weight: 650; color: var(--text);
                                   border-top: 1px solid var(--line); padding-top: 7px; margin-top: 1px; }

.prose { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.prose.dim { color: var(--dim); font-size: 14px; }

.inline-form { margin: 0; }
.danger-form { margin-top: 22px; }
.busy { opacity: .5; pointer-events: none; }

.quote .facts { font-size: 15px; }

/* --------------------------------------------------------------- gallery */

.gallery { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.gallery figure { margin: 0; position: relative; }
.gallery img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card-2);
}
.gallery .flag {
  position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.62); color: #fff;
  font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 6px;
}
.gallery .acts { display: flex; gap: 8px; margin-top: 4px; }
.gallery .acts button {
  background: none; border: 0; padding: 0; font-size: 12px; color: var(--dim);
  cursor: pointer; min-height: 0; text-decoration: underline;
}
.gallery .acts button.danger { color: var(--bad); }
.caption-input {
  width: 100%; margin-top: 4px; border: 1px solid var(--line); background: var(--card-2);
  color: var(--text); border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 12px;
}

/* -------------------------------------------------------------- calendar */

.cal + .cal { margin-top: 18px; }

.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cal-head b { flex: 1; text-align: center; font-size: 14px; font-weight: 600; }
.cal-head .step {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--card-2); border-radius: 9px; color: var(--dim); font-size: 19px;
}

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-wd {
  text-align: center; font-size: 10.5px; color: var(--dim); font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; padding-bottom: 4px;
}

/* A cell is a positioned box; the band is an absolutely-positioned child that
   bleeds into the 2px gap on both sides, so consecutive booked nights join up
   into one continuous bar. Only the first and last night of a run get a
   radius — which is what makes a stay read as a stay. */
.cal-day {
  position: relative; aspect-ratio: 1; display: grid; place-items: center;
  font-size: 13px; font-variant-numeric: tabular-nums;
}
.cal-day .n { position: relative; z-index: 1; }
.cal-day a.n { display: grid; place-items: center; width: 100%; height: 100%; }
.cal-day.outside { opacity: .22; }
.cal-day.past .n { color: var(--dim); }
.cal-day.weekend .n { font-weight: 600; }
.cal-day.today .n {
  outline: 1.5px solid var(--accent); outline-offset: 3px; border-radius: 99px;
}

.cal-day .fill {
  position: absolute; inset: 3px -2px; background: var(--fill, var(--accent));
  opacity: .30;
}
.cal-day .fill.start { left: 3px; border-radius: 99px 0 0 99px; }
.cal-day .fill.end { right: 3px; border-radius: 0 99px 99px 0; }
.cal-day .fill.start.end { border-radius: 99px; }
/* A request is drawn hollow: it holds the dates, but it is not settled yet and
   the calendar should not claim it is. */
.cal-day .fill.pending {
  opacity: 1; background: none;
  box-shadow: inset 0 0 0 1.5px var(--fill, var(--accent));
}
.cal-day .fill.blocked {
  opacity: 1;
  background: repeating-linear-gradient(-45deg,
    var(--line) 0 4px, transparent 4px 8px);
}

.cal-day .dots { position: absolute; bottom: 2px; display: flex; gap: 2px; z-index: 1; }
.cal-day .dots i { width: 4px; height: 4px; border-radius: 99px; }

.cal-key { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px;
           color: var(--dim); margin: 12px 0 0; }
.cal-key i { display: inline-block; width: 14px; height: 8px; border-radius: 99px;
             margin-right: 5px; vertical-align: middle; }
.cal-key .k-free { background: var(--card-2); }
.cal-key .k-booked { background: var(--fill, var(--accent)); opacity: .45; }
.cal-key .k-pending { box-shadow: inset 0 0 0 1.5px var(--fill, var(--accent)); }
.cal-key .k-blocked {
  background: repeating-linear-gradient(-45deg, var(--line) 0 4px, transparent 4px 8px);
}
