:root {
  --bg: #0a0f1c;
  --grid-line: rgba(120, 150, 200, 0.05);
  --panel: #111a2e;
  --panel-2: #172440;
  --border: #26365a;
  --wall: #3d5480;
  --text: #dbe4f5;
  --text-dim: #7e8fb3;
  --accent: #4f7cff;

  --available: #1f8a52;
  --available-b: #3fb87c;
  --mine: #3b6fe0;
  --mine-b: #7ba0ef;
  --half: #b8862f;
  --taken: #3a4560;
  --taken-b: #545f80;
  --selected: #e0a52f;
  --released: #8a5cf0;
  --released-b: #a684f5;
  --not-bookable: #1a2033;
  --danger: #d9534f;

  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Roboto Mono", monospace;
  --sans: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--text);
}

.mono { font-family: var(--mono); }
.dim { color: var(--text-dim); font-size: 12.5px; }

.app-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.app-header h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: 0.01em; }
.app-header-sub { font-size: 11.5px; color: var(--text-dim); font-weight: 400; margin-left: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.app-header a { color: var(--text-dim); text-decoration: none; margin-left: 16px; }
.app-header a:hover { color: var(--text); }

.app-layout { display: flex; gap: 16px; padding: 16px; align-items: flex-start; }

.floor-panel {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  min-width: 0;
}

.side-panel {
  width: 340px;
  flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  position: sticky;
  top: 16px;
}

/* --- Controls bar --- */
.controls-bar {
  display: flex;
  gap: 20px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.controls-bar-secondary { align-items: center; }

.control-group { display: flex; flex-direction: column; gap: 5px; }
.control-group.grow { flex: 1; min-width: 200px; }
.control-group > label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); }

