:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --green: #047857;
  --amber: #b45309;
  --red: #b91c1c;
  --violet: #6d28d9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--red); font-size: 13px; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, #dbeafe 0%, transparent 55%),
              radial-gradient(900px 500px at 110% 110%, #ede9fe 0%, transparent 50%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; text-align: center; }
.login-card h1 { font-size: 20px; }
.login-card > p { margin: -8px 0 4px; }
.login-card label { text-align: left; font-size: 13px; font-weight: 600; color: #334155; display: flex; flex-direction: column; gap: 6px; }
.brand-mark { width: 56px; height: 56px; margin: 0 auto; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--violet)); color: #fff; font-weight: 800; letter-spacing: .04em; }
.brand-mark.small { width: 36px; height: 36px; border-radius: 10px; font-size: 12px; margin: 0; }
.demo-accounts { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }
.demo-accounts p { margin: 0 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chip { border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px; padding: 4px 10px;
  font-size: 12px; cursor: pointer; font-family: var(--mono); color: #334155; }
.chip:hover { border-color: var(--primary); color: var(--primary); }

/* ------------------------------------------------------------- app shell */
#app-view { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; padding: 16px 12px; gap: 18px;
  position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; color: #fff; padding: 4px 6px; }
.brand strong { display: block; font-size: 14px; }
.brand small { display: block; font-size: 11px; }
nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
nav button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent;
  color: #cbd5e1; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 500; }
nav button:hover { background: #1e293b; color: #fff; }
nav button.active { background: var(--primary); color: #fff; font-weight: 600; }
nav .nav-icon { width: 18px; text-align: center; opacity: .9; }
.sidebar-foot { border-top: 1px solid #1e293b; padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.who strong { display: block; color: #fff; font-size: 13px; }
.who small { font-size: 11px; text-transform: capitalize; }

.content { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar h2 { font-size: 18px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page { padding: 22px 24px 48px; display: flex; flex-direction: column; gap: 18px; }

/* ------------------------------------------------------------ components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card > header h3 { font-size: 14.5px; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

button, .btn { font: inherit; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: 7px 12px; cursor: pointer; font-size: 13px; font-weight: 550; }
button:hover, .btn:hover { background: var(--surface-2); }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
button.ghost { background: transparent; }
button.ghost:hover { background: rgba(148,163,184,.18); }
button.danger { color: var(--red); border-color: #fecaca; background: #fef2f2; }
button.danger:hover { background: #fee2e2; }
button.success { color: #fff; background: var(--green); border-color: var(--green); }
button.success:hover { filter: brightness(.94); }
button:disabled { opacity: .5; cursor: not-allowed; }
.small-btn { padding: 5px 9px; font-size: 12px; }
.icon-btn { border: 0; background: transparent; font-size: 20px; line-height: 1; padding: 2px 6px; color: var(--muted); }

input, select, textarea { font: inherit; font-size: 13px; padding: 7px 9px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; outline-offset: 0; border-color: var(--primary); }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: #475569; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.form-grid .span-2 { grid-column: span 2; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-input { max-width: 280px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700;
  background: var(--surface-2); position: sticky; top: 0; }
tbody tr:hover { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12.5px; }
.table-scroll { max-height: 62vh; overflow: auto; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-transform: capitalize; white-space: nowrap;
  background: #f1f5f9; color: #475569; border: 1px solid transparent; }
.badge.green { background: #ecfdf5; color: var(--green); border-color: #a7f3d0; }
.badge.blue { background: #eff6ff; color: var(--primary); border-color: #bfdbfe; }
.badge.amber { background: #fffbeb; color: var(--amber); border-color: #fde68a; }
.badge.red { background: #fef2f2; color: var(--red); border-color: #fecaca; }
.badge.violet { background: #f5f3ff; color: var(--violet); border-color: #ddd6fe; }
.badge.gray { background: #f1f5f9; color: var(--muted); border-color: #e2e8f0; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; }
.kpi .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.kpi .value { font-size: 25px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 820px) { #app-view { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } }

/* ---------------------------------------------------------- room board */
.room-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(122px, 1fr)); gap: 10px; }
.room-tile { border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 9px; padding: 10px;
  background: var(--surface); cursor: pointer; display: flex; flex-direction: column; gap: 3px; text-align: left; }
.room-tile:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.room-tile .rn { font-weight: 750; font-size: 15px; }
.room-tile .rt { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-tile .rg { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.room-tile.available { border-left-color: #10b981; }
.room-tile.occupied { border-left-color: var(--primary); background: #f8fbff; }
.room-tile.cleaning { border-left-color: #f59e0b; background: #fffdf5; }
.room-tile.maintenance, .room-tile.out_of_order { border-left-color: #ef4444; background: #fff7f7; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; }

/* ------------------------------------------------------------ timeline */
.timeline { display: flex; flex-direction: column; gap: 4px; }
.tl-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; align-items: center; }
.tl-label { font-size: 12px; font-weight: 650; display: flex; gap: 6px; align-items: baseline; }
.tl-track { position: relative; height: 30px; background: repeating-linear-gradient(90deg, var(--surface-2) 0 1px, transparent 1px 100%);
  border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.tl-bar { position: absolute; top: 5px; height: 20px; border-radius: 5px; background: var(--primary); color: #fff;
  font-size: 11px; padding: 2px 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.tl-bar.maintenance { background: #ef4444; }
.tl-bar.cleaning { background: #f59e0b; }
.tl-head { display: grid; grid-template-columns: 130px 1fr; gap: 10px; }
.tl-days { display: flex; font-size: 10.5px; color: var(--muted); }
.tl-days span { flex: 1; text-align: center; border-left: 1px solid var(--border); padding: 2px 0; }

/* --------------------------------------------------------------- modal */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: grid; place-items: center; z-index: 60; padding: 20px; }
.modal-card { background: var(--surface); border-radius: 14px; width: min(720px, 100%); max-height: 90vh; display: flex;
  flex-direction: column; box-shadow: 0 24px 60px -12px rgba(15,23,42,.4); }
.modal-card > header { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.modal-card > header h3 { font-size: 16px; }
.modal-body { padding: 18px; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { padding: 13px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 14px 14px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff;
  padding: 11px 18px; border-radius: 10px; z-index: 90; font-size: 13.5px; box-shadow: var(--shadow); max-width: 90vw; }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

.empty { padding: 34px; text-align: center; color: var(--muted); font-size: 13.5px; }
.folio-total { display: flex; flex-direction: column; gap: 6px; border-top: 2px solid var(--border); padding-top: 10px; }
.folio-total .row { display: flex; justify-content: space-between; font-size: 13px; }
.folio-total .row.grand { font-size: 16px; font-weight: 750; border-top: 1px solid var(--border); padding-top: 8px; }
.folio-total .row.balance { color: var(--red); font-weight: 700; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.invoice-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.bar-chart { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 10px; }
.bar-chart .bar { flex: 1; background: linear-gradient(180deg, #3b82f6, #1d4ed8); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bar-chart .bar:hover::after { content: attr(data-label); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; font-size: 11px; padding: 3px 7px; border-radius: 5px; white-space: nowrap; z-index: 5; }
