:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0d9488;
  --brand-ink: #0f766e;
  --accent: #6366f1;
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: grid;
  grid-template-columns: 248px 1fr;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: grid; place-items: center; font-weight: 800; color: white; letter-spacing: .5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: white; font-size: 16px; }
.brand-text span { font-size: 12px; color: #94a3b8; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: 0; color: #cbd5e1;
  padding: 11px 12px; border-radius: 9px; cursor: pointer;
  font-size: 14px; font-weight: 500; text-align: left; transition: .15s;
}
.nav-btn .dot { width: 7px; height: 7px; border-radius: 50%; background: #475569; transition: .15s; }
.nav-btn:hover { background: #1e293b; color: white; }
.nav-btn.active { background: #1e293b; color: white; }
.nav-btn.active .dot { background: var(--brand); box-shadow: 0 0 0 3px rgba(13,148,136,.25); }
.sidebar-foot { display: flex; flex-direction: column; gap: 10px; }
.conn { font-size: 12px; padding: 6px 10px; border-radius: 8px; text-align: center; font-weight: 600; }
.conn-demo { background: #422006; color: #fbbf24; }
.conn-live { background: #052e2b; color: #2dd4bf; }
.conn-err { background: #450a0a; color: #fca5a5; }
.refresh {
  background: #1e293b; color: #e2e8f0; border: 0; border-radius: 8px;
  padding: 9px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.refresh:hover { background: #334155; }

/* Main */
.main { padding: 24px 32px 60px; max-width: 1200px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; }
.topbar h1 { margin: 0; font-size: 24px; }
.muted { color: var(--muted); }
.topbar .muted { margin: 4px 0 0; font-size: 14px; }
.window-pick { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.window-pick select {
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: white; font-size: 13px; color: var(--ink);
}

.tab { display: none; }
.tab.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Cards */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 800; margin-top: 6px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.kpi .value.good { color: var(--good); }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden;
}
.panel-h { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-h h2 { margin: 0; font-size: 15px; }
.panel-h .muted { font-size: 13px; }
.panel-b { padding: 6px 0; }

/* Reservation rows */
.row {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 14px;
  align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: #f8fafc; }
.datechip {
  width: 52px; text-align: center; border-radius: 9px; padding: 6px 0;
  background: #f1f5f9; border: 1px solid var(--line);
}
.datechip .m { font-size: 10px; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: .05em; }
.datechip .d { font-size: 18px; font-weight: 800; line-height: 1; }
.row .who { font-weight: 600; }
.row .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.row .amt { font-weight: 700; text-align: right; }
.row .amt small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }

.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 700; text-transform: capitalize; }
.pill.airbnb { background: #fee2e2; color: #be123c; }
.pill.vrbo, .pill.vrbo-official { background: #dbeafe; color: #1d4ed8; }
.pill.booking { background: #e0e7ff; color: #4338ca; }
.pill.direct { background: #dcfce7; color: #15803d; }
.pill.manual { background: #f1f5f9; color: #475569; }
.pill.prop { background: #f1f5f9; color: #334155; }
.tag-pet { background: #fef3c7; color: #92400e; }
.tag-turn { background: #fee2e2; color: #b91c1c; }

/* Calendar */
.cal-legend { display: flex; gap: 12px; flex-wrap: wrap; }
.cal-legend .leg { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); font-weight: 600; }
.cal-legend .leg i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.cal-axis-top { position: relative; height: 15px; margin-bottom: 10px; }
.cal-tick { position: absolute; font-size: 10px; color: var(--muted); white-space: nowrap; font-weight: 600; }
.cal-prop { margin-bottom: 12px; }
.cal-prop-h { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; padding: 4px 2px; }
.cal-track { position: relative; height: 34px; background: #f8fafc; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.cal-band {
  position: absolute; top: 3px; height: 28px; border-radius: 6px;
  font-size: 11px; color: white; display: flex; align-items: center; padding: 0 7px;
  white-space: nowrap; overflow: hidden; font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.28);
}
.cal-band.clickable { cursor: pointer; transition: filter .12s, transform .12s; }
.cal-band.clickable:hover { filter: brightness(1.08); transform: translateY(-1px); }
.cal-hint { font-size: 11.5px; margin-top: 10px; text-align: center; }
.cal-axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 4px; padding: 0 2px; }

/* Bars */
.bar-row { display: grid; grid-template-columns: 150px 1fr 90px; align-items: center; gap: 12px; padding: 8px 18px; }
.bar-row .nm { font-size: 13px; font-weight: 600; }
.bar-track { background: #f1f5f9; border-radius: 6px; height: 22px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); border-radius: 6px; }
.bar-row .val { text-align: right; font-weight: 700; font-size: 13px; }

/* Messages */
.msg-list { display: grid; grid-template-columns: 1fr; }
.msg-item { padding: 12px 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.msg-item:hover { background: #f8fafc; }
.msg-item .top { display: flex; justify-content: space-between; }
.msg-item .nm { font-weight: 600; }
.msg-item .age { font-size: 12px; color: var(--muted); }
.thread { padding: 14px 18px; }
.bubble { max-width: 80%; padding: 9px 12px; border-radius: 12px; margin-bottom: 8px; font-size: 13.5px; line-height: 1.4; }
.bubble.guest { background: #f1f5f9; }
.bubble.host { background: #ccfbf1; margin-left: auto; }
.composer { display: flex; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); align-items: stretch; }
.composer textarea { flex: 1; resize: vertical; min-height: 64px; border: 1px solid var(--line); border-radius: 9px; padding: 9px; font-family: inherit; font-size: 13.5px; }
.composer-actions { display: flex; flex-direction: column; gap: 8px; min-width: 120px; }
.composer-actions .btn { flex: 1; white-space: nowrap; }
.btn { background: var(--brand); color: white; border: 0; border-radius: 9px; padding: 0 16px; font-weight: 700; cursor: pointer; }
.btn:hover { background: var(--brand-ink); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.ghost { background: #f1f5f9; color: var(--ink); }
.btn.ai { background: linear-gradient(135deg, var(--accent), var(--brand)); }
.btn.ai:hover { filter: brightness(1.07); background: linear-gradient(135deg, var(--accent), var(--brand)); }

.empty { padding: 40px; text-align: center; color: var(--muted); }
.skel { padding: 60px; text-align: center; color: var(--muted); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #0f172a; color: white; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow); transition: transform .25s; z-index: 50;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--bad); }

@media (max-width: 820px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 18px; }
  .bar-row { grid-template-columns: 110px 1fr 70px; }
}
