:root {
  --paper: #F7F2E8;
  --card: #FFFDF8;
  --ink: #14121A;
  --stone: #66605A;
  --rule: #DDD4C2;
  --saff: #FFC933;
  --saff-deep: #E8A317;
  --green: #1E7A4F;
  --red: #B3341A;
  --radius: 14px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.45 'Commissioner', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }
h1 { font-size: 1.7rem; line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 600; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--saff-deep); outline-offset: 2px; }

.boot { padding: 48px 16px; text-align: center; color: var(--stone); }

.brand { font-weight: 700; font-size: 0.95rem; letter-spacing: 0.02em; }
.brand span { background: var(--saff); padding: 1px 7px; border-radius: 6px; margin-left: 2px; }

.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card h2 { margin-bottom: 10px; }
.card-head h2 { margin-bottom: 0; }
.card-head + .seg { margin-top: 10px; }

.help { color: var(--stone); font-size: 0.92rem; margin-top: 10px; }
.note { margin: 16px 2px 0; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 50px; padding: 0 18px; width: 100%;
  border-radius: 12px; border: 1.5px solid var(--ink);
  font-weight: 600; text-decoration: none; text-align: center;
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-line { background: transparent; color: var(--ink); }
.btn-small { min-height: 44px; width: auto; padding: 0 14px; font-size: 0.95rem; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }

.link-btn, .text-link {
  background: none; border: 0; padding: 10px 0; min-height: 44px;
  color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
  display: inline-flex; align-items: center;
}

/* login */
.login { max-width: 440px; margin: 0 auto; padding: 40px 16px 48px; }
.login h1 { margin-top: 28px; }
.intro { color: var(--stone); margin-top: 8px; }
.login label { display: block; font-weight: 600; margin: 14px 0 6px; }
.login label:first-child { margin-top: 0; }
.login input, .price-form input {
  width: 100%; min-height: 50px; padding: 0 14px;
  background: #fff; border: 1.5px solid var(--rule); border-radius: 12px;
}
.login input:focus, .price-form input:focus { border-color: var(--ink); outline: none; }
.login .btn-primary { margin-top: 18px; }
.form-error { color: var(--red); font-weight: 500; font-size: 0.95rem; margin-top: 10px; }
.demo-box p { color: var(--stone); margin-bottom: 14px; }

/* app */
.app { max-width: 720px; margin: 0 auto; padding: 0 16px 64px; }
.banner {
  margin: 0 -16px; padding: 10px 16px;
  background: var(--saff); color: var(--ink); font-weight: 500; font-size: 0.95rem; text-align: center;
}
.top { padding-top: 14px; }
.top-row { display: flex; align-items: center; justify-content: space-between; }
.top h1 { margin-top: 10px; }

.status-line {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px;
  margin: 4px -16px 0; padding: 10px 16px;
  background: var(--paper); border-bottom: 1px solid var(--rule);
}
.badge {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  font-weight: 700; font-size: 0.85rem; letter-spacing: 0.02em; white-space: nowrap;
  border: 1.5px solid var(--ink);
}
.badge[data-life='selling'] { background: var(--green); border-color: var(--green); color: #fff; }
.badge[data-life='last'] { background: var(--saff); border-color: var(--saff); }
.badge[data-life='soldout'] { background: var(--ink); color: var(--paper); }
.counts { color: var(--stone); font-size: 0.92rem; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 16px; padding: 4px; background: #ECE5D6; border-radius: 12px; }
.tabs button {
  min-height: 46px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; color: var(--stone);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.tabs button[aria-selected='true'] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(20, 18, 26, 0.12); }
.pill { background: var(--ink); color: var(--paper); border-radius: 999px; font-size: 0.78rem; padding: 1px 8px; min-width: 22px; }

/* segmented control */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; border: 1.5px solid var(--rule); border-radius: 12px; overflow: hidden; background: #fff; }
.seg button {
  min-height: 48px; padding: 0 4px; border: 0; background: transparent; font-weight: 600; font-size: 0.9rem; line-height: 1.15; color: var(--stone);
  border-left: 1.5px solid var(--rule);
}
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed='true'] { color: var(--paper); background: var(--ink); }
.seg button[aria-pressed='true'][data-value='available'] { background: var(--green); color: #fff; }
.seg button[aria-pressed='true'][data-value='reserved'] { background: var(--saff); color: var(--ink); }
.seg button:focus-visible { outline-offset: -3px; }

/* units */
.floor-title {
  margin: 26px 2px 0; font-size: 0.82rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--stone);
}
.unit { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px; margin-top: 10px; }
.unit-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.unit-id { font-size: 1.3rem; font-weight: 700; margin-right: 8px; }
.unit-facts { color: var(--stone); font-size: 0.92rem; }
.unit-type { color: var(--stone); font-size: 0.92rem; margin-top: 2px; }

.tick { color: var(--green); font-weight: 600; font-size: 0.88rem; white-space: nowrap; opacity: 0; transition: opacity 0.2s ease; }
.tick::before { content: '\2713\00a0'; }
.tick.show { opacity: 1; }

.price-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 48px; margin-top: 10px; padding: 0 12px;
  background: #fff; border: 1.5px solid var(--rule); border-radius: 12px; text-align: left;
}
.price-value { font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.price-value.none { font-weight: 500; color: var(--stone); }
.price-base { color: var(--stone); font-size: 0.85rem; margin-left: 8px; font-weight: 400; }
.price-edit { color: var(--stone); font-size: 0.88rem; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.price-form { margin-top: 10px; }
.price-form label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 6px; }
.price-form .row-2 { margin-top: 10px; }
.unit .seg { margin-top: 10px; }

/* leads */
.leads-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.leads-head h2 { font-size: 1.25rem; }
.lead { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px; margin-top: 10px; }
.lead-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.lead-name { font-weight: 700; font-size: 1.08rem; overflow-wrap: anywhere; }
.kind { flex: none; font-size: 0.78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 1.5px solid var(--ink); white-space: nowrap; }
.kind[data-kind='waitlist'] { background: var(--saff); border-color: var(--saff); }
.lead-meta { color: var(--stone); font-size: 0.9rem; margin-top: 2px; }
.lead-contact { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 6px; }
.lead-contact a { color: var(--ink); font-weight: 600; text-underline-offset: 3px; min-height: 40px; display: inline-flex; align-items: center; overflow-wrap: anywhere; }
.lead-msg { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty { color: var(--stone); text-align: center; padding: 40px 12px; }

/* dialog + toast */
.dialog { border: 0; border-radius: 18px; padding: 22px; width: min(92vw, 400px); background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(20, 18, 26, 0.3); }
.dialog::backdrop { background: rgba(20, 18, 26, 0.5); }
.dialog h2 { font-size: 1.2rem; }
.dialog p { color: var(--stone); margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(92vw, 420px); padding: 14px 16px; border-radius: 12px; z-index: 20;
  background: var(--ink); color: var(--paper); font-weight: 500; box-shadow: 0 10px 30px rgba(20, 18, 26, 0.3);
}
.toast[data-kind='error'] { border-left: 6px solid #FF5533; }
.toast[data-kind='ok'] { border-left: 6px solid var(--saff); }

@media (min-width: 620px) {
  .unit { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; align-items: center; }
  .unit-main { grid-column: 1; }
  .unit-price { grid-column: 2; grid-row: 1; }
  .unit .price-btn, .unit .price-form { margin-top: 0; }
  .unit .seg { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
