:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e6e8f0;
  --ink: #1a1c2e;
  --ink-soft: #5b6178;
  --ink-faint: #9aa0b4;
  --primary: #4f46e5;
  --primary-soft: #eef0ff;
  --airbnb: #ff385c;
  --green: #17a673;
  --green-soft: #e5f6ef;
  --amber: #d98a00;
  --red: #e5484d;
  --shadow: 0 1px 2px rgba(16, 22, 48, .04), 0 4px 16px rgba(16, 22, 48, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.app { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  background: #10122a;
  color: #c9cce0;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 22px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: grid; place-items: center; font-weight: 700; color: #fff; letter-spacing: .5px;
}
.brand-name { font-weight: 700; color: #fff; font-size: 15px; }
.brand-sub { font-size: 11px; color: #6b7099; text-transform: uppercase; letter-spacing: .8px; }

.prop-select { padding: 0 6px; }
.prop-select label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #6b7099; margin-bottom: 6px; }
.prop-select select {
  width: 100%; padding: 9px 10px; border-radius: 9px;
  background: #1b1e3d; color: #fff; border: 1px solid #2a2e52; font-size: 13px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border: none; background: none; color: #b6bad6;
  border-radius: 9px; cursor: pointer; font-size: 13.5px; font-weight: 500; text-align: left;
  font-family: inherit; transition: background .12s, color .12s;
}
.nav button span { width: 18px; text-align: center; opacity: .8; }
.nav button:hover { background: #1b1e3d; color: #fff; }
.nav button.active { background: var(--primary); color: #fff; }
.nav button.active span { opacity: 1; }

.env-badge {
  margin-top: auto; font-size: 11px; color: #6b7099;
  padding: 8px 10px; border: 1px solid #262a4d; border-radius: 8px; text-align: center;
}

/* ---- Content ---- */
.content { display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.view { padding: 24px 28px; overflow: auto; flex: 1; }

/* ---- Bits ---- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .label { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .5px; }
.stat .value { font-size: 28px; font-weight: 700; }
.stat .sub { font-size: 12px; color: var(--ink-faint); }

.section-title { font-size: 13px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .6px; margin: 26px 0 12px; }

.btn {
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 9px 15px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); transition: all .12s;
}
.btn:hover { border-color: #cfd2e2; background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #4338ca; }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 6px 11px; font-size: 12px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: #fdf1dd; color: var(--amber); }
.pill.gray { background: #eef0f5; color: var(--ink-soft); }
.pill.airbnb { background: #ffe8ec; color: var(--airbnb); }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; color: var(--ink-soft); font-weight: 600; font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: .4px; }
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--surface-2); }
table.data tr:hover td { background: var(--surface-2); }

/* ---- ARI calendar grid ---- */
.cal-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 18px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); }
.field input, .field select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit; background: var(--surface);
}
.cal-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table.cal { border-collapse: collapse; font-size: 13px; min-width: 100%; }
table.cal th, table.cal td { border-bottom: 1px solid var(--surface-2); border-right: 1px solid var(--surface-2); white-space: nowrap; }
table.cal thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; padding: 10px 8px; font-weight: 600; text-align: center; color: var(--ink-soft); }
table.cal thead th.weekend { background: #fbf7ef; }
table.cal .row-head {
  position: sticky; left: 0; background: var(--surface); z-index: 1;
  padding: 10px 14px; text-align: left; min-width: 210px; font-weight: 500;
}
table.cal .row-room .row-head { font-weight: 700; }
table.cal .row-room td { background: var(--surface-2); }
table.cal .rate-label { color: var(--ink-soft); font-weight: 500; padding-left: 26px; }
table.cal td.cell { text-align: center; padding: 0; }
table.cal td.cell input {
  width: 62px; border: none; background: transparent; text-align: center;
  padding: 10px 4px; font-size: 13px; font-family: inherit; color: var(--ink);
}
table.cal td.cell input:focus { outline: 2px solid var(--primary); outline-offset: -2px; background: var(--primary-soft); border-radius: 4px; }
table.cal td.cell.dirty { background: #fff8e6; }
table.cal td.cell.weekend { background: #fcfaf5; }
table.cal td.avail input { font-weight: 600; }
table.cal td.zero input { color: var(--red); }

.muted { color: var(--ink-faint); }
.empty { text-align: center; padding: 50px; color: var(--ink-faint); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #10122a; color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 13px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: all .25s; box-shadow: 0 8px 30px rgba(0,0,0,.25); z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

.row-actions { display: flex; gap: 8px; }
.dim { color: var(--ink-faint); font-size: 12px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }

/* ===== v2: pro components ===================================== */
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: #565b85; margin: 14px 8px 4px; }
.btn.ghost { background: transparent; color: #b6bad6; border-color: #2a2e52; }
.prop-select .btn.ghost { width: 100%; margin-top: 8px; color: #aab; }
.live-badge { display: flex; align-items: center; gap: 8px; justify-content: center; font-size: 11px; color: #6b7099; padding: 7px; border: 1px solid #262a4d; border-radius: 8px; margin-top: auto; }
.live-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #565b85; }
.live-badge.on { color: #7ee2b8; } .live-badge.on .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(23,166,115,.2); animation: pulse 1.8s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(23,166,115,0); } }
.crumb { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }
.range-label { font-size: 12px; color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--border); padding: 6px 12px; border-radius: 8px; }

/* KPI row */
.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { display: flex; flex-direction: column; gap: 5px; }
.kpi.accent { background: linear-gradient(135deg, #4f46e5, #6d5efc); color: #fff; border: none; }
.kpi.accent .kpi-label, .kpi.accent .kpi-sub { color: rgba(255,255,255,.8); }
.kpi-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.kpi-sub { font-size: 11.5px; color: var(--ink-faint); }
@media (max-width: 1100px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }

.dash-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-cols .center-col { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.card-title { font-weight: 700; font-size: 14px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
.legend { font-size: 11px; color: var(--ink-faint); font-weight: 500; display: flex; align-items: center; gap: 5px; }
.legend .sw { display: inline-block; width: 12px; height: 4px; border-radius: 2px; }
.legend .sw.bar { background: var(--primary); } .legend .sw.line { background: var(--airbnb); }
.chart-wrap { overflow-x: auto; }

/* charts */
svg.chart { width: 100%; height: auto; }
svg.chart .grid { stroke: #eef0f5; stroke-width: 1; }
svg.chart .axis { fill: var(--ink-faint); font-size: 10px; }
svg.chart .bar { fill: url(#g); fill: #a5b4fc; }
svg.chart .bar { fill: #c7d2fe; }
svg.chart .bar:hover { fill: #818cf8; }
svg.chart .line { fill: none; stroke: var(--airbnb); stroke-width: 2; }
svg.chart .dot { fill: var(--airbnb); }
.donut { width: 130px; height: 130px; }
.donut .donut-bg { fill: none; stroke: #eef0f5; stroke-width: 12; }
.donut .donut-fg { fill: none; stroke: var(--primary); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset .6s; }
.donut .donut-text { font-size: 22px; font-weight: 800; fill: var(--ink); }

.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar-label { font-weight: 600; }
.hbar-track { background: var(--surface-2); border-radius: 6px; height: 12px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 6px; }
.hbar-val { font-weight: 600; font-variant-numeric: tabular-nums; }

/* rooms */
.room-card { margin-bottom: 14px; }
.room-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.room-title { font-weight: 700; font-size: 15px; }
.spread { display: flex; justify-content: space-between; align-items: center; }
.reply { background: var(--primary-soft); border-radius: 8px; padding: 8px 12px; font-size: 12.5px; color: #3730a3; margin-top: 6px; }
.msg { margin-bottom: 8px; }
.err { color: var(--red); }

/* forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-soft); font-weight: 600; }
.inp { padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; font-size: 13.5px; font-family: inherit; background: var(--surface); color: var(--ink); }
.inp:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.inp { resize: vertical; }
.hint { font-size: 11px; color: var(--ink-faint); }
.chk { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-soft); }

/* overlay / modal / drawer */
.overlay { position: fixed; inset: 0; background: rgba(16,18,42,.45); display: flex; align-items: center; justify-content: center; z-index: 40; backdrop-filter: blur(2px); }
.overlay.right { justify-content: flex-end; align-items: stretch; }
.modal { background: var(--surface); border-radius: 16px; width: 92%; max-width: 560px; box-shadow: 0 24px 60px rgba(16,22,48,.3); max-height: 88vh; display: flex; flex-direction: column; animation: pop .16s ease-out; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.drawer { background: var(--surface); width: 440px; max-width: 92%; height: 100%; box-shadow: -20px 0 60px rgba(16,22,48,.2); display: flex; flex-direction: column; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: .6; } }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; overflow: auto; }
.drawer-body { padding: 20px; overflow: auto; flex: 1; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.x { border: none; background: none; font-size: 15px; color: var(--ink-faint); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.x:hover { background: var(--surface-2); color: var(--ink); }

/* weekdays */
.weekdays { display: flex; gap: 6px; flex-wrap: wrap; }
.wd { display: flex; align-items: center; gap: 4px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); padding: 5px 8px; border-radius: 7px; cursor: pointer; }

/* grid sub-rows & checkboxes */
table.cal .sub-row .row-head { font-weight: 400; }
table.cal td.chk-cell { text-align: center; }
table.cal td.chk-cell input { transform: scale(1.1); }

/* booking drawer */
.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--surface-2); font-size: 13px; }
.kv .k { color: var(--ink-soft); }
.kv .v { font-weight: 600; }

/* live feed */
.feed-item { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--surface-2); font-size: 12px; }
.feed-time { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
