:root {
  --bg-dark: #0a1628;
  --bg-panel: #111d33;
  --bg-card: #152238;
  --border: #1e3a5f;
  --text: #e8f0fe;
  --text-muted: #8ba3c7;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --danger: #ef4444;
  --warning: #f59e0b;
  --incomplete: #e11d48;
  --partial: #eab308;
  --complete: #22c55e;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

/* Screens */
.screen {
  display: none;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  position: relative;
}
.screen.active {
  display: flex;
}

/* Blueprint background */
.blueprint-bg {
  position: absolute;
  inset: 0;
  background: 
    linear-gradient(rgba(10,22,40,0.85), rgba(10,22,40,0.9)),
    url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h100v100H0z' fill='%230a1628'/%3E%3Cpath d='M0 20h100M0 40h100M0 60h100M0 80h100M20 0v100M40 0v100M60 0v100M80 0v100' stroke='%231e3a5f' stroke-width='0.5'/%3E%3C/svg%3E");
  background-size: cover, 60px 60px;
  z-index: 0;
}

/* Sign In */
#signInScreen {
  align-items: center;
  justify-content: center;
}
.sign-in-card, .project-card {
  position: relative;
  z-index: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow);
  text-align: center;
}
.sign-in-card h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 0.25rem;
}
.subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}
.hint {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Project Select */
#projectScreen {
  align-items: center;
  justify-content: center;
}
.project-card h2 {
  margin-bottom: 1.5rem;
  font-size: 1.4rem;
}
.project-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}
.project-item {
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.project-item:hover, .project-item.selected {
  border-color: var(--accent);
  background: rgba(34, 197, 94, 0.1);
}
.project-item .check {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: transparent;
}
.project-item.selected .check {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.welcome {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}

/* Main App Layout */
#mainScreen {
  display: none;
  flex-direction: row;
}
#mainScreen.active {
  display: flex;
}

