/* Layout: a single phone-first column (max 760px) under a slim navy header; cards per section, sticky save bar on the editor. */
:root {
  --bg: #f3f1ec;
  --surface: #ffffff;
  --ink: #141b2e;
  --soft: #5d6478;
  --line: #e2ded4;
  --navy: #0a1224;
  --gold: #c8923a;
  --gold-ink: #7a5212;
  --good: #2f8a5b;
  --bad: #b8432f;
  --field: #faf9f6;
  --display: "Gloock", Georgia, "Times New Roman", serif;
  --body: "Figtree", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #141c30; --ink: #f2ede3; --soft: #a3a9ba; --line: #263049;
    --gold: #eab866; --gold-ink: #eab866; --good: #5cc28d; --bad: #f08a7a; --field: #0f1627;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #141c30; --ink: #f2ede3; --soft: #a3a9ba; --line: #263049;
  --gold: #eab866; --gold-ink: #eab866; --good: #5cc28d; --bad: #f08a7a; --field: #0f1627;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--body); -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

.top { background: var(--navy); color: #f5eee0; padding-top: env(safe-area-inset-top, 0px); }
.top-inner {
  max-width: 760px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding-block: 14px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.logo { font-family: var(--display); font-size: 22px; color: #f5eee0; text-decoration: none; letter-spacing: 0.01em; }
.logo::before { content: ""; display: inline-block; width: 18px; height: 1px; background: #eab866; vertical-align: middle; margin-right: 10px; }
.top .link { color: rgba(245,238,224,.8); }

.wrap {
  max-width: 760px; margin: 0 auto; padding-block: 20px 120px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid; gap: 16px;
}
h1 { font-family: var(--display); font-weight: 400; font-size: 32px; line-height: 1.1; margin: 4px 0 0; text-wrap: balance; }
h2 { font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-ink); margin: 0 0 12px; }
p { margin: 0; }
.muted { color: var(--soft); font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; min-width: 0; }

label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--soft); }
input, textarea {
  font: 16px var(--body); color: var(--ink); background: var(--field);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%; min-width: 0;
}
input.big { font-size: 22px; font-weight: 600; }
input.code { font-size: 24px; letter-spacing: .25em; font-variant-numeric: tabular-nums; text-align: center; }
textarea { min-height: 150px; resize: vertical; line-height: 1.5; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.fields { display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row, .row3 { grid-template-columns: 1fr; } }

button { font: 600 15px var(--body); border-radius: 10px; padding: 11px 16px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
button.primary { background: var(--navy); color: #f5eee0; border-color: var(--navy); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) button.primary { background: var(--gold); color: #0a1224; border-color: var(--gold); } }
:root[data-theme="dark"] button.primary { background: var(--gold); color: #0a1224; border-color: var(--gold); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: transparent; }
button.link { background: none; border: 0; padding: 6px 0; color: var(--soft); font-weight: 500; }
button:disabled { opacity: .55; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Apartment list */
.units { display: grid; gap: 12px; }
.unit-link { display: grid; gap: 4px; text-decoration: none; color: inherit; }
.unit-link:hover .unit-name { text-decoration: underline; text-decoration-color: var(--gold); }
.unit-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.unit-name { font-family: var(--display); font-size: 22px; line-height: 1.2; min-width: 0; overflow-wrap: anywhere; }
.guest { font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--field); border: 1px solid var(--line); color: var(--soft); white-space: nowrap; }
.chip.on { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.chip.stay { color: var(--gold-ink); border-color: color-mix(in srgb, var(--gold) 45%, transparent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--soft); margin-right: 6px; vertical-align: 1px; }
.on .dot { background: var(--good); }

/* TVs */
.tvs { display: grid; gap: 8px; margin-bottom: 16px; }
.tv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); }
.tv-name { font-weight: 600; }
.tv-meta { font-size: 13px; color: var(--soft); }
.tv-meta.on { color: var(--good); }
.pair-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
@media (max-width: 520px) { .pair-form { grid-template-columns: 1fr; } }

/* Sticky save bar */
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: color-mix(in srgb, var(--surface) 92%, transparent); border-top: 1px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.savebar-inner {
  max-width: 760px; margin: 0 auto; display: flex; gap: 10px; justify-content: space-between; align-items: center; flex-wrap: wrap;
  padding-block: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.back { color: var(--soft); text-decoration: none; font-size: 14px; font-weight: 600; }
.error { color: var(--bad); font-size: 14px; font-weight: 600; }
.confirm { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--bad); font-size: 14px; font-weight: 600; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom, 0px)); z-index: 10;
  background: var(--navy); color: #f5eee0; padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  max-width: calc(100vw - 32px); text-align: center; box-shadow: 0 8px 30px rgba(0,0,0,.2);
}

.login { max-width: 420px; margin: 8vh auto 0; width: 100%; }
.login h1 { margin-bottom: 6px; }
.empty { text-align: center; padding: 28px 18px; color: var(--soft); }
