:root {
  --bg: #f5f3f9;
  --panel: #ffffff;
  --ink: #241a33;
  --muted: #6f6787;
  --line: #e2ddec;
  --brand: #5b3a8e;
  --brand-dark: #472c73;
  --danger: #e5484d;
  --ok: #2f9e6e;
  --warn: #e8930c;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(40, 28, 65, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}

button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 14px;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 6px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2c1a4d 0%, #5b3a8e 100%);
}
.login-card {
  width: min(400px, 92vw);
  background: var(--panel);
  border-radius: 16px;
  padding: 36px;
  box-shadow: 0 20px 60px rgba(10, 20, 50, 0.35);
}
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); margin-bottom: 24px; font-size: 14px; }
.login-card .logo-img { width: 100%; max-width: 280px; margin-bottom: 20px; display: block; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfe;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
}
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 10px; }

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.sidebar {
  background: #2c1a4d;
  color: #c6cde0;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar .brand {
  color: #fff; font-weight: 700; font-size: 17px;
  padding: 6px 12px 20px; display: flex; align-items: center; gap: 10px;
}
.sidebar .brand .dot { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; }
.sidebar .brand-mark { width: 34px; height: 34px; background: #fff; border-radius: 9px; padding: 2px; }
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; color: inherit;
  padding: 10px 12px; border-radius: 8px; text-align: left; width: 100%;
  font-size: 14px;
}
.nav-btn:hover { background: rgba(255, 255, 255, 0.07); }
.nav-btn.active { background: var(--brand); color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .whoami { font-size: 12px; padding: 8px 12px; color: #8791ab; }

.main { padding: 24px 28px; max-width: 1300px; }

.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.topbar h2 { font-size: 20px; flex: 0 0 auto; }
.searchbox { position: relative; flex: 1; max-width: 420px; }
.searchbox input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 14px; background: var(--panel);
}
.search-results {
  position: absolute; top: 110%; left: 0; right: 0; z-index: 50;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 380px; overflow: auto; display: none;
}
.search-results.open { display: block; }
.search-results .group { padding: 8px 12px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.search-results .hit { padding: 8px 12px; cursor: pointer; font-size: 14px; }
.search-results .hit:hover { background: var(--bg); }

/* ---------- Panels / tables ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h3 { font-size: 15px; }
.panel-body { padding: 18px; }

table.grid { width: 100%; border-collapse: collapse; }
table.grid th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line);
}
table.grid td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr:hover td { background: #f8faff; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.pill-room { background: #e8eeff; color: var(--brand-dark); }
.pill-special { background: #fff3e0; color: var(--warn); }
.pill-cat { background: #eef2f8; color: var(--muted); }
.pill-admin { background: #e8eeff; color: var(--brand-dark); }
.pill-staff { background: #e6f6ee; color: var(--ok); }
.pill-off { background: #fdecec; color: var(--danger); }

.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; }

/* ---------- Stats / reports ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .num { font-size: 28px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 2px; }

.cap-bar { background: #edf1f8; border-radius: 99px; height: 8px; overflow: hidden; min-width: 90px; }
.cap-bar > div { height: 100%; border-radius: 99px; background: var(--brand); }
.cap-bar > div.full { background: var(--danger); }

/* ---------- Calendar ---------- */
.cal-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-toolbar .title { font-size: 17px; font-weight: 700; min-width: 190px; text-align: center; }
.cal-toolbar .grow { flex: 1; }

.cal-month { display: grid; grid-template-columns: repeat(7, 1fr); border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
.cal-month .dow {
  padding: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted);
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #f8faff; text-align: center;
}
.cal-cell {
  min-height: 104px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 6px; background: var(--panel); position: relative; cursor: pointer;
}
.cal-cell.other { background: #f6f8fc; color: #a8b0c5; }
.cal-cell:hover { background: #f2f6ff; }
.cal-cell .dnum { font-size: 12px; font-weight: 700; }
.cal-cell.today .dnum {
  background: var(--brand); color: #fff; border-radius: 99px;
  width: 22px; height: 22px; display: inline-grid; place-items: center;
}
.cal-evt {
  font-size: 11px; border-radius: 5px; padding: 2px 6px; margin-top: 3px;
  color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-evt.special { outline: 2px solid var(--warn); outline-offset: -1px; }
.cal-more { font-size: 11px; color: var(--muted); margin-top: 2px; }

.week-list .day-block { border-bottom: 1px solid var(--line); padding: 12px 18px; }
.week-list .day-block:last-child { border-bottom: 0; }
.week-list .day-head { font-weight: 700; margin-bottom: 8px; }
.week-list .day-head.today { color: var(--brand); }
.evt-row {
  display: flex; align-items: center; gap: 12px; padding: 7px 10px;
  border-radius: 8px; border-left: 4px solid var(--brand); background: #f8faff; margin-bottom: 6px;
}
.evt-row .time { font-weight: 700; font-size: 13px; min-width: 96px; }
.evt-row .name { flex: 1; }
.evt-row .actions { display: flex; gap: 6px; }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(15, 22, 40, 0.55);
  display: none; place-items: center; z-index: 100; padding: 20px;
}
.modal-back.open { display: grid; }
.modal {
  width: min(560px, 96vw); max-height: 92vh; overflow: auto;
  background: var(--panel); border-radius: 14px; padding: 24px;
}
.modal h3 { margin-bottom: 18px; }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.check-line { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 14px; }
.dow-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.dow-picker label {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
  font-size: 13px; cursor: pointer; user-select: none;
}
.dow-picker input { display: none; }
.dow-picker label:has(input:checked) { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #1c2333; color: #fff; border-radius: 10px; padding: 12px 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3); opacity: 0; transform: translateY(8px);
  transition: all 0.3s; max-width: 380px; font-size: 14px;
}
.toast.show { opacity: 1; transform: none; }
.toast-error { background: var(--danger); }
.toast-success { background: var(--ok); }
.toast-alert { background: var(--warn); font-weight: 600; }

/* Fleet health */
.nav-badge {
  background: var(--danger); color: #fff; border-radius: 99px;
  font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: auto;
}
.dot-status { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: 0; }
.dot-online { background: var(--ok); }
.dot-stale { background: var(--warn); }
.dot-offline { background: var(--danger); }
.pill-online { background: #e6f6ee; color: var(--ok); }
.pill-stale { background: #fff3e0; color: var(--warn); }
.pill-offline { background: #fdecec; color: var(--danger); }
.mono { font-family: Consolas, "SF Mono", monospace; font-size: 12px; color: var(--muted); }

.send-to { max-height: 130px; overflow: auto; }
.send-to label.all-rooms:has(input:checked) { background: var(--warn); border-color: var(--warn); }

.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 30px; }

/* ---------- Print (Reports → Print report) ---------- */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, #toasts, .btn, .modal-back { display: none !important; }
  .app { display: block; }
  .main { padding: 0; max-width: none; }
  .panel, .stat { box-shadow: none; break-inside: avoid; }
  .stat-row { grid-template-columns: repeat(5, 1fr); }
}

.slide-preview {
  border: 1px solid var(--line); border-radius: 10px;
  background: linear-gradient(160deg, #0b1026, #2c1a4d);
  color: #f2f5ff; min-height: 130px; padding: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 6px;
}
.slide-preview .p-icon { font-size: 30px; line-height: 1; }
.slide-preview .p-title { font-size: 19px; font-weight: 800; }
.slide-preview .p-body { font-size: 14px; opacity: 0.8; }
.slide-preview.takeover { outline: 2px solid var(--warn); }