.sidebar {
  width: 240px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-header h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.sidebar select, .unit-selector select {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.95rem;
}
.floor-selector label, .unit-selector label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.floor-btns {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.floor-btn {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.floor-btn:hover, .floor-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.floor-btn.small {
  font-size: 0.75rem;
  padding: 0.45rem;
}
.floor-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.extra-floors {
  display: flex;
  gap: 0.4rem;
}

/* Plan View */
.plan-view {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0d1a2d;
}
.plan-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}
.plan-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}
.status-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.legend {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.legend i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}
.legend.incomplete i { background: var(--incomplete); }
.legend.complete i { background: var(--complete); }
.legend.partial i { background: var(--partial); }

.plan-container {
  flex: 1;
  min-height: 0; /* critical for flex child to shrink and get real height */
  overflow: hidden;
  padding: 0;
  display: block;
  position: relative;
  touch-action: none;
  cursor: grab;
  background: 
    linear-gradient(rgba(13,26,45,0.7), rgba(13,26,45,0.85)),
    repeating-linear-gradient(0deg, transparent, transparent 19px, #1e3a5f22 19px, #1e3a5f22 20px),
    repeating-linear-gradient(90deg, transparent, transparent 19px, #1e3a5f22 19px, #1e3a5f22 20px);
}
.plan-container.is-panning {
  cursor: grabbing;
}
.plan-container.is-fallback {
  overflow: auto;
  padding: 1.5rem;
  cursor: default;
  touch-action: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-content: flex-start;
}

/* Unit Cards on Plan */
.unit-card {
  width: 90px;
  height: 70px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 2px solid transparent;
  position: relative;
  font-weight: 700;
  font-size: 1.1rem;
  user-select: none;
}
.unit-card:hover, .unit-card.selected {
  transform: scale(1.06);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.4);
  z-index: 2;
}
.unit-card.incomplete {
  background: rgba(225, 29, 72, 0.25);
  border-color: var(--incomplete);
  color: #fda4af;
}
.unit-card.complete {
  background: rgba(34, 197, 94, 0.25);
  border-color: var(--complete);
  color: #86efac;
}
.unit-card.partial {
  background: rgba(249, 115, 22, 0.25);
  border-color: var(--partial);
  color: #fdba74;
}
.unit-card .unit-type {
  font-size: 0.65rem;
  font-weight: 500;
  opacity: 0.85;
  margin-top: 2px;
}
.unit-card .task-count {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* Details Panel */
.details-panel {
  width: 320px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.details-header h3 {
  font-size: 1rem;
}
.details-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}
.empty-state {
  color: var(--text-muted);
  text-align: center;
  margin-top: 3rem;
  font-size: 0.95rem;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.task-item {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 0.75rem;
  border-left: 4px solid var(--incomplete);
  cursor: pointer;
  transition: background 0.15s;
}
.task-item:hover {
  background: #1a2d4a;
}
.task-item.done {
  border-left-color: var(--complete);
  opacity: 0.75;
}
.task-item .task-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
}
.task-item .task-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 1rem 0 0.5rem;
}

.measurement-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.measurement-field {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 0.6rem;
}
.measurement-field label {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.25rem;
}
.measurement-field input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.notes-box {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 60px;
}

.action-btns {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.btn.primary {
  background: var(--accent);
  color: #fff;
}
.btn.primary:hover {
  background: var(--accent-hover);
}
.btn.secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:hover {
  background: #1a2d4a;
}
.btn.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}
.btn.ghost:hover {
  color: var(--text);
  border-color: var(--border);
}
.btn.full {
  width: 100%;
}
.btn.danger {
  background: var(--danger);
  color: #fff;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.25rem;
}
.close-btn:hover {
  color: var(--text);
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
  text-align: left;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}
.form-row {
  display: flex;
  gap: 0.75rem;
}
.form-row .form-group {
  flex: 1;
}
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text);
}
.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.task-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
.task-toggles label {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  min-width: 7.5rem;
  user-select: none;
}
.task-toggles label:has(input:checked) {
  border-color: var(--accent);
  background: rgba(34, 197, 94, 0.12);
}
.task-toggles label:has(#taskBillable:checked) {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
}
.task-toggles input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal.active {
  display: flex;
}
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 1.05rem;
}
.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* Photo Upload */
.photo-upload input[type="file"] {
  margin-bottom: 0.5rem;
}
.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.photo-thumb {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
  display: block;
}
.photo-thumb-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}
.photo-delete-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: #e11d48;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  z-index: 2;
  padding: 0;
}
.photo-delete-btn:hover {
  background: #be123c;
}

/* Photo Viewer */
.photo-viewer {
  max-width: 92vw;
  max-height: 92vh;
  width: min(960px, 92vw);
  background: #000;
  position: relative;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.photo-viewer-stage {
  position: relative;
  width: 100%;
  height: min(78vh, 720px);
  overflow: hidden;
  background: #0a0a0a;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.photo-viewer-stage.is-panning {
  cursor: grabbing;
}
.photo-viewer-transform {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
  line-height: 0;
}
.photo-viewer-transform img,
#photoViewerImg {
  display: block;
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
  pointer-events: none;
  -webkit-user-drag: none;
}
.photo-viewer-delete-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  width: auto;
  height: auto;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.9);
  background: #e11d48;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.45);
  pointer-events: auto;
}
.photo-viewer-delete-btn:hover {
  background: #be123c;
}
/* Close viewer: upper right */
.photo-viewer > .close-btn {
  top: 8px;
  right: 8px;
  left: auto;
  z-index: 6;
}
.photo-viewer .close-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  color: #fff;
  z-index: 2;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  width: 36px;
  height: 36px;
}
.photo-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem;
  color: #fff;
}
.photo-nav button {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
}

