:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #1f6feb; --accent-weak: #e8f0fe; --green: #1a7f37; --red: #c62828; --amber: #b26a00;
  --booked: #dbe9ff; --closed: #fde8e8; --blocked: #ececec;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
main { padding: 12px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; } .pad { padding: 16px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
.err-text { color: var(--red); }
.pre { white-space: pre-wrap; }

.topbar { display: flex; align-items: center; gap: 12px; background: #111827; color: #fff; padding: 0 12px; height: 48px; position: sticky; top: 0; z-index: 20; }
.topbar .brand { color: #fff; font-weight: 700; }
.topbar nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.topbar nav a { color: #cbd5e1; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.topbar nav a.active, .topbar nav a:hover { background: #374151; color: #fff; }
.logout button { background: none; border: 1px solid #4b5563; color: #cbd5e1; border-radius: 6px; padding: 4px 8px; cursor: pointer; }

.flash { margin: 10px 12px 0; padding: 10px 12px; border-radius: 8px; }
.flash.ok { background: #e6f4ea; color: var(--green); } .flash.err { background: #fde8e8; color: var(--red); }

button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 8px; padding: 7px 12px; cursor: pointer; display: inline-block; }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: 8px; padding: 7px 14px; cursor: pointer; font: inherit; }
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: #fff; max-width: 100%; }
label { display: block; margin: 6px 0; font-size: 13px; color: var(--muted); }
label input, label select, label textarea { display: block; width: 100%; margin-top: 3px; color: var(--text); }
label.chk { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; }
label.chk input { width: auto; margin: 0; display: inline; }
label.chk.inline { display: inline-flex; margin-right: 8px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.card h2, .card h3 { margin-top: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions-row form { margin: 0; }
pre.code { background: #0f172a; color: #e2e8f0; padding: 10px; border-radius: 8px; overflow: auto; max-height: 420px; font-size: 12px; }

.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; background: #fff; }
table.list th, table.list td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr.cancelled td { color: var(--muted); text-decoration: line-through; }
tr.cancelled td:last-child, tr.cancelled td:nth-last-child(2) { text-decoration: none; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.pill.green { background: #e6f4ea; color: var(--green); } .pill.red { background: #fde8e8; color: var(--red); } .pill.amber { background: #fff4e0; color: var(--amber); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.filters label { margin: 0; }

/* login */
.login-page main { display: flex; justify-content: center; padding-top: 12vh; }
.login-box { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: 100%; max-width: 340px; }
.login-box h1 { margin: 0; } .login-box .primary { width: 100%; margin-top: 12px; padding: 10px; }

/* inbox */
.inbox-page main { padding: 0; }
.inbox { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 48px); }
.conv-list { border-right: 1px solid var(--line); overflow-y: auto; background: #fff; }
.conv { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--text); }
.conv:hover { background: #f3f4f6; } .conv.active { background: var(--accent-weak); }
.conv-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.conv-top { display: flex; justify-content: space-between; gap: 6px; }
.conv-sub { font-size: 12px; color: var(--muted); }
.conv-last { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .conv-last { color: var(--text); font-weight: 600; }
.badge { background: var(--accent); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
.ch { flex: none; width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 13px; background: #6b7280; }
.ch-booking { background: #003580; } .ch-airbnb { background: #ff385c; } .ch-expedia { background: #f5b301; color: #111; }
.ch-whatsapp { background: #25d366; } .ch-instagram { background: #c13584; } .ch-facebook { background: #1877f2; }
.ch-email { background: #6b7280; } .ch-webchat { background: #0d9488; }
.thread { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.thread-head { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: #fff; border-bottom: 1px solid var(--line); }
.thread-head .back { display: none; font-size: 26px; padding: 0 6px; }
.messages { flex: 1; overflow-y: auto; padding: 12px; }
.msg { display: flex; flex-direction: column; margin-bottom: 10px; max-width: 75%; }
.msg.in { align-items: flex-start; } .msg.out { align-items: flex-end; margin-left: auto; }
.bubble { padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.in .bubble { background: #fff; border: 1px solid var(--line); } .msg.out .bubble { background: var(--accent); color: #fff; }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.reply { display: flex; gap: 8px; padding: 10px; background: #fff; border-top: 1px solid var(--line); }
.reply textarea { flex: 1; resize: vertical; }

/* calendar */
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.toolbar form.inline { display: flex; gap: 6px; }
.hint { margin: 4px 0 8px; }
.cal-wrap { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; max-height: calc(100vh - 170px); }
table.cal { border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.cal th, table.cal td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
table.cal thead th { position: sticky; top: 0; background: #fff; z-index: 2; padding: 4px 2px; min-width: 58px; font-weight: 500; }
table.cal thead th.we { background: #fafafa; } table.cal thead th.today { background: var(--accent-weak); }
table.cal .dw, table.cal .dn, table.cal .dm { display: block; text-align: center; }
table.cal .dn { font-size: 15px; font-weight: 600; } table.cal .dm { color: var(--muted); font-size: 10px; }
.unit-col { position: sticky; left: 0; background: #fff; z-index: 1; min-width: 130px; max-width: 160px; text-align: left; padding: 4px 8px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
thead .unit-col { z-index: 3; }
td.cell { height: 56px; min-width: 58px; padding: 3px 4px; vertical-align: top; cursor: pointer; user-select: none; position: relative; }
td.cell.past { background: #f3f4f6; color: #9ca3af; cursor: default; }
td.cell.booked { background: var(--booked); } td.cell.closed { background: var(--closed); } td.cell.blocked { background: var(--blocked); }
td.cell.sel { outline: 3px solid var(--accent); outline-offset: -3px; }
td.cell .price { display: block; font-weight: 600; }
td.cell .guest, td.cell .tag { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; }
td.cell .tag { color: var(--red); }
td.cell .flags i { font-style: normal; font-size: 10px; background: #eef2f7; border-radius: 4px; padding: 0 3px; margin-right: 2px; color: #374151; }
.selbar { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 10px 12px; display: flex; gap: 10px; align-items: center; justify-content: flex-end; z-index: 30; box-shadow: 0 -2px 8px rgba(0,0,0,.06); }
.selbar[hidden] { display: none; }
.selbar span { margin-right: auto; }
dialog { border: none; border-radius: 14px; padding: 18px; width: min(460px, 94vw); max-height: 92vh; }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h3 { margin-top: 0; }
dialog fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 6px 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

@media (max-width: 760px) {
  main { padding: 8px; }
  .inbox { grid-template-columns: 1fr; }
  .inbox-page.has-current .conv-list { display: none; }
  .inbox-page:not(.has-current) .thread { display: none; }
  .thread-head .back { display: inline; }
  .hide-mobile { display: none; }
  .msg { max-width: 88%; }
  .unit-col { min-width: 96px; max-width: 110px; font-size: 11px; }
  .topbar .brand { display: none; }
}
