:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1b2330; --muted: #6b7686; --line: #e3e7ed; --accent: #1f6feb;
  --accent-soft: #e8f0fe; --ok: #1a7f37; --warn: #b26b00; --bad: #c62828; --col: 46px; --rowh: 40px;
  --confirmed: #3b82f6; --checked_in: #16a34a; --checked_out: #94a3b8; --no_show: #9ca3af;
  --radius: 8px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#0f141b; --panel:#171e28; --text:#e6ebf2; --muted:#93a0b2; --line:#283241; --accent:#5b9bff; --accent-soft:#1c2a40; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; width: 100%; }
textarea { min-height: 70px; resize: vertical; }
button { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 7px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--bad); }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: default; }
label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 3px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }

.login { position: fixed; inset: 0; display: grid; place-items: center; }
.login-card { background: var(--panel); padding: 28px; border-radius: 12px; width: min(340px, 92vw); border: 1px solid var(--line); display: grid; gap: 10px; }
.login-card h1 { margin: 0; }

.top { display: flex; align-items: center; gap: 18px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { padding: 6px 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.top-right { margin-left: auto; display: flex; gap: 8px; position: relative; }
#search { width: 240px; }
.search-results { position: absolute; top: 40px; right: 80px; width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 60vh; overflow: auto; }
.search-results div { padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.search-results div:hover { background: var(--accent-soft); }
.badge { background: var(--bad); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; }
main { padding: 16px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }

/* calendar */
.cal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 150px); }
.cal-inner { position: relative; min-width: max-content; }
.cal-head, .cal-row { display: flex; }
.cal-head { position: sticky; top: 0; z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line); }
.cal-label { position: sticky; left: 0; z-index: 4; width: 150px; min-width: 150px; background: var(--panel); border-right: 1px solid var(--line); padding: 0 10px; display: flex; align-items: center; gap: 6px; }
.cal-head .cal-label { z-index: 6; }
.cal-day { width: var(--col); min-width: var(--col); text-align: center; font-size: 11px; padding: 4px 0; border-right: 1px solid var(--line); }
.cal-day.weekend { background: rgba(127,127,127,.06); }
.cal-day.today { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.cal-day b { display: block; font-size: 13px; }
.cal-prop { background: var(--bg); font-weight: 600; padding: 6px 10px; position: sticky; left: 0; border-bottom: 1px solid var(--line); }
.cal-row { height: var(--rowh); border-bottom: 1px solid var(--line); position: relative; }
.cal-cells { display: flex; position: relative; }
.cal-cell { width: var(--col); min-width: var(--col); height: var(--rowh); border-right: 1px solid var(--line); cursor: cell; }
.cal-cell.weekend { background: rgba(127,127,127,.06); }
.cal-cell.today { background: rgba(31,111,235,.06); }
.cal-cell:hover { background: var(--accent-soft); }
.bar { position: absolute; top: 5px; height: calc(var(--rowh) - 10px); border-radius: 6px; color: #fff; font-size: 12px; padding: 0 8px; display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; cursor: grab; user-select: none; box-shadow: 0 1px 2px rgba(0,0,0,.2); touch-action: none; }
.bar.confirmed { background: var(--confirmed); }
.bar.checked_in { background: var(--checked_in); }
.bar.checked_out { background: var(--checked_out); }
.bar.no_show { background: var(--no_show); text-decoration: line-through; }
.bar.unpaid::after { content: "unpaid"; font-size: 10px; background: rgba(0,0,0,.25); padding: 1px 5px; border-radius: 4px; }
.bar.dragging { opacity: .85; cursor: grabbing; z-index: 10; outline: 2px dashed #fff; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.clean { background: var(--ok); } .dot.dirty { background: var(--warn); } .dot.inspect { background: var(--accent); } .dot.out_of_order { background: var(--bad); }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); align-items: center; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* drawer */
.drawer { position: fixed; inset: 0 0 0 auto; width: min(520px, 100vw); background: var(--panel); border-left: 1px solid var(--line); z-index: 50; box-shadow: -8px 0 24px rgba(0,0,0,.15); overflow: auto; }
.drawer-inner { padding: 18px; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.status-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; color: #fff; }
.log { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 16px; }
.log div { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.warn { background: #fff4e5; color: #7a4a00; padding: 8px 10px; border-radius: 6px; margin-top: 8px; font-size: 13px; }
@media (prefers-color-scheme: dark) { .warn { background: #3a2a10; color: #ffd28a; } }

/* today */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.list-item { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; align-items: center; cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.clean-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.clean-unit { border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.clean-unit select { margin-top: 6px; }

/* prices */
.prices-wrap { display: grid; grid-template-columns: 1fr 340px; gap: 12px; align-items: start; }
.ptable { overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.ptable table { border-collapse: collapse; min-width: max-content; }
.ptable th, .ptable td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; text-align: center; font-size: 12px; }
.ptable th.rowhead, .ptable td.rowhead { position: sticky; left: 0; background: var(--panel); text-align: left; min-width: 170px; z-index: 2; }
.ptable td.pc { min-width: 64px; cursor: pointer; }
.ptable td.pc:hover { background: var(--accent-soft); }
.ptable td.pc.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.ptable td.pc .p { font-weight: 600; font-size: 13px; }
.ptable td.pc.default .p { color: var(--muted); font-weight: 400; }
.ptable td.pc.stop { background: repeating-linear-gradient(45deg, transparent 0 6px, rgba(198,40,40,.12) 6px 12px); }
.ptable .avail { font-size: 10px; color: var(--muted); }
.ptable .avail.full { color: var(--bad); font-weight: 600; }
.tag { display: inline-block; font-size: 9px; padding: 0 3px; border-radius: 3px; background: var(--accent-soft); color: var(--accent); margin: 1px; }
.tag.red { background: #fde8e8; color: var(--bad); }
.weekdays { display: flex; gap: 4px; flex-wrap: wrap; }
.weekdays label { margin: 0; display: inline-flex; gap: 3px; align-items: center; color: var(--text); font-size: 12px; border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; }
.weekdays input { width: auto; }
.tri { display: flex; gap: 4px; }
.tri select { width: auto; }
.preview { font-size: 12px; max-height: 220px; overflow: auto; margin-top: 8px; }
.preview table { width: 100%; border-collapse: collapse; }
.preview td { padding: 2px 4px; border-bottom: 1px solid var(--line); }
.up { color: var(--ok); } .down { color: var(--bad); }

table.simple { width: 100%; border-collapse: collapse; }
table.simple th, table.simple td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.sev-urgent { color: var(--bad); font-weight: 700; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1b2330; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 100; max-width: 90vw; }
.toast.err { background: var(--bad); }

@media (max-width: 900px) {
  .prices-wrap { grid-template-columns: 1fr; }
  #search { width: 160px; }
  .cal-label { width: 70px; min-width: 70px; }
  .cal-label .muted { display: none; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}

.demo-bar { background: #fff4e5; color: #7a4a00; text-align: center; padding: 6px 12px; font-size: 13px; }
.demo-bar button { padding: 2px 8px; margin-left: 8px; }
@media (prefers-color-scheme: dark) { .demo-bar { background: #3a2a10; color: #ffd28a; } }
