:root {
  --bg: #f5f6fa; --panel: #ffffff; --text: #151a2d; --muted: #6b7290; --line: #e3e6ef; --accent: #4f6bff; --accent-soft: #eef1ff;
  --ok: #17a673; --warn: #e79b20; --bad: #e0485a; --radius: 14px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0d1020; --panel: #161a2e; --text: #eef0fa; --muted: #9aa1bf; --line: #262b45; --accent: #7c8fff; --accent-soft: #1e2446; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.4em; }

.btn { border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 8px 14px; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.wa { background: #25d366; border-color: #25d366; color: #fff; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 36px; width: 100%; max-width: 360px; text-align: center; }
.login-card .logo { font-size: 42px; }
.login-card h1 { margin: 6px 0 0; }
.login-card input { width: 100%; margin: 18px 0 12px; }
.login-card .btn { width: 100%; justify-content: center; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar .title { font-weight: 700; font-size: 17px; color: var(--text); }
.topbar .sync { display: flex; align-items: center; gap: 8px; font-size: 13px; flex: 1; min-width: 0; }
.topbar .sync span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .actions { display: flex; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: 0 0 9px; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.demo { background: var(--warn); }

main { max-width: 1280px; margin: 0 auto; padding: 24px; }
h2 { margin: 28px 0 12px; font-size: 18px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.kpi .v { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }

.demo-note { background: #fff7e6; color: #7a5200; border: 1px solid #f3d69a; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; }
@media (prefers-color-scheme: dark) { .demo-note { background: #2b2210; color: #f3d69a; border-color: #5a4720; } }

.props { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.prop { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.prop-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.prop-head h3 { margin: 0; font-size: 18px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.stay { background: #e3f7ee; color: #0f7a52; } .pill.checkout { background: #fff1dc; color: #9a5b00; } .pill.vacant { background: var(--accent-soft); color: var(--accent); }
@media (prefers-color-scheme: dark) { .pill.stay { background: #12352a; color: #6fe0b2; } .pill.checkout { background: #3a2a10; color: #ffc46b; } }
.guest { background: var(--bg); border-radius: 12px; padding: 12px 14px; }
.guest .n { font-weight: 600; font-size: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.warn { color: var(--warn); font-size: 13px; }
.tvlink { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.tvlink code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--bg); padding: 6px 8px; border-radius: 8px; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: var(--bg); }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* ---------- settings ---------- */
.settings { display: grid; grid-template-columns: minmax(0, 1fr) 480px; gap: 24px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 4px; font-size: 16px; }
.panel .help { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
label .muted { font-weight: 400; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); font: inherit; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field { margin-bottom: 12px; }
.rep { display: grid; gap: 8px; margin-bottom: 8px; align-items: center; }
.rep.guide { grid-template-columns: 56px 1fr 2fr 34px; }
.rep.tips { grid-template-columns: 1fr 1.3fr 1.6fr 1.6fr 34px; }
.x { border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; }
.preview { position: sticky; top: 76px; }
.preview .frame { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; border: 6px solid #1b1d26; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.preview iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.savebar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; display: flex; gap: 8px; justify-content: flex-end; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px); background: #151a2d; color: #fff; padding: 10px 18px; border-radius: 10px; transition: transform .25s; z-index: 20; }
.toast.on { transform: translateX(-50%) translateY(0); }

@media (max-width: 980px) {
  .settings { grid-template-columns: 1fr; }
  .preview { position: static; order: -1; }
}
@media (max-width: 640px) {
  main { padding: 16px; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .topbar .sync { order: 3; flex-basis: 100%; }
  .props { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .rep.guide, .rep.tips { grid-template-columns: 1fr 34px; }
  .rep.guide > :not(.x), .rep.tips > :not(.x) { grid-column: 1; }
  .rep .x { grid-column: 2; grid-row: 1; }
}