/* ---------- Unit Type Plan ---------- */
.unit-type-modal {
  width: min(1000px, 96vw) !important;
  max-width: 96vw !important;
}
.unit-type-body {
  padding: 0.75rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
}
.unit-type-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.unit-type-stage {
  position: relative;
  width: 100%;
  height: min(70vh, 640px);
  overflow: hidden;
  background: #0a0a0a;
  border: 1px solid var(--border);
  border-radius: 8px;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.unit-type-stage.is-panning {
  cursor: grabbing;
}
.unit-type-stage.is-panning .unit-type-hotspot-label {
  visibility: hidden;
}
.unit-type-transform {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  line-height: 0;
}
.unit-type-transform img,
#unitTypeImg {
  display: block;
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.unit-type-zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  justify-content: center;
}
.unit-type-zoom-controls button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}
.unit-type-zoom-controls button:hover {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}
#unitTypeZoomLabel {
  min-width: 3.2rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.unit-type-hotspot {
  /* Match Unity unit-level fixture color (green ~0.1, 0.8, 0.2 @ 0.5) */
  position: absolute;
  border: 2px solid rgba(34, 197, 94, 0.95);
  background: rgba(26, 204, 51, 0.50);
  border-radius: 2px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  z-index: 5;
  /* Pixel mins only — never inflate % width/height (Unity uses exact DB rects) */
  min-width: 18px;
  min-height: 14px;
}
.unit-type-hotspot:hover {
  background: rgba(34, 197, 94, 0.70);
  border-color: #4ade80;
}
.unit-type-hotspot-label {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 3px #000, 0 1px 2px #000;
  white-space: nowrap;
  padding: 0 2px;
  pointer-events: none;
}
.unit-type-stage.is-panning .unit-type-hotspot {
  pointer-events: none;
}
.unit-type-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---------- Reports ---------- */
.reports-modal {
  width: min(1400px, 98vw) !important;
  max-width: 98vw !important;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
}
.reports-body {
  padding: 0.85rem 1.15rem 1.15rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
}
.reports-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.reports-presets .btn {
  font-size: 0.8rem;
  padding: 0.4rem 0.7rem;
}
.reports-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 0.75rem 1rem;
}
.reports-filters .form-group {
  margin: 0;
  min-width: 0;
}
.reports-filters label {
  font-size: 0.75rem;
  margin-bottom: 0.3rem;
}
.reports-filters select,
.reports-filters input[type="date"],
.reports-filters input[type="text"] {
  width: 100%;
  min-width: 0;
  font-size: 0.9rem;
  padding: 0.55rem 0.65rem;
}
.reports-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.reports-count {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.reports-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 220px;
  max-height: 52vh;
  background: var(--bg-card);
}
.reports-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.reports-table th {
  position: sticky;
  top: 0;
  background: var(--bg-panel);
  color: var(--text-muted);
  text-align: left;
  font-weight: 600;
  padding: 0.5rem 0.55rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.reports-table td {
  padding: 0.42rem 0.55rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.reports-table tbody tr:hover {
  background: rgba(255,255,255,0.04);
  cursor: pointer;
}
.reports-table .empty-state {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
}
.rpt-status {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.rpt-status.open { background: rgba(244,63,94,0.2); color: #fb7185; }
.rpt-status.done { background: rgba(34,197,94,0.2); color: #4ade80; }
.rpt-desc {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mat-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.mat-filters {
  grid-template-columns: repeat(2, minmax(200px, 1fr));
  max-width: 640px;
}
.mat-columns {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 0.85rem;
  min-height: 0;
  flex: 1;
}
.mat-columns .reports-table-wrap {
  max-height: 58vh;
}
.mat-section-title {
  margin: 0;
  padding: 0.55rem 0.65rem 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@media (max-width: 900px) {
  .reports-filters {
    grid-template-columns: repeat(2, 1fr);
  }
  .reports-table-wrap {
    max-height: 40vh;
  }
  .mat-columns {
    grid-template-columns: 1fr;
  }
}

/* Mobile Responsive */
@media (max-width: 900px) {
  #mainScreen {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.75rem;
    gap: 0.75rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .sidebar-header, .floor-selector, .unit-selector {
    flex: 1;
    min-width: 120px;
  }
  .sidebar .btn {
    flex: 1;
    min-width: 100px;
  }
  .plan-view {
    flex: 1 1 auto;
    min-height: 40vh; /* ensure plan area has real height on tablets */
  }
  .plan-container {
    min-height: 35vh;
  }
  .details-panel {
    width: 100%;
    max-height: 40vh;
    border-left: none;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
  }
  .plan-container.is-fallback {
    padding: 1rem;
  }
  .unit-card {
    width: 76px;
    height: 60px;
    font-size: 0.95rem;
  }
}

@media (max-width: 500px) {
  .sign-in-card, .project-card {
    padding: 1.75rem 1.25rem;
  }
  .status-legend {
    display: none;
  }
}

/* ===== Real Plan Image + Hotspots ===== */
.plan-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  /* Limit compositor layer size on mobile GPUs */
  contain: strict;
  background: #0d1a2d;
}

.plan-image-wrapper {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  line-height: 0;
  background: #0d1a2d;
  border-radius: 8px;
  overflow: visible;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transform-origin: 0 0;
  /* no will-change: on Android it promotes a huge layer and causes black tiles */
  user-select: none;
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  -webkit-user-select: none;
}

.plan-image-wrapper img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  user-select: none;
  pointer-events: none;
  -webkit-user-drag: none;
  image-rendering: auto;
}

.plan-zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.plan-zoom-controls button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
.plan-zoom-controls button:hover {
  background: var(--bg-card);
  border-color: var(--accent);
}
.plan-zoom-label {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(10,22,40,0.85);
  border-radius: 6px;
  padding: 2px 4px;
}

.hotspot {
  position: absolute;
  border: 2px solid rgba(34, 197, 94, 0.7);
  background: rgba(34, 197, 94, 0.15);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  touch-action: none;
  pointer-events: auto;
  z-index: 5;
}
.hotspot-label {
  pointer-events: none;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
  color: #fff;
  text-shadow:
    0 0 3px #000,
    0 1px 2px #000,
    1px 0 2px #000,
    -1px 0 2px #000;
  white-space: nowrap;
  transform-origin: center center;
}

.hotspot:hover {
  filter: brightness(1.15);
  z-index: 10;
}

/* Strong selection ring — very thick so it stays visible when zoomed out */
.hotspot.selected {
  z-index: 20 !important;
  border-color: #22d3ee !important;
  border-width: 14px !important;
  outline: 10px solid rgba(34, 211, 238, 0.95);
  outline-offset: 6px;
  box-shadow:
    0 0 0 12px rgba(34, 211, 238, 1),
    0 0 0 28px rgba(34, 211, 238, 0.55),
    0 0 0 44px rgba(14, 165, 233, 0.3),
    0 0 50px rgba(34, 211, 238, 0.85) !important;
  animation: hotspot-pulse 1.4s ease-in-out 2;
}
.hotspot.selected .hotspot-label {
  color: #e0f2fe !important;
  text-shadow:
    0 0 4px #000,
    0 0 8px rgba(34, 211, 238, 0.9),
    0 1px 2px #000;
}

@keyframes hotspot-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 12px rgba(34, 211, 238, 1),
      0 0 0 28px rgba(34, 211, 238, 0.55),
      0 0 0 44px rgba(14, 165, 233, 0.3),
      0 0 50px rgba(34, 211, 238, 0.85);
  }
  50% {
    box-shadow:
      0 0 0 16px rgba(34, 211, 238, 1),
      0 0 0 36px rgba(34, 211, 238, 0.45),
      0 0 0 56px rgba(14, 165, 233, 0.22),
      0 0 70px rgba(34, 211, 238, 0.95);
  }
}

.hotspot.incomplete {
  border-color: #e11d48 !important;
  background: rgba(225, 29, 72, 0.35) !important;
  color: #fecdd3;
}
.hotspot.incomplete:hover {
  background: rgba(225, 29, 72, 0.55) !important;
}

.hotspot.partial {
  border-color: #eab308 !important;
  background: rgba(234, 179, 8, 0.35) !important;
  color: #fef08a;
}
.hotspot.partial:hover {
  background: rgba(234, 179, 8, 0.55) !important;
}

.hotspot.complete {
  border-color: #22c55e !important;
  background: rgba(34, 197, 94, 0.4) !important;
  color: #bbf7d0;
}
.hotspot.complete:hover {
  background: rgba(34, 197, 94, 0.6) !important;
}

/* neutral when no task data */
.hotspot.none {
  border-color: rgba(148, 163, 184, 0.6) !important;
  background: rgba(148, 163, 184, 0.15) !important;
  color: #e2e8f0;
}

.plan-loading {
  color: var(--text-muted);
  padding: 3rem;
  text-align: center;
  width: 100%;
}

/* ---------- Progress / Status Descriptions ---------- */
.progress-modal {
  width: min(760px, 96vw) !important;
  max-width: 96vw !important;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
}
.progress-body {
  padding: 0.85rem 1.15rem 1.15rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  flex: 1;
}
.progress-banner {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: var(--text);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  line-height: 1.35;
}
.progress-pickers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}
.progress-pickers .form-group {
  margin: 0;
}
.progress-pickers label,
.progress-attach label {
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}
.progress-summary {
  font-size: 0.9rem;
  color: var(--text-muted);
}
.progress-unit-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.progress-selected-count {
  margin-left: auto;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}
.progress-checklist-wrap {
  overflow-y: auto;
  min-height: 140px;
  max-height: 42vh;
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.progress-unit-list {
  display: flex;
  flex-direction: column;
  padding: 0.35rem;
}
.progress-unit-row {
  display: grid;
  grid-template-columns: auto 3.25rem 1fr;
  gap: 0.55rem;
  align-items: center;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.progress-unit-row:last-child {
  border-bottom: none;
}
.progress-unit-row:hover {
  background: rgba(255,255,255,0.04);
}
.progress-unit-row.is-selected {
  background: rgba(59, 130, 246, 0.16);
  outline: 1px solid rgba(59, 130, 246, 0.45);
}
.progress-unit-row input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: #3b82f6;
}
.progress-unit-id {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.9rem;
}
.progress-unit-label {
  font-size: 0.88rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.progress-attach {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: end;
}
.progress-attach .form-group {
  margin: 0;
}
.progress-confirm {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: var(--text);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.progress-readonly-wrap {
  border-top: 1px solid var(--border);
  padding-top: 0.55rem;
}
.progress-readonly-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.progress-readonly {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.progress-chip {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
  font-size: 0.75rem;
}
.progress-readonly-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
}
@media (max-width: 640px) {
  .progress-pickers,
  .progress-attach {
    grid-template-columns: 1fr;
  }
  .progress-selected-count {
    margin-left: 0;
  }
}

/* ---------- Fixture Submittal PDF modal ---------- */
.fixture-submittal-modal {
  width: min(960px, 96vw) !important;
  max-width: 96vw !important;
  height: min(90vh, 900px);
  display: flex;
  flex-direction: column;
  background: #1a1a1a;
  color: #fff;
}
.fixture-submittal-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.fixture-submittal-modal .modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  color: #fff;
}
.fixture-submittal-body {
  flex: 1;
  min-height: 0;
  background: #111;
}
.fixture-submittal-body iframe {
  width: 100%;
  height: 100%;
  min-height: 60vh;
  border: 0;
  background: #222;
}
.fixture-submittal-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.65rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.12);
  color: #fff;
}
.fixture-submittal-nav button {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 0.95rem;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
}
.fixture-submittal-nav button:disabled {
  opacity: 0.35;
  cursor: default;
}
.fixture-submittal-nav button:not(:disabled):hover {
  background: rgba(255,255,255,0.28);
}
.fixture-submittal-page-num {
  opacity: 0.75;
  font-size: 0.9rem;
}
.fixture-submittal-close-text {
  margin-left: 0.5rem;
}

/* ===== Site plan (Back to Site) ===== */
.site-plan-notice {
  flex-shrink: 0;
  margin: 0 1rem 0.5rem;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(234, 179, 8, 0.12);
  color: #fde68a;
  font-size: 0.85rem;
  font-weight: 600;
}
.site-plan-notice[hidden] {
  display: none !important;
}
.hotspot.hotspot-site {
  border-radius: 50%;
  border: 3px solid #eab308;
  background: rgba(234, 179, 8, 0.28);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
  pointer-events: auto;
  z-index: 6;
}
.hotspot.hotspot-site:hover {
  background: rgba(234, 179, 8, 0.42);
  border-color: #facc15;
}
.hotspot.hotspot-site .hotspot-label {
  white-space: normal;
  text-align: center;
  max-width: 92%;
  font-size: 11px;
  pointer-events: none;
}
.plan-container.is-site-view .status-legend {
  opacity: 0.45;
}
