:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-2: #f2f5f8;
  --text: #06172e;
  --muted: #536780;
  --line: #d5dee8;
  --brand: #f59e0b;
  --brand-2: #d97706;
  --accent: #1e40af;
  --danger: #dc2626;
  --warning: #b7791f;
  --ok: #15803d;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .12);
  --sidebar: #0f172a;
  --sidebar-muted: #9aa6ba;
  --sidebar-active: #1b2638;
}

[data-theme="dark"] {
  --bg: #101418;
  --panel: #171d22;
  --panel-2: #20272e;
  --text: #eef4f7;
  --muted: #9aa8b4;
  --line: #2d3842;
  --brand: #2dd4bf;
  --brand-2: #14b8a6;
  --accent: #60a5fa;
  --shadow: 0 12px 30px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif; color: var(--text); background: var(--bg); }
body { margin: 0; min-height: 100vh; font-size: 13px; letter-spacing: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 150px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 8px 6px; background: var(--sidebar); border-right: 0; color: #fff; }
.brand { display: grid; grid-template-columns: 24px 1fr; align-items: center; gap: 6px; padding: 6px 2px 10px; margin-bottom: 3px; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--brand); color: #111827; font-weight: 900; }
.brand strong, .brand small { display: block; line-height: 1.1; }
.brand strong { color: #fff; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand small { color: var(--sidebar-muted); font-size: 9px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collapse-mark { display: none; }
.side-nav { display: grid; gap: 4px; }
.side-nav a { display: flex; align-items: center; gap: 8px; padding: 8px 9px; border-radius: 6px; color: #e5edf8; font-size: 11px; font-weight: 750; }
.side-nav a:hover, .side-nav a.active { background: var(--sidebar-active); color: #fff; }
.side-nav a.active { box-shadow: none; }
.side-nav a.active .nav-icon { color: var(--brand); }
.nav-icon { width: 18px; height: 18px; display: inline-grid; place-items: center; flex: 0 0 auto; }

.main-shell { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; height: 64px; display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: color-mix(in srgb, var(--panel) 92%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.search { flex: 1; min-width: 180px; display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.property-select, input, select, textarea { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); min-height: 40px; padding: 8px 10px; }
.icon-button { position: relative; width: 38px; height: 38px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); }
.dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 99px; background: var(--danger); }
.user-menu { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: var(--accent); color: #fff; }
.content { padding: 25px 25px 36px; display: grid; gap: 21px; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
h1, h2, p { margin: 0; }
h1 { font-size: 29px; line-height: 1.08; letter-spacing: 0; }
h2 { font-size: 14px; }
.page-title p, .muted { color: var(--muted); }

.primary-button, .ghost-button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 8px; padding: 8px 12px; font-weight: 750; border: 1px solid transparent; }
.primary-button { background: var(--brand); color: #fff; }
.primary-button:hover { background: var(--brand-2); }
.ghost-button { background: var(--panel); border-color: var(--line); color: var(--text); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 12px; }
.metric-grid article, .panel, .module-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric-grid article { padding: 16px; display: grid; gap: 5px; }
.metric-grid span, .metric-grid small, .module-card p { color: var(--muted); }
.metric-grid strong { font-size: 25px; }
.split-grid { display: grid; grid-template-columns: minmax(320px, .9fr) minmax(420px, 1.1fr); gap: 18px; align-items: start; }
.panel { padding: 16px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.s { width: 9px; height: 9px; border-radius: 99px; display: inline-block; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.room-tile { min-height: 92px; text-align: left; display: grid; gap: 4px; border-radius: 8px; border: 1px solid var(--line); padding: 10px; background: var(--panel-2); color: var(--text); }
.room-tile strong { font-size: 20px; }
.room-tile span, .room-tile small { overflow-wrap: anywhere; }
.vacant, .clean, .inspected { --state: #16a34a; }
.occupied { --state: #2563eb; }
.dirty { --state: #d97706; }
.maintenance, .out-of-order { --state: #dc2626; }
.room-tile { border-left: 5px solid var(--state, var(--muted)); }
.room-tile.selected { outline: 3px solid rgba(15, 23, 42, .22); outline-offset: 2px; }
.legend .vacant { background: #16a34a; } .legend .occupied { background: #2563eb; } .legend .dirty { background: #d97706; } .legend .maintenance { background: #dc2626; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 840px; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.data-table th { position: sticky; top: 0; background: var(--panel-2); font-size: 12px; text-transform: uppercase; color: var(--muted); cursor: pointer; }
.data-table td small { display: block; color: var(--muted); margin-top: 2px; }
.status { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; background: var(--panel-2); text-transform: capitalize; }
.status.confirmed, .status.checked-in { color: var(--ok); } .status.pending { color: var(--warning); } .status.cancelled, .status.no-show { color: var(--danger); }
.table-tools, .pagination, .toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.table-search { width: 190px; }
.pagination { justify-content: flex-end; margin-top: 12px; color: var(--muted); }
.toolbar { padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }

.calendar-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.month-expanded .calendar-strip { grid-template-columns: repeat(7, minmax(90px, 1fr)); }
.calendar-strip div, .kanban div { border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); padding: 12px; display: grid; gap: 5px; }
.calendar-strip span { font-size: 24px; font-weight: 800; }
.calendar-strip small, .kanban p { color: var(--muted); }
.module-grid { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 12px; }
.module-card { padding: 16px; display: grid; gap: 12px; align-content: start; }
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.data-form { display: grid; gap: 12px; }
.two-col { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
.data-form label, .form-stack label { display: grid; gap: 6px; font-weight: 700; color: var(--muted); }
.data-form input, .data-form select, .data-form textarea, .form-stack input { width: 100%; }
.full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; align-items: center; }
.alert { border-radius: 8px; padding: 10px 12px; background: var(--panel-2); }
.alert.danger { color: #991b1b; background: #fee2e2; }
.alert.success { color: #166534; background: #dcfce7; }

.dashboard-kpis { display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); gap: 18px; }
.dash-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.kpi-card { position: relative; min-height: 121px; padding: 21px 24px; display: grid; gap: 5px; align-content: start; }
.kpi-label { color: #3f5a7b; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.kpi-card strong { color: #031b3f; font-size: 27px; line-height: 1.08; }
.kpi-card small { color: #536780; font-size: 11px; }
.kpi-icon { position: absolute; top: 20px; right: 20px; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 7px; background: #f1f5f9; font-weight: 900; font-size: 18px; }
.kpi-icon.blue { color: #2563eb; } .kpi-icon.green { color: #059669; } .kpi-icon.orange { color: #f97316; }
.kpi-icon.purple { color: #9333ea; } .kpi-icon.teal { color: #0f9f86; } .kpi-icon.red { color: #ff4d2f; }
.kpi-icon.cyan { color: #00a7d8; } .kpi-icon.pink { color: #e11d72; }

.dashboard-main-grid { display: grid; grid-template-columns: minmax(520px, 1.8fr) minmax(300px, .9fr); gap: 24px; }
.trend-card, .room-status-card, .list-card { padding: 28px 28px 24px; }
.trend-card h2, .room-status-card h2, .list-card h2 { color: #06172e; font-size: 14px; margin-bottom: 18px; }
.chart-frame { height: 285px; overflow: hidden; }
.chart-frame svg { width: 100%; height: 100%; }
.grid-lines path { stroke: #d8e1eb; stroke-width: 1; stroke-dasharray: 3 4; fill: none; }
.line { fill: none; stroke-width: 2.2; }
.occupancy-line { stroke: #64748b; }
.revenue-line { stroke: #f59e0b; }
.axis-labels text { fill: #60738c; font-size: 11px; }

.room-status-card { display: grid; align-content: start; }
.donut-wrap { display: grid; place-items: center; height: 150px; }
.donut-chart {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: conic-gradient(#6b7280 0 24%, #1f3d63 24% 64%, #f97316 64% 70%, #3b82f6 70% 76%, #111827 76% 82%, #9ca3af 82% 100%);
  position: relative;
}
.donut-chart::after { content: ""; position: absolute; inset: 30px; border-radius: 50%; background: #fff; }
.status-list { display: grid; gap: 7px; list-style: none; padding: 0; margin: 10px 0 0; }
.status-list li { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 7px; color: #314763; font-size: 11px; }
.status-list strong { color: #06172e; }
.dot-status { width: 9px; height: 9px; border-radius: 50%; }
.dot-status.slate { background: #6b7280; } .dot-status.gray { background: #9ca3af; } .dot-status.navy { background: #1f3d63; }
.dot-status.dark { background: #111827; } .dot-status.amber { background: #f97316; } .dot-status.sky { background: #3b82f6; }

.dashboard-bottom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.list-card h2 { display: flex; align-items: center; gap: 8px; }
.section-icon { display: inline-grid; place-items: center; width: 18px; height: 18px; font-size: 16px; }
.section-icon.teal { color: #0f9f86; } .section-icon.pink { color: #e11d72; }
.compact-list { display: grid; }
.compact-row { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #dce4ed; }
.compact-row:last-child { border-bottom: 0; }
.compact-row strong { display: block; color: #06172e; font-size: 12px; margin-bottom: 3px; }
.compact-row small { display: block; color: #536780; font-size: 11px; }
.compact-row em { padding: 4px 8px; border-radius: 6px; background: #f3f6fa; color: #031b3f; font-size: 11px; font-style: normal; font-weight: 800; text-transform: capitalize; }
.empty-row { min-height: 60px; }

.dark-add-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  background: #0f172a;
  color: #fff;
  padding: 9px 16px;
  font-size: 12px;
  font-weight: 850;
}
.dark-add-button span { font-size: 17px; line-height: 1; }
.room-status-pills { display: flex; flex-wrap: wrap; gap: 10px; }
.room-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; border-radius: 7px; padding: 5px 12px; font-size: 11px; border: 1px solid; }
.room-pill strong { font-weight: 850; }
.room-pill.vacant-clean { background: #dcfce7; border-color: #86efac; color: #15803d; }
.room-pill.vacant-dirty { background: #fef9c3; border-color: #fde047; color: #a16207; }
.room-pill.occupied { background: #dbeafe; border-color: #93c5fd; color: #1d4ed8; }
.room-pill.out-of-order { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }
.room-pill.maintenance { background: #ffedd5; border-color: #fdba74; color: #c2410c; }
.room-pill.inspected { background: #f3e8ff; border-color: #d8b4fe; color: #7e22ce; }
.rooms-toolbar {
  min-height: 67px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
}
.rooms-toolbar select { width: 140px; min-height: 38px; font-size: 12px; }
.view-toggle { display: flex; gap: 6px; }
.view-toggle button {
  width: 32px;
  height: 32px;
  border: 1px solid #cfd9e5;
  border-radius: 6px;
  background: #fff;
  color: #34445d;
  font-weight: 850;
}
.view-toggle button.active { background: #0f172a; color: #fff; border-color: #0f172a; }
.rooms-map { display: grid; gap: 24px; }
.floor-section { display: grid; gap: 13px; }
.floor-section h2 { display: flex; align-items: center; gap: 9px; color: #213a59; font-size: 13px; font-weight: 650; }
.floor-section h2 span {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #0f172a;
  color: #fff;
  font-size: 11px;
  font-weight: 850;
}
.floor-room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.rooms-map.list-view .floor-room-grid { grid-template-columns: 1fr; }
.rooms-map.list-view .room-card { min-height: 74px; grid-template-columns: 120px 1fr 120px 120px; align-items: center; }
.room-card {
  min-height: 121px;
  display: grid;
  align-content: start;
  gap: 6px;
  border: 1px solid;
  border-radius: 9px;
  padding: 15px 16px;
}
.room-card div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.room-card strong { font-size: 20px; line-height: 1; color: #0b53d0; }
.room-card em { color: #0b53d0; font-size: 11px; font-style: normal; }
.room-card span { color: #0b315f; font-size: 12px; font-weight: 750; }
.room-card small { color: #274f7c; font-size: 11px; }
.room-card.vacant-clean { background: #d8fbe3; border-color: #88efad; }
.room-card.vacant-dirty { background: #fff8bd; border-color: #f7dc3e; }
.room-card.occupied { background: #d7e9ff; border-color: #9bc7ff; }
.room-card.out-of-order { background: #ffe0e0; border-color: #f6a7a7; }
.room-card.maintenance { background: #ffebcf; border-color: #f7bf76; }
.room-card.inspected { background: #efe0ff; border-color: #dab7ff; }
.room-card.vacant-clean strong, .room-card.vacant-clean em { color: #00883c; }
.room-card.vacant-dirty strong, .room-card.vacant-dirty em { color: #b96b00; }
.room-card.maintenance strong, .room-card.maintenance em { color: #d64b00; }
.room-card.out-of-order strong, .room-card.out-of-order em { color: #c51616; }
.room-card.inspected strong, .room-card.inspected em { color: #7f22ce; }
.empty-rooms-state {
  display: grid;
  justify-items: start;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}
.empty-rooms-state p { color: var(--muted); }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, .78);
  padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  width: min(540px, 100%);
  background: #fff;
  border-radius: 8px;
  border: 1px solid #d5dee8;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
  padding: 24px;
}
.wide-modal { width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.modal-head h2 { font-size: 18px; color: #06172e; }
.modal-close { width: 28px; height: 28px; border: 0; background: transparent; color: #64748b; font-size: 20px; }
.room-modal-form { display: grid; gap: 16px; }
.room-modal-form label { display: grid; gap: 7px; color: #06172e; font-size: 12px; font-weight: 850; }
.room-modal-form input, .room-modal-form select { width: 100%; min-height: 38px; background: #fff; border-color: #cfd9e5; box-shadow: inset 0 1px 2px rgba(15, 23, 42, .04); }
.two-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; }
.modal-primary {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  background: #6b7280;
  color: #fff;
  padding: 8px 16px;
  font-weight: 850;
}
.modal-primary:not(:disabled):hover { background: #0f172a; }
.focus-panel { outline: 3px solid rgba(245, 158, 11, .35); outline-offset: 3px; }
.module-action-links { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.webhook-endpoint {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}
.webhook-endpoint span { color: var(--muted); font-weight: 800; }
.webhook-endpoint code { overflow-wrap: anywhere; color: var(--text); }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #e6f4f1, #f5f7f9 55%, #e8eef9); }
.auth-panel { width: min(430px, 100%); display: grid; gap: 16px; background: #fff; border: 1px solid #dbe3ea; border-radius: 8px; padding: 24px; box-shadow: var(--shadow); }
.auth-brand { margin: 0; padding: 0; }
.form-stack { display: grid; gap: 12px; }
.mobile-only { display: none; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -280px; z-index: 20; transition: left .2s ease; }
  .sidebar.open { left: 0; }
  .mobile-only { display: inline-grid; }
  .metric-grid, .module-grid, .split-grid, .kanban, .dashboard-kpis, .dashboard-main-grid, .dashboard-bottom-grid { grid-template-columns: 1fr 1fr; }
  .user-menu span:last-child, .property-select { display: none; }
}

@media (max-width: 640px) {
  .topbar { padding: 10px; gap: 8px; }
  .search { min-width: 0; }
  .content { padding: 12px; }
  .page-title { align-items: stretch; flex-direction: column; }
  .metric-grid, .module-grid, .split-grid, .kanban, .calendar-strip, .two-col, .dashboard-kpis, .dashboard-main-grid, .dashboard-bottom-grid { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
}
