﻿:root {
  --bg: #F4F6F9;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #f8f9fc;
  --line: #E0E0E0;
  --text: #333333;
  --muted: #888888;
  --blue: #4F84C4;
  --blue-2: #1D4F8F;
  --green: #38a169;
  --red: #E53935;
  --amber: #d69e2e;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 4px 14px rgba(0,0,0,.06);
  --radius: 10px;
  --bg-grad: #F4F6F9;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg-grad);
  color: var(--text);
}
.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: #4F84C4;
  border-right: 1px solid #3a6fa8;
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  color: #ffffff;
}
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-bottom: 22px; }
.sidebar-logo { width: 100%; height: auto; mix-blend-mode: screen; display: block; cursor: pointer; }
.sidebar-site-label { margin: 0; font-size: 11px; color: #ffffff; }
.nav button, .btn, .input, select, textarea {
  width: 100%; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: inherit;
}
.nav button {
  text-align: left; padding: 10px 12px; cursor: pointer; margin-bottom: 4px;
  background: transparent; border-color: transparent; color: #ffffff; font-size: 14px;
  display: flex; align-items: center; gap: 10px;
}
.nav button svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav button.active, .nav button:hover {
  background: #1D4F8F; border-color: #1D4F8F; color: #ffffff;
}
.sidebar .btn.ghost { background: rgba(255,255,255,.07); color: #ffffff; border-color: rgba(255,255,255,.12); }
.sidebar .btn.ghost:hover { background: rgba(255,255,255,.13); color: #ffffff; }
.nav-group { margin: 10px 0 4px; }
.nav-group-toggle {
  all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; color: #fff; cursor: pointer;
}
.nav-group-toggle svg.lead { width: 16px; height: 16px; flex-shrink: 0; }
.nav-group-toggle .chev { margin-left: auto; width: 14px; height: 14px; transition: transform .15s ease; }
.nav-group-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.nav-group-toggle:hover { background: rgba(255,255,255,.10); }
.nav-sub { display: flex; flex-direction: column; gap: 2px; padding: 4px 0 6px 0; margin-left: 0; }
.nav-sub[hidden] { display: none; }
.nav-sub a {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px;
  font-size: 13px; color: rgba(255,255,255,.85); text-decoration: none; cursor: pointer;
}
.nav-sub a:hover { background: rgba(255,255,255,.10); }
.nav-sub a svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--red); color: #fff; font-size: 10.5px; font-weight: 700;
  min-width: 17px; height: 17px; border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.main { padding: 24px; min-width: 0; }
/* Boxes in a grid may be narrower than their content; a wide table then scrolls in its own box. */
.grid > *, .two-col > *, .three-col > *, .form-grid > *, .room-grid > * { min-width: 0; }
.section { display: none; }
.section.active { display: block; }
.topbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.title h2 { margin: 0; font-size: 28px; }
.title p { margin: 6px 0 0; color: var(--muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { padding: 10px 16px; cursor: pointer; transition: .15s ease; width: auto; font-weight: 500; }
.btn:hover { opacity: .88; }
.btn.primary { background: #1D4F8F; border: none; color: #fff; }
.btn.ghost { background: var(--panel); }
.btn.danger { background: rgba(229,62,62,.1); border-color: rgba(229,62,62,.28); color: #9b1c1c; }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.two-col { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.stat-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.stat-value { font-size: 32px; font-weight: 700; margin: 8px 0 4px; }
.stat-sub { color: #4F84C4; font-size: 12px; }
th { color: #333333; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.input, select, textarea { padding: 11px 12px; }
textarea { min-height: 86px; resize: vertical; }
.room-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.room-card {
  padding: 16px; border-radius: var(--radius); background: var(--panel);
  border: 1px solid var(--line); cursor: pointer; transition: .15s ease;
}
.room-card:hover { transform: translateY(-2px); border-color: rgba(56,189,248,.35); }
.room-card.unavailable, .tenant-item.unavailable { border-color: rgba(229,62,62,.5); background: rgba(254,215,215,.45); }
.room-card.available, .tenant-item.available { border-color: rgba(56,161,105,.5); background: rgba(198,246,213,.45); }
.room-card.full { border-color: rgba(214,158,46,.5); background: rgba(253,246,178,.45); }
.pill.unavailable { background: rgba(229,62,62,.1); border-color: rgba(229,62,62,.35); color: #9b1c1c; }
.pill.available { background: rgba(56,161,105,.1); border-color: rgba(56,161,105,.35); color: #276749; }
.site-check-item { cursor: pointer; -webkit-user-select: none; user-select: none; }
.site-check-item input { width: 18px; height: 18px; cursor: pointer; }
.room-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 10px; }
.room-top h4 { margin: 0 0 6px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.beds { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.bed { padding: 7px 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(56,189,248,.08); font-size: 12px; }
.bed.double { background: rgba(37,99,235,.14); }
.bed.occupied { border-color: rgba(34,197,94,.28); background: rgba(34,197,94,.14); }
.bed.unavailable { border-color: rgba(229,62,62,.5); background: rgba(254,215,215,.45); color: #9b1c1c; }
.tenant-list { display: flex; flex-direction: column; gap: 8px; }
.tenant-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--panel-2); }
.split { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-flex; border: 1px solid rgba(49,130,206,.2); background: rgba(49,130,206,.08); color: #2c5282; padding: 6px 10px; border-radius: 999px; font-size: 12px; }
.pill.ok { background: #38a169; border-color: #38a169; color: #fff; }
.pill.warn { background: #d69e2e; border-color: #d69e2e; color: #fff; }
.pill.danger { background: #e53e3e; border-color: #e53e3e; color: #fff; }
.missing-clock { border-color: rgba(239,68,68,.4); box-shadow: inset 0 0 0 1px rgba(239,68,68,.14); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.footer-note { margin-top: 10px; color: var(--muted); font-size: 12px; }
.hide { display: none !important; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-wrap { display: flex; flex-direction: column; align-items: center; gap: 20px; width: min(420px, 100%); }
.logo-img { width: 240px; height: auto; mix-blend-mode: screen; display: block; transition: transform .1s ease; }
.logo-img-lg { width: 260px; height: auto; mix-blend-mode: screen; }
.logo-login-btn { background: none; border: none; padding: 0; cursor: pointer; display: block; }
.logo-login-btn:active .logo-img { transform: scale(0.94); }
.login-heading { color: #fff; font-size: 15px; font-weight: 700; margin: 4px 0 0; text-align: center; }
.login-helper { color: rgba(255,255,255,.85); font-size: 11px; margin: 0; text-align: center; }
.login-copyright { color: rgba(255,255,255,.75); font-size: 11px; padding: 10px 0 2px; text-align: center; }
.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50; background: rgba(2,6,23,.62); }
.modal.open { display: flex; }
.modal-box { width: min(980px, 100%); max-height: 90vh; overflow: auto; }
.inline-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.profile-layout { display: flex; gap: 14px; align-items: flex-start; }
.profile-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.profile-side { width: 250px; flex-shrink: 0; position: sticky; top: 20px; }
.overview-card h3 { margin: 0 0 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
.overview-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.overview-row:last-child { border-bottom: none; }
.overview-row .k { font-size: 11px; color: var(--muted); }
.overview-row .v { font-size: 12px; font-weight: 600; text-align: right; }
.overview-row .v.owed { color: #9b1c1c; }
.overview-divider { height: 1px; background: var(--line); margin: 8px 0; }
.action-section { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); overflow: hidden; }
.action-section summary {
  cursor: pointer; padding: 11px 14px; font-weight: 600; font-size: 13px; list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.action-section summary::-webkit-details-marker { display: none; }
.action-section summary .chev { color: var(--muted); font-size: 11px; transition: transform .15s ease; }
.action-section[open] summary .chev { transform: rotate(90deg); }
.action-section summary .hint { font-size: 11px; color: var(--muted); font-weight: 400; }
.action-section .action-body { padding: 0 14px 14px; border-top: 1px solid var(--line); padding-top: 12px; }
@media (max-width: 900px) { .profile-layout { flex-direction: column; } .profile-side { width: 100%; position: static; } }

.dropdown { position: relative; display: inline-block; }
.dropdown-menu { display: none; position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 230px; z-index: 30; padding: 6px; overflow: hidden; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: none; background: none; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text); font-family: inherit; border-radius: 8px; }
.dropdown-menu button:hover { background: var(--panel-2); }

/* Searchable tick-list combobox -- reuses .dropdown/.dropdown.open's existing show/hide and
   click-outside-to-close mechanics (see events.js); these classes only add the search-combo's
   own layout and internal panel content on top of that. */
.combo-trigger {
  width: 100%; text-align: left; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; font-size: 13.5px;
  cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.combo-trigger .placeholder { color: var(--muted); }
.combo-trigger .arrow { color: var(--muted); font-size: 11px; transition: transform .15s ease; flex-shrink: 0; }
.dropdown.open .combo-trigger .arrow { transform: rotate(180deg); }
.dropdown.open .combo-trigger { border-color: var(--blue); }
.combo-panel { left: 0; right: 0; width: 100%; min-width: unset; padding: 0; }
.combo-search { padding: 8px; border-bottom: 1px solid var(--line); }
.combo-search input { width: 100%; }
.combo-list { max-height: 260px; overflow-y: auto; padding: 6px; }
.combo-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 7px; cursor: pointer; font-weight: 400; }
.combo-row:hover { background: var(--panel-2); }
.combo-row input { width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; }
.combo-row-meta { font-size: 11.5px; color: var(--muted); margin-left: auto; text-align: right; }
.combo-footer { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-top: 1px solid var(--line); background: var(--panel-2); font-size: 12px; color: var(--muted); }
.combo-footer button { display: inline; width: auto; border: none; background: none; color: var(--blue-2); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; padding: 0; }
.combo-footer button:hover { background: none; text-decoration: underline; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { display: flex; align-items: center; gap: 6px; background: var(--panel-2); color: var(--blue-2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 6px 5px 12px; font-size: 12.5px; font-weight: 500; }
.chip button { border: none; background: rgba(0,0,0,.08); color: inherit; width: 16px; height: 16px; border-radius: 50%; cursor: pointer; font-size: 11px; line-height: 1; display: flex; align-items: center; justify-content: center; padding: 0; }
.chip button:hover { background: rgba(0,0,0,.16); }

.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.site-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; cursor: pointer; transition: .15s ease; }
.site-card:hover { transform: translateY(-2px); border-color: rgba(56,189,248,.35); }
.site-card .site-card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.site-card h4 { margin: 0; font-size: 15px; }
.site-card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.site-card-stats .num { font-size: 17px; font-weight: 700; line-height: 1.1; }
.site-card-stats .lbl { font-size: 10.5px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .3px; }
.site-card .unavail-flag { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 11px; color: #9b1c1c; font-weight: 600; }
.region-block { margin-bottom: 22px; }
.region-block .region-title { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.region-block h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 0; font-weight: 700; }
.region-block .region-line { flex: 1; height: 1px; background: var(--line); }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: #1D4F8F; font-size: 13px; font-weight: 700; cursor: pointer; }

.sub-room-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; margin: 10px 0 5px; }
.sub-room-label:first-of-type { margin-top: 0; }
.empty-slot { border: 1px dashed var(--line); border-radius: 7px; padding: 6px 9px; font-size: 11.5px; color: var(--muted); text-align: center; }

.occ-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; margin-bottom: 6px; background: var(--panel-2); }
.occ-row .bed-tag { font-size: 10px; font-weight: 700; color: var(--muted); background: var(--panel); border: 1px solid var(--line); padding: 2px 7px; border-radius: 5px; flex-shrink: 0; width: 34px; text-align: center; }
.occ-row .occ-name { font-weight: 600; font-size: 13px; flex: 1; }
.occ-row.is-empty .occ-name { color: var(--muted); font-weight: 400; font-style: italic; }
.occ-room-label { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; margin: 14px 0 7px; }
.occ-room-label:first-of-type { margin-top: 0; }
.add-result-row { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; margin-bottom: 6px; }
.add-result-row .name { font-weight: 600; font-size: 12.5px; }
.add-result-row .meta { font-size: 11px; color: var(--muted); flex: 1; }

@media (max-width: 1100px) { .two-col, .three-col, .room-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 12px; }
  /* On a phone the page fits the screen: wide tables scroll sideways in their own box, and
     side-by-side blocks drawn by the page stack in one column. */
  .main table { display: block; overflow-x: auto; }
  .main [style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
  .sidebar { position: relative; height: auto; }
  .form-grid, .two-col, .three-col, .room-grid { grid-template-columns: 1fr; }
}
@media print {
  body * { visibility: hidden; }
  #reportBox, #reportBox * { visibility: visible; }
  #reportBox { position: absolute; left: 0; top: 0; width: 100%; }
}
  
.pie-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:14px; }
.pie-card { padding:14px; border:1px solid var(--line); border-radius:16px; background:var(--panel); box-shadow:var(--shadow); overflow:hidden; min-width:0; }
.pie-wrap { display:flex; align-items:center; gap:14px; min-width:0; }
.pie-chart { width:88px; height:88px; border-radius:50%; flex:0 0 88px; border:5px solid #fff; box-shadow:0 0 0 1px var(--line); overflow:hidden; }
.pie-legend { display:grid; gap:6px; font-size:12px; flex:1; min-width:0; overflow:hidden; }
.pie-legend div { display:flex; align-items:center; justify-content:space-between; gap:6px; min-width:0; }
.pie-legend div span { display:flex; align-items:center; min-width:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; flex:1; }
.pie-legend div strong { white-space:nowrap; flex-shrink:0; }
.pie-legend span.swatch { width:9px; height:9px; border-radius:50%; display:inline-block; margin-right:5px; flex-shrink:0; }
.details-stack { display:grid; gap:10px; }
.details-panel { border:1px solid var(--line); border-radius:14px; padding:10px 12px; background:var(--card); }
.details-panel summary { cursor:pointer; font-weight:700; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.6;transform:scale(.94)} }
#loadingOverlay { position:fixed;inset:0;background:#4F84C4;display:flex;align-items:center;justify-content:center;z-index:9999;flex-direction:column;gap:18px;color:#fff; }
#loadingOverlay .occupy-logo { width:64px;height:64px;animation:pulse 1.4s ease-in-out infinite; }
.login-shell { background:#4F84C4; }
.login-box .brand h1 { color:#1a202c; font-size:20px; }
.login-box .brand p { color:#718096; }
.login-logo { width:44px;height:44px; }
#syncBanner { position:fixed;bottom:16px;right:16px;background:rgba(34,197,94,.15);border:1px solid rgba(34,197,94,.35);color:#bbf7d0;padding:10px 16px;border-radius:12px;font-size:13px;z-index:999;display:none; }
#reportDownloadBanner { position:fixed;bottom:64px;right:16px;background:rgba(34,197,94,.15);border:1px solid rgba(34,197,94,.35);color:#bbf7d0;padding:10px 16px;border-radius:12px;font-size:13px;z-index:999;display:none; }
#inactivityBanner { position:fixed;bottom:16px;left:50%;transform:translateX(-50%);background:rgba(245,158,11,.15);border:1px solid rgba(245,158,11,.45);color:#fde68a;padding:12px 20px;border-radius:12px;font-size:13px;z-index:1000;display:none;text-align:center; }