input[type="date"], input[type="search"], select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 7px 9px;
  font-size: 13.5px;
  font-family: var(--sans);
}
input[type="search"] { width: 100%; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.date-caption { color: var(--text-dim); font-size: 12px; margin-top: 2px; }

.quick-picks, .chip-row { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}
.chip:hover { border-color: var(--wall); color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.segmented { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.segment {
  background: var(--panel-2);
  color: var(--text-dim);
  border: none;
  border-right: 1px solid var(--border);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--sans);
  text-align: center;
}
.segment:last-child { border-right: none; }
.segment small { display: block; font-size: 10px; color: inherit; opacity: 0.75; font-family: var(--mono); margin-top: 1px; }
.segment[aria-checked="true"] { background: var(--accent); color: #fff; }

.occupancy { min-width: 200px; }
.occ-bar { width: 100%; height: 8px; border-radius: 4px; background: var(--not-bookable); overflow: hidden; display: flex; }
.occ-bar-fill { height: 100%; background: var(--half); transition: width 0.2s ease; }

.legend { display: flex; gap: 16px; margin-bottom: 12px; font-size: 12px; color: var(--text-dim); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.glyph-swatch {
  width: 16px; height: 16px; border-radius: 3px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-family: var(--mono); color: #fff; flex-shrink: 0;
}
.glyph-swatch.available { background: var(--available); }
.glyph-swatch.mine { background: var(--mine); }
.glyph-swatch.half_day_left { background: repeating-linear-gradient(45deg, var(--available) 0 4px, var(--taken) 4px 8px); }
.glyph-swatch.taken { background: var(--taken); }
.glyph-swatch.selected { background: var(--selected); color: #1a1205; }
.glyph-swatch.released_office { background: var(--released); }
.glyph-swatch.not_bookable { background: var(--not-bookable); border: 1px dashed var(--wall); color: var(--text-dim); }

.map-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }

/* --- Spatial floor map ---
   Desk positions come from x_pct/y_pct (percent of the map's own box), so the
   map container's aspect-ratio must match the source floor-plan drawing
   (1215:483) for those percentages to place desks correctly relative to walls
   and each other. Zoom/pan is a CSS transform on #floorMap itself, so the
   percentage layout inside never has to change - see zoomPan in booking.js. */
.map-scroll {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
}

.map {
  position: relative;
  width: 100%;
  aspect-ratio: 1215 / 483;
  transform-origin: center center;
  cursor: grab;
}
.map.panning { cursor: grabbing; }

.map-inner { position: absolute; inset: 0; }

.room-box {
  position: absolute;
  border: 1.5px solid var(--wall);
  background: rgba(61, 84, 128, 0.08);
  border-radius: 4px;
}
.room-box .room-label {
  position: absolute;
  top: 5px;
  left: 7px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #93a7cf;
  text-transform: uppercase;
  font-family: var(--mono);
}
.room-box.released { border-color: var(--released); background: rgba(138, 92, 240, 0.12); }

.zone-label {
  position: absolute;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: #435170;
  text-transform: uppercase;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  font-family: var(--mono);
}

.desk {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 3.55%;
  height: 6.4%;
  border-radius: 3px;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  padding: 0;
  color: #fff;
  font-family: inherit;
  line-height: 1;
}
.desk-id { font-family: var(--mono); font-size: 9px; font-weight: 650; letter-spacing: -0.02em; }
.desk-glyph { font-size: 8px; }

.desk.available { background: var(--available); border-color: var(--available-b); }
.desk.taken { background: var(--taken); border-color: var(--taken-b); color: #aab4cf; cursor: not-allowed; }
.desk.mine { background: var(--mine); border-color: var(--mine-b); }
.desk.half_day_left {
  background: repeating-linear-gradient(45deg, var(--available) 0 5px, var(--taken) 5px 10px);
  border-color: var(--available-b);
}
.desk.not_bookable {
  background: var(--not-bookable);
  border: 1px dashed var(--wall);
  color: var(--text-dim);
  cursor: not-allowed;
}
.desk.released_office { background: var(--released); border-color: var(--released-b); }
.desk[aria-pressed="true"] {
  background: var(--selected) !important;
  border-color: #ffd166;
  color: #1a1205;
  box-shadow: 0 0 0 2px rgba(224, 165, 47, 0.4);
}
.desk[aria-pressed="true"] .desk-id, .desk[aria-pressed="true"] .desk-glyph { color: #1a1205; }
.desk:disabled { pointer-events: none; }
.desk:focus-visible { outline: 2px solid #fff; outline-offset: 2px; z-index: 2; }

.desk.dim { opacity: 0.22; }
.desk.hit:not(.dim) { box-shadow: 0 0 0 2px #fff; z-index: 1; }

@media (prefers-reduced-motion: no-preference) {
  .desk { transition: transform 0.1s ease, box-shadow 0.1s ease; }
  .desk:hover:not(:disabled) { transform: translate(-50%, -50%) scale(1.08); }
  .occ-bar-fill { transition: width 0.25s ease; }
}

/* Below 720px the CAD-scale map is unusable however it's squeezed - swap to a
   zone-grouped list instead of trying to shrink a 1215:483 canvas further. */
@media (max-width: 720px) {
  .map-scroll, .map-toolbar { display: none; }
  .zone-list { display: block !important; }
  .app-layout { flex-direction: column; }
  .side-panel { width: auto; position: static; }
}

.zone-list { display: none; }
.zone-list-group { margin-bottom: 16px; }
.zone-list-group h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin: 0 0 8px; }
.zone-list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 6px;
  background: var(--panel-2);
}
.zone-list-row .desk-id-full { font-family: var(--mono); font-weight: 650; min-width: 76px; }
.zone-list-row button.list-select { margin-left: auto; }

.alert-region {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(217, 83, 79, 0.12);
  border: 1px solid var(--danger);
  color: #ffb3b0;
  font-size: 13px;
}
.alert-region:empty { display: none; }

.pdpa-note {
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 14px;
  line-height: 1.4;
}

.detail-panel { margin-bottom: 12px; min-height: 40px; }
.detail-panel .dh-id { font-family: var(--mono); font-size: 18px; font-weight: 700; }
.detail-panel .status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
  margin-left: 8px;
}
.detail-panel dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13px; margin: 10px 0; }
.detail-panel dt { color: var(--text-dim); }
.detail-panel dd { margin: 0; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag { font-size: 11px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; color: var(--text-dim); }
.explain-copy { font-size: 12.5px; color: var(--text-dim); margin-top: 8px; line-height: 1.5; }

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 13.5px;
  font-family: var(--sans);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.danger { background: var(--danger); }
.btn.secondary { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }

.my-booking-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.my-booking-row .mono { font-size: 13px; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 13.5px;
  font-family: var(--mono);
}
.toast.error { border-color: var(--danger); }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in 0.15s ease; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

/* --- Centered single-card pages (sign-in, check-in) - moved out of inline
   style="" attributes so these pages can eventually run under a real CSP
   (see CLAUDE.md's security audit: contentSecurityPolicy is currently off
   specifically because of inline styles like these). --- */
.center-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.center-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 36px 32px;
  text-align: center;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.6);
}

.auth-mark {
  width: 46px;
  height: 46px;
  margin: 0 auto 18px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #7ba0ef);
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.auth-title { margin: 0 0 10px; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.auth-subtitle { color: var(--text-dim); font-size: 13.5px; line-height: 1.5; margin: 0 0 26px; }

.btn-microsoft { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 11px 16px; }

.checkin-desk-id { font-family: var(--mono); font-size: 20px; font-weight: 700; margin: 0; }
.checkin-status { color: var(--text-dim); margin: 16px 0; font-size: 13.5px; }

/* --- Light professional theme, sign-in page only (book.html/checkin.html
   keep the dark blueprint look for now - ask if that should change too).
   Drop a photo at public/images/login-hero.jpg and it appears automatically
   under a light overlay; until then this just renders as a soft gradient. */
body.theme-light {
  --panel: #ffffff;
  --panel-2: #f3f6fb;
  --border: #dde4f0;
  --text: #1b2540;
  --text-dim: #5b6b8c;
  background-color: #eef2fa;
  background-image:
    linear-gradient(180deg, rgba(238, 242, 250, 0.92), rgba(238, 242, 250, 0.97)),
    url("/static/images/InCorp-Ascentium.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}
body.theme-light .center-card {
  box-shadow: 0 20px 50px -24px rgba(31, 41, 66, 0.18);
}
