/* RenovaGuard app — shared stylesheet */
:root {
  --navy: #0b2545;
  --navy-2: #133156;
  --blue: #1f4ed8;
  --teal: #14b8a6;
  --teal-dark: #0f766e;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --danger: #dc2626;
  --warning: #f59e0b;
  --success: #16a34a;
  --info: #0ea5e9;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.10), 0 4px 8px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "PingFang HK", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top nav ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  padding: 12px 0;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #fff;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.2px;
  text-decoration: none;
}
.brand img {
  height: 44px;
  width: 44px;
  border-radius: 50%;
  background: #fff;
  padding: 3px;
  object-fit: contain;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.18),
    0 0 14px 2px rgba(255, 255, 255, 0.10);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #cbd5e1;
  font-size: 14px;
}
.user-chip strong { color: #fff; font-weight: 600; }
.user-chip .role {
  background: rgba(255,255,255,0.10);
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.user-chip button {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.user-chip button:hover { background: rgba(255,255,255,0.10); }

/* ---------- Layout ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }
.container.narrow { max-width: 760px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}
.page-head h1 { margin: 0 0 4px; font-size: 26px; }
.page-head .sub { color: var(--muted); font-size: 14px; }

/* ---------- Login screen ---------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--navy);
}
@media (max-width: 900px) { .login-shell { grid-template-columns: 1fr; } }
.login-side {
  padding: 60px;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(circle at 20% 20%, rgba(20,184,166,0.18), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(31,78,216,0.20), transparent 50%),
    var(--navy);
}
@media (max-width: 900px) { .login-side { display: none; } }
.login-side .brand img { height: 56px; width: 56px; }
.login-side h1 { font-size: 32px; margin: 0 0 12px; line-height: 1.2; }
.login-side p { color: rgba(255,255,255,0.75); font-size: 15px; max-width: 420px; }
.login-side .footnote { font-size: 12px; color: rgba(255,255,255,0.55); }
.login-form-wrap {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.login-card {
  width: 100%;
  max-width: 380px;
}
.login-card h2 { margin: 0 0 6px; font-size: 22px; }
.login-card .lead { color: var(--muted); font-size: 14px; margin: 0 0 24px; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin: 14px 0 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="date"], input[type="number"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--teal);
  outline-offset: -1px;
  border-color: transparent;
}
textarea { min-height: 90px; resize: vertical; }

button.primary {
  width: 100%;
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
}
button.primary:hover { background: var(--navy-2); }
button.primary:disabled { background: var(--muted); cursor: not-allowed; }

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
button.ghost:hover { background: var(--bg); }

button.teal {
  background: var(--teal);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button.teal:hover { background: var(--teal-dark); }

.error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin: 12px 0;
  display: none;
}
.error-banner.show { display: block; }

.success-banner {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #14532d;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin: 12px 0;
}

/* ---------- Cards & panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.panel + .panel { margin-top: 20px; }
.panel h2, .panel h3 { margin: 0 0 12px; }
.panel h2 { font-size: 18px; }
.panel h3 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- Project cards (homeowner dashboard) ---------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}
.project-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s, box-shadow 0.12s;
}
.project-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--teal);
}
.project-card h3 { margin: 0 0 6px; font-size: 17px; color: var(--text); text-transform: none; letter-spacing: 0; }
.project-card .addr { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.project-card .progress {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}
.project-card .progress > div {
  height: 100%;
  background: var(--teal);
  border-radius: 999px;
}
.project-card .meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Status badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--border);
  color: var(--text);
}
.badge.planning  { background: #e0e7ff; color: #3730a3; }
.badge.in_progress { background: #cffafe; color: #155e75; }
.badge.on_hold   { background: #fef3c7; color: #92400e; }
.badge.completed { background: #dcfce7; color: #166534; }
.badge.disputed  { background: #fee2e2; color: #991b1b; }
.badge.cancelled { background: #f1f5f9; color: #475569; }

.badge.pending             { background: #f1f5f9; color: #475569; }
.badge.awaiting_inspection { background: #fef3c7; color: #92400e; }
.badge.inspector_approved  { background: #cffafe; color: #155e75; }
.badge.owner_approved      { background: #dcfce7; color: #166534; }
.badge.rework_required     { background: #fee2e2; color: #991b1b; }

/* defect statuses */
.badge.open         { background: #fee2e2; color: #991b1b; }
.badge.acknowledged { background: #fef3c7; color: #92400e; }
.badge.in_repair    { background: #cffafe; color: #155e75; }
.badge.resolved     { background: #dcfce7; color: #166534; }
.badge.rejected     { background: #f1f5f9; color: #475569; }

/* defect severity */
.sev { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em; }
.sev.cosmetic { background: #f1f5f9; color: #475569; }
.sev.minor    { background: #fef3c7; color: #92400e; }
.sev.major    { background: #fed7aa; color: #9a3412; }
.sev.critical { background: #fecaca; color: #7f1d1d; }

/* ---------- Project timeline (top of project page) ---------- */
.timeline {
  margin: 16px 0 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.timeline-bar {
  position: relative;
  height: 12px;
  background: #e5e7eb;            /* light grey for ongoing portion */
  border-radius: 999px;
  margin: 14px 0 10px;
}
.timeline-fill {
  height: 100%;
  background: var(--success);     /* green for completed portion */
  border-radius: 999px;
  transition: width 0.4s ease;
}
.timeline-today {
  position: absolute;
  top: -5px;
  width: 3px;
  height: 22px;
  background: var(--navy);
  border-radius: 2px;
  transform: translateX(-1.5px);
}
.timeline-today::after {
  content: "Today";
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--navy);
  font-weight: 700;
  white-space: nowrap;
  background: #fff;
  padding: 0 4px;
}
.timeline-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}
.timeline-stat {
  font-weight: 600;
  color: var(--text);
}

/* ---------- Tab badges (red circle on tabs with outstanding items) ---------- */
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 0 5px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ---------- Workflow action button row on milestones ---------- */
.workflow-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.workflow-actions button { font-size: 13px; padding: 7px 12px; }
.workflow-actions .danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.workflow-actions .danger:hover { background: #fef2f2; }

/* ---------- Read-only task list (homeowner / non-builder view) ---------- */
.tasks.readonly li { color: var(--text); padding: 4px 0; }
.tasks.readonly li.done { color: var(--muted); text-decoration: line-through; }
.tasks.readonly li::before {
  content: "•";
  color: var(--muted);
  font-size: 16px;
  margin-right: 8px;
  display: inline-block;
  width: 12px;
}
.tasks.readonly li.done::before { content: "✓"; color: var(--success); font-weight: 700; }

/* ---------- Drawing category cards ---------- */
.drawing-categories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.drawing-cat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.drawing-cat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--teal);
}
.drawing-cat .cat-icon {
  font-size: 28px;
  margin-bottom: 10px;
}
.drawing-cat h4 { margin: 0 0 4px; font-size: 16px; color: var(--text); }
.drawing-cat .count { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.drawing-cat .cat-summary {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  margin-top: 6px;
  /* clamp to ~3 lines */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.drawings-back-btn {
  background: transparent;
  border: none;
  color: var(--blue);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  margin-bottom: 14px;
}
.drawings-back-btn:hover { text-decoration: underline; }

.drawing-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.drawing-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  display: flex;
  flex-direction: column;
}
.drawing-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--teal);
}
.drawing-thumb {
  background: #f1f5f9;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.drawing-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.drawing-meta { padding: 12px 14px; }
.drawing-meta h4 { margin: 0 0 4px; font-size: 15px; }
.drawing-meta p  { margin: 0 0 8px; }

/* ---------- Floor plan card (single, versioned) ---------- */
.floor-plan-card {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
@media (max-width: 720px) {
  .floor-plan-card { grid-template-columns: 1fr; }
}
.floor-plan-thumb {
  background: #f1f5f9;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-right: 1px solid var(--border);
}
@media (max-width: 720px) {
  .floor-plan-thumb { border-right: none; border-bottom: 1px solid var(--border); }
}
.floor-plan-thumb {
  position: relative;
  cursor: zoom-in;
}
.floor-plan-thumb:hover .enlarge-hint { opacity: 1; }
.floor-plan-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.enlarge-hint {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.version-thumb { cursor: zoom-in; }
.version-thumb:hover { outline: 2px solid var(--teal); outline-offset: 1px; }

/* ==================== MARKUP VIEW (fullscreen) ==================== */
.markup-view {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  font-family: inherit;
}
.markup-topbar {
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  box-shadow: var(--shadow);
  z-index: 2;
}
.markup-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 600;
}
.markup-title .markup-cat-icon { font-size: 22px; }
.markup-title .markup-meta {
  color: rgba(255,255,255,0.65);
  font-size: 12px;
  font-weight: 400;
}
.markup-back {
  background: rgba(255,255,255,0.10);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.20);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.markup-back:hover { background: rgba(255,255,255,0.18); }
.markup-zoombar {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.10);
  border-radius: 999px;
  padding: 4px;
}
.markup-zoombar button {
  background: transparent;
  color: #fff;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
}
.markup-zoombar button:hover { background: rgba(255,255,255,0.15); }
.markup-zoombar .zoom-level {
  color: #fff;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  min-width: 50px;
  text-align: center;
}
.markup-zoombar .zoom-fit {
  width: auto !important;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px !important;
}

.markup-body {
  flex: 1;
  display: grid;
  grid-template-columns: 240px 1fr 300px;
  overflow: hidden;
  min-height: 0;
}
.markup-body.no-properties { grid-template-columns: 240px 1fr; }

@media (max-width: 900px) {
  .markup-body { grid-template-columns: 200px 1fr; }
  .markup-properties { display: none !important; }
}

.markup-sidebar, .markup-properties {
  background: var(--panel);
  padding: 16px;
  overflow-y: auto;
  font-size: 13px;
}
.markup-sidebar { border-right: 1px solid var(--border); }
.markup-properties { border-left: 1px solid var(--border); }
.markup-sidebar h3, .markup-properties h3 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.markup-sidebar p { margin: 0 0 12px; }

.fixture-row {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.fixture-row:hover { background: var(--bg); border-color: var(--border); }
.fixture-row.active {
  background: var(--teal);
  color: #fff;
  font-weight: 600;
  border-color: var(--teal);
}
.fixture-icon-placeholder {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--marker-bg, var(--border));
  flex-shrink: 0;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
}
.fixture-row.active .fixture-icon-placeholder { box-shadow: 0 0 0 1px rgba(255,255,255,0.5); }

/* Canvas */
.markup-canvas-wrap {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%) 0 0/24px 24px,
    linear-gradient(-45deg, #f1f5f9 25%, transparent 25%) 0 12px/24px 24px,
    linear-gradient(45deg, transparent 75%, #f1f5f9 75%) 0 0/24px 24px,
    linear-gradient(-45deg, transparent 75%, #f1f5f9 75%) 12px -12px/24px 24px,
    #e5e7eb;
  cursor: grab;
  user-select: none;
}
.markup-canvas-wrap.placing { cursor: crosshair; }
.markup-canvas-wrap.panning { cursor: grabbing; }

.markup-canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.markup-canvas img {
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.markup-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.markup-marker {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  width: 28px;
  height: 28px;
  transform-origin: center center;
  transform: translate(-50%, -50%) scale(var(--inv-scale, 1));
  transition: filter 0.1s, drop-shadow 0.1s;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35));
  overflow: visible;
}
.markup-marker svg, .markup-marker > svg { display: block; width: 100%; height: 100%; }
.markup-marker .shape-fill   { fill: var(--marker-color, #ef4444); stroke: #fff; stroke-width: 2.2px; }
.markup-marker .shape-stroke { stroke: var(--marker-color, #ef4444); fill: none; }
.markup-marker:hover {
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.5)) brightness(1.05);
  z-index: 5;
}
.markup-marker.selected {
  filter: drop-shadow(0 0 0 3px var(--teal)) drop-shadow(0 2px 6px rgba(0,0,0,0.4));
  z-index: 6;
}
.markup-marker.selected .shape-fill   { stroke: var(--teal); stroke-width: 3px; }
.markup-marker.selected .shape-stroke { stroke: var(--teal); stroke-width: 4px; }
.markup-marker.fresh { animation: marker-pop 0.3s ease-out; }
@keyframes marker-pop {
  0%   { transform: translate(-50%, -50%) scale(0.0); }
  60%  { transform: translate(-50%, -50%) scale(calc(var(--inv-scale, 1) * 1.35)); }
  100% { transform: translate(-50%, -50%) scale(var(--inv-scale, 1)); }
}

/* ---------- Line layer (routing fixtures: wires, pipes, partition) ---------- */
.markup-line-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.markup-line-layer polyline {
  fill: none;
  stroke: var(--line-color, #ef4444);
  pointer-events: stroke;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.12s, stroke-width 0.12s;
}
.markup-line-layer polyline:hover { opacity: 0.9; }
.markup-line-layer polyline.selected {
  opacity: 1;
  filter: drop-shadow(0 0 4px var(--teal));
}
.markup-line-layer .temp-line {
  opacity: 0.85;
  stroke-dasharray: 6 4;
  pointer-events: none;
}
.markup-line-layer .temp-point {
  fill: var(--line-color, #ef4444);
  stroke: #fff;
  stroke-width: 1.5;
  pointer-events: none;
}
.markup-line-layer .temp-line.rubber { opacity: 0.55; }

/* Vertex handles for editing a selected line */
.markup-line-layer .vertex-handle {
  fill: #fff;
  stroke: var(--teal);
  stroke-width: 2.5;
  pointer-events: auto;
  cursor: grab;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35));
}
.markup-line-layer .vertex-handle:hover { fill: var(--teal); stroke: #fff; }
.markup-line-layer .vertex-handle.endpoint {
  stroke: var(--navy);
  stroke-width: 3;
}
.markup-line-layer .vertex-handle.endpoint:hover { fill: var(--navy); }

/* Snap target highlight (the fixture the cursor is about to snap to) */
.markup-marker.snap-target {
  filter: drop-shadow(0 0 0 6px rgba(20, 184, 166, 0.6)) drop-shadow(0 2px 4px rgba(0,0,0,0.35));
  z-index: 7;
}

/* ---------- Fixture sidebar shape preview ---------- */
.fixture-row .fixture-shape {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fixture-row .fixture-shape svg { width: 100%; height: 100%; display: block; }
.fixture-row .fixture-shape .shape-fill   { fill: var(--marker-color, #475569); stroke: #fff; stroke-width: 1.5px; }
.fixture-row .fixture-shape .shape-stroke { stroke: var(--marker-color, #475569); fill: none; }
.fixture-row .fixture-shape .line-preview {
  width: 22px;
  height: 22px;
}
.fixture-row .fixture-shape .line-preview line {
  stroke: var(--marker-color, #475569);
  stroke-width: 2.2;
  opacity: 0.8;
}
.fixture-row.active .fixture-shape .shape-fill   { stroke: rgba(255,255,255,0.95); }

/* ---------- Line drawing helper bar ---------- */
.line-draw-help {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 10;
}
.line-draw-help.visible { display: flex; }
.line-draw-help button {
  background: var(--teal);
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.line-draw-help button.cancel { background: rgba(255,255,255,0.18); }
.line-draw-help button:hover { filter: brightness(1.1); }

/* Properties panel content */
.markup-properties .placed-meta {
  font-size: 11px;
  color: var(--muted);
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  margin-bottom: 12px;
}
.markup-properties label { font-size: 12px; margin-top: 10px; }
.markup-properties input,
.markup-properties textarea,
.markup-properties select { padding: 8px 10px; font-size: 13px; }
.markup-properties .prop-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.markup-properties .prop-actions button { font-size: 13px; padding: 8px 12px; }
.markup-properties .delete-locked-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 10px;
  font-style: italic;
}

.markup-empty-canvas {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}
.floor-plan-meta { padding: 16px 18px; }

.version-history {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  max-height: 280px;
  overflow-y: auto;
}
.version-row {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.version-row:last-child { border-bottom: none; }
.version-thumb {
  width: 60px;
  height: 45px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.version-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.version-info { font-size: 13px; }
.badge.draft       { background: #e0e7ff; color: #3730a3; }
.badge.superseded  { background: #f1f5f9; color: #475569; }
.badge.in_review   { background: #fef3c7; color: #92400e; }
.badge.digital_signoff   { background: #cffafe; color: #155e75; }
.badge.onsite_confirmed  { background: #dcfce7; color: #166534; }
.badge.locked      { background: #dcfce7; color: #166534; }

/* ---------- Photo gallery ---------- */
.photo-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.photo-toolbar select { width: auto; min-width: 180px; }
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}
.photo-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform 0.12s, box-shadow 0.12s;
}
.photo-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-tile .photo-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 22px 8px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,0.78));
  color: #fff;
  font-size: 11px;
  line-height: 1.3;
  pointer-events: none;
}
.photo-tile .photo-caption .meta { opacity: 0.7; font-size: 10px; }
.photo-tile .pin-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 12px;
  padding: 3px 7px;
  border-radius: 999px;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ---------- Pin-picker modal (one-pin click on floor plan) ---------- */
.pin-picker {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.92);
  z-index: 1200;
  display: flex;
  flex-direction: column;
}
.pin-picker-topbar {
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.pin-picker-title { font-size: 15px; font-weight: 600; }
.pin-picker-actions { display: flex; gap: 8px; }
.pin-picker-actions .ghost {
  background: rgba(255,255,255,0.10);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.20);
}
.pin-picker-actions .ghost:hover { background: rgba(255,255,255,0.18); }
.pin-picker-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.pin-picker-canvas {
  position: relative;
  display: inline-block;
  cursor: crosshair;
  background: #fff;
  box-shadow: var(--shadow-lg);
}
.pin-picker-canvas img {
  display: block;
  max-width: 88vw;
  max-height: calc(100vh - 130px);
  user-select: none;
  -webkit-user-drag: none;
}
.pin-picker-canvas .pin-marker {
  position: absolute;
  font-size: 32px;
  line-height: 1;
  transform: translate(-50%, -100%);
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.pin-picker-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.92);
  color: var(--text);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  pointer-events: none;
}

/* ---------- Lightbox: floor plan + pin section ---------- */
.lightbox-floorplan {
  margin-top: 14px;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.lightbox-floorplan-canvas { max-width: 100%; }
.lightbox-floorplan-canvas img { max-width: 100%; max-height: 200px; }
.lightbox-floorplan-label {
  color: rgba(255,255,255,0.75);
  font-size: 12px;
  margin-bottom: 6px;
}
.lightbox-floorplan-canvas {
  position: relative;
  display: inline-block;
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.lightbox-floorplan-canvas img {
  display: block;
  max-width: 100%;
  max-height: 240px;
}
.lightbox-floorplan-canvas .pin-marker {
  position: absolute;
  font-size: 22px;
  line-height: 1;
  transform: translate(-50%, -100%);
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
}

/* ---------- Lightbox notes section ---------- */
.lightbox-notes {
  margin-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.18);
  padding-top: 14px;
}
.lightbox-notes h4 {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.65);
}
.lightbox-notes .note {
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
  position: relative;
}
.lightbox-notes .note .note-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.85);
  color: #fff;
  border: none;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s, transform 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.lightbox-notes .note.mine:hover .note-delete-btn { opacity: 1; }
.lightbox-notes .note .note-delete-btn:hover { transform: scale(1.1); background: #b91c1c; }
.lightbox-notes .note-composer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(255,255,255,0.15);
}
.lightbox-notes .note.deleted .note-content {
  text-decoration: line-through;
  opacity: 0.55;
}
.lightbox-notes .note .deleted-tag {
  background: rgba(220, 38, 38, 0.6);
  color: #fff;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 6px;
}
.lightbox-notes .note.mine { background: rgba(20, 184, 166, 0.20); border: 1px solid rgba(20, 184, 166, 0.4); }
.lightbox-notes .note-author {
  font-weight: 600;
  font-size: 12px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}
.lightbox-notes .note-author .role {
  background: rgba(255,255,255,0.18);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lightbox-notes .note-content { color: rgba(255,255,255,0.92); margin: 4px 0; line-height: 1.4; white-space: pre-wrap; }
.lightbox-notes .note-date    { color: rgba(255,255,255,0.55); font-size: 11px; }
.lightbox-notes textarea {
  width: 100%;
  background: rgba(255,255,255,0.10);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  min-height: 70px;
}
.lightbox-notes textarea::placeholder { color: rgba(255,255,255,0.45); }
.lightbox-notes .note-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.lightbox-notes .note-actions button {
  background: var(--teal);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.lightbox-notes .note-actions button.delete {
  background: transparent;
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.25);
}
.lightbox-notes .note-actions button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Approval timeline (floor plan workflow) ---------- */
.approval-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.approval-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.approval-header .approval-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
.approval-timeline { display: flex; flex-direction: column; gap: 5px; }
.approval-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
}
.approval-row.done    { color: var(--success); font-weight: 500; }
.approval-row.pending { color: var(--warning); font-weight: 500; }
.approval-row .approval-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--border-strong);
  flex-shrink: 0;
}
.approval-row.done .approval-icon    { background: var(--success); }
.approval-row.pending .approval-icon { background: var(--warning); color: var(--text); }
.approval-row .approval-text { flex: 1; }
.approval-row .approval-when { font-size: 11px; opacity: 0.85; }
.approval-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.approval-actions button { font-size: 13px; padding: 7px 12px; }

/* ==================== CHAT TAB ==================== */
.chat-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  height: 60vh;
  min-height: 380px;
}
@media (max-width: 768px) { .chat-shell { grid-template-columns: 1fr; height: auto; } }

.chat-thread-list {
  border-right: 1px solid var(--border);
  padding-right: 12px;
  overflow-y: auto;
}
@media (max-width: 768px) {
  .chat-thread-list { border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 12px; }
}

.chat-thread-row {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13.5px;
}
.chat-thread-row:hover { background: var(--bg); }
.chat-thread-row.active { background: var(--navy); color: #fff; }
.chat-thread-row.active .chat-thread-sub { color: rgba(255,255,255,0.7); }
.chat-thread-row .chat-thread-main { display: flex; flex-direction: column; min-width: 0; }
.chat-thread-row .chat-thread-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-thread-row .chat-thread-sub   { font-size: 11px; color: var(--muted); margin-top: 2px; }
.chat-thread-row .chat-unread {
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-conversation { display: flex; flex-direction: column; min-height: 0; }
.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}
.chat-active { display: flex; flex-direction: column; height: 100%; }
.chat-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}
.chat-header .chat-header-title { font-weight: 600; font-size: 14px; color: var(--text); }
.chat-header .chat-header-sub   { font-size: 11px; color: var(--muted); margin-top: 2px; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
}
.chat-msg {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 12px;
  background: #f1f5f9;
  font-size: 13.5px;
  line-height: 1.4;
  align-self: flex-start;
  word-wrap: break-word;
}
.chat-msg.mine { align-self: flex-end; background: var(--teal); color: #fff; }
.chat-msg .chat-msg-author {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 2px;
  opacity: 0.85;
}
.chat-msg .chat-msg-when {
  font-size: 10px;
  opacity: 0.65;
  margin-top: 3px;
}
.chat-msg.system {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-style: italic;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}
.chat-input-row textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13.5px;
}
.chat-input-row button { white-space: nowrap; }

/* Trade/milestone chip on top-left */
.photo-tile .trade-chip {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(255,255,255,0.94);
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  pointer-events: none;
  max-width: calc(100% - 14px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  z-index: 1;
}

/* Pin badge if this photo is pinpointed on a floor plan */
.photo-tile .pin-chip {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--teal);
  color: #fff;
  font-size: 11px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Uploader popup — appears on hover */
.photo-tile .uploader-popup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  white-space: nowrap;
  max-width: 90%;
  z-index: 2;
}
.photo-tile .uploader-popup .who { font-weight: 700; }
.photo-tile .uploader-popup .when { opacity: 0.7; font-size: 11px; margin-top: 2px; }
.photo-tile:hover .uploader-popup { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.photo-tile:hover img { filter: brightness(0.65); transition: filter 0.15s; }

/* Lightbox actions row */
.lightbox-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.lightbox-actions button {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.lightbox-actions button:hover { background: rgba(255,255,255,0.25); }
.lightbox-actions button.destructive {
  border-color: rgba(252, 165, 165, 0.5);
  color: #fecaca;
}
.lightbox-actions button.destructive:hover { background: rgba(220, 38, 38, 0.4); color: #fff; }
.lightbox-locked-note {
  color: rgba(255,255,255,0.55);
  font-size: 11px;
  margin-top: 8px;
  font-style: italic;
}

.upload-progress {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0c4a6e;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin: 12px 0;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  cursor: zoom-out;
}
.lightbox-content {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 20px;
  max-width: 96vw;
  max-height: 92vh;
  cursor: default;
}
.lightbox-photo-side {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  gap: 10px;
}
.lightbox-photo-side img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.lightbox-info-side {
  flex: 0 0 360px;
  max-width: 360px;
  max-height: 88vh;
  overflow-y: auto;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 16px;
  color: #fff;
  font-size: 13px;
}
@media (max-width: 900px) {
  .lightbox-content { flex-direction: column; max-height: 95vh; overflow-y: auto; }
  .lightbox-info-side { flex: 0 0 auto; max-width: 100%; max-height: none; }
  .lightbox-photo-side img { max-height: 60vh; }
}
.lightbox-meta {
  color: #fff;
  font-size: 14px;
  text-align: center;
  max-width: 700px;
}
.lightbox-meta .meta-line { color: rgba(255,255,255,0.65); font-size: 12px; margin-top: 4px; }
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: none;
  border-radius: 999px;
  width: 38px;
  height: 38px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255,255,255,0.30); }

/* ---------- Inspection modal ---------- */
.inspection-modal {
  background: #fff;
  border-radius: 12px;
  width: min(820px, 96vw);
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  color: var(--text);
}
.inspection-modal .lightbox-close {
  background: rgba(0,0,0,0.06);
  color: var(--text);
}
.inspection-modal .lightbox-close:hover { background: rgba(0,0,0,0.12); }
.inspection-head {
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--border);
}
.inspection-head h2 { margin: 0 0 4px; font-size: 18px; }
.inspection-body {
  padding: 18px 24px;
  overflow-y: auto;
  flex: 1;
}
.inspection-body .form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.inspection-body .form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.inspection-body .form-row label { font-size: 12px; font-weight: 600; color: var(--muted); }
.inspection-body .form-row input,
.inspection-body .form-row select,
.inspection-body .form-row textarea {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.inspection-body .form-row textarea { resize: vertical; }
.inspection-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 18px 0 10px;
}
.inspection-checklist { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.check-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "label controls" "note note";
  gap: 6px 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
}
.check-item .check-label    { grid-area: label;    font-size: 13.5px; line-height: 1.4; }
.check-item .check-controls { grid-area: controls; display: flex; gap: 6px; }
.check-item .check-note     { grid-area: note;     font-size: 12.5px; padding: 6px 8px;
                              border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.check-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.check-pill input { display: none; }
.check-pill:hover { background: #f1f5f9; }
.check-pill.pass.active { background: #ecfdf5; border-color: #10b981; color: #047857; }
.check-pill.fail.active { background: #fef2f2; border-color: #ef4444; color: #b91c1c; }
.check-pill.na.active   { background: #f3f4f6; border-color: var(--border-strong); color: var(--text); }
.inspection-foot {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f8fafc;
  flex-wrap: wrap;
}
.inspection-foot-note { flex: 1; min-width: 200px; }
.inspection-foot-actions { display: flex; gap: 8px; margin-left: auto; }
.inspection-foot-btn {
  min-width: 170px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 120ms ease;
}
.inspection-foot-btn:hover { filter: brightness(0.95); }
.inspection-foot-btn:active { filter: brightness(0.88); }
.inspection-foot-btn.ghost  { background: #fff;     color: var(--text);  border-color: var(--border-strong); }
.inspection-foot-btn.danger { background: #dc2626;  color: #fff; }
.inspection-foot-btn.teal   { background: var(--teal, #0f766e); color: #fff; }

/* ---------- Inspection: floor-plan markup ---------- */
.inspection-fp { margin-bottom: 12px; }
.inspection-fp-help { margin-bottom: 8px; }
.inspection-fp-empty {
  padding: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  text-align: center;
}
.inspection-fp-canvas {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 100%;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  cursor: crosshair;
  user-select: none;
}
.inspection-fp-canvas.readonly { cursor: default; }
.inspection-fp-canvas img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}
.inspection-fp-pins { position: absolute; inset: 0; pointer-events: none; }
.inspection-fp-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  border: 2px solid #fff;
  pointer-events: none;
}
.inspection-fp-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.inspection-fp-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 8px;
  align-items: center;
}
.inspection-fp-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  font-weight: 700;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.inspection-fp-row input {
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13px;
}
.inspection-fp-row .inspection-fp-remove { padding: 6px 10px; font-size: 12px; }

/* ---------- Defect card ---------- */
.defect-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  margin-bottom: 10px;
}
.defect-row.open         { border-left: 3px solid var(--danger); }
.defect-row.acknowledged { border-left: 3px solid var(--warning); }
.defect-row.in_repair    { border-left: 3px solid var(--info); }
.defect-row.resolved     { border-left: 3px solid var(--success); opacity: 0.85; }
.defect-row.rejected     { border-left: 3px solid var(--muted); opacity: 0.6; }
.defect-row .info { flex: 1; }
.defect-row h4 { margin: 0 0 4px; font-size: 15px; }
.defect-row p  { margin: 0; color: var(--text); font-size: 13px; }
.defect-row .meta-line { color: var(--muted); font-size: 12px; margin-top: 6px; }
.defect-row .actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.defect-notes {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}
.defect-notes label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.defect-notes textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  background: #fff;
}
.defect-notes.readonly { background: #fefce8; border-color: #fde68a; }
.defect-notes-text { font-size: 13px; white-space: pre-wrap; }

/* ---------- Milestone list ---------- */
.milestone {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  background: #fff;
}
.milestone-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.milestone-head h4 { margin: 0; font-size: 16px; }
.milestone-head .seq {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  margin-right: 10px;
  flex-shrink: 0;
}
.milestone .desc { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.milestone .dates { font-size: 12px; color: var(--muted); }
.milestone .tasks { margin: 10px 0 0; padding: 0; list-style: none; }
.milestone .tasks li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 3px 0;
  color: var(--text);
}
.milestone .tasks li.done { color: var(--muted); text-decoration: line-through; }
.milestone .tasks .check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  font-size: 11px;
  color: transparent;
  flex-shrink: 0;
}
.milestone .tasks li.done .check {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

/* ---------- VO list ---------- */
.vo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  margin-bottom: 10px;
}
.vo-row .info h4 { margin: 0 0 4px; font-size: 15px; }
.vo-row .info p { margin: 0; color: var(--muted); font-size: 13px; }
.vo-row .price { font-weight: 700; font-size: 17px; color: var(--text); }
.vo-row .actions { display: flex; gap: 8px; }

.vo-row.proposed   { border-left: 3px solid var(--warning); }
.vo-row.approved   { border-left: 3px solid var(--success); }
.vo-row.rejected   { border-left: 3px solid var(--danger); opacity: 0.65; }
.vo-row.completed  { border-left: 3px solid var(--success); opacity: 0.85; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
  flex-wrap: wrap;
}
.tabs li {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs li:hover { color: var(--text); }
.tabs li.active {
  color: var(--navy);
  border-bottom-color: var(--teal);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
  font-size: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
}
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 16px; text-transform: none; letter-spacing: 0; }

/* ---------- Loading ---------- */
.loading {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
  font-size: 14px;
}
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Misc ---------- */
.row { display: flex; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---------- Reusable button classes (landing + admin) ---------- */
.primary-btn, .ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter 120ms ease, background 120ms ease, border-color 120ms ease;
  line-height: 1.2;
}
.primary-btn { background: var(--navy); color: #fff; }
.primary-btn:hover { background: var(--navy-2); }
.primary-btn:disabled { background: var(--muted); cursor: not-allowed; }
.ghost-btn  { background: #fff; color: var(--text); border-color: var(--border-strong); }
.ghost-btn:hover { border-color: var(--navy); }
.primary-btn.lg, .ghost-btn.lg { padding: 12px 22px; font-size: 15px; }
.primary-btn.sm, .ghost-btn.sm { padding: 6px 12px;  font-size: 13px; }

/* ---------- Public landing page ---------- */
body.landing { background: #fff; }
.landing-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255,255,255,0.94);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.landing-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 24px;
}
.landing-nav .brand { font-size: 18px; font-weight: 700; color: var(--navy); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.landing-nav .brand img { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; }
.landing-nav-links { display: flex; gap: 22px; }
.landing-nav-links a { color: var(--text); text-decoration: none; font-size: 14px; font-weight: 500; }
.landing-nav-links a:hover { color: var(--navy); }
.landing-nav-cta { display: flex; gap: 8px; }
@media (max-width: 720px) { .landing-nav-links { display: none; } }

.hero { padding: 64px 24px 56px; background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%); }
.hero-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 48px;
  align-items: center;
}
@media (max-width: 900px) { .hero-inner { grid-template-columns: 1fr; gap: 32px; } }
.eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal-dark);
  margin-bottom: 14px;
}
.hero-copy h1 {
  font-size: 44px;
  line-height: 1.1;
  margin: 0 0 16px;
  color: var(--navy);
  letter-spacing: -0.01em;
}
@media (max-width: 720px) { .hero-copy h1 { font-size: 32px; } }
.hero-copy .lede { font-size: 17px; color: var(--text); max-width: 540px; line-height: 1.5; margin: 0 0 28px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.hero-trust { max-width: 420px; }

.hero-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.hero-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.hero-card-head .dot { width: 9px; height: 9px; border-radius: 50%; }
.hero-card-head .dot-r { background: #ef4444; }
.hero-card-head .dot-y { background: #f59e0b; }
.hero-card-head .dot-g { background: #10b981; }
.hero-card-title { margin-left: 10px; font-size: 13px; font-weight: 600; color: var(--text); }
.hero-card-body { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.hero-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hero-pill {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid transparent;
}
.hero-pill.teal  { background: #ecfeff; color: #0e7490; border-color: #67e8f9; }
.hero-pill.green { background: #ecfdf5; color: #047857; border-color: #6ee7b7; }
.hero-pill.amber { background: #fffbeb; color: #92400e; border-color: #fcd34d; }
.hero-pill.red   { background: #fef2f2; color: #b91c1c; border-color: #fca5a5; }

.features, .roles, .pilot { padding: 64px 24px; }
.features-inner, .roles-inner, .pilot-inner { max-width: 1200px; margin: 0 auto; }
.features h2, .roles h2, .pilot h2 {
  font-size: 30px;
  letter-spacing: -0.01em;
  color: var(--navy);
  margin: 0 0 32px;
  max-width: 720px;
}
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}
.feature-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 22px 20px;
  background: #fff;
  transition: border-color 120ms ease, transform 120ms ease;
}
.feature-card:hover { border-color: var(--teal); transform: translateY(-1px); }
.feature-ico { font-size: 26px; margin-bottom: 10px; }
.feature-card h3 { margin: 0 0 6px; font-size: 17px; color: var(--navy); }
.feature-card p  { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text); }

.roles { background: #f8fafc; }
.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}
.role-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}
.role-card h3 { margin: 0 0 14px; font-size: 19px; color: var(--navy); }
.role-card ul { margin: 0; padding-left: 18px; }
.role-card li { font-size: 14px; line-height: 1.55; color: var(--text); margin-bottom: 6px; }

.pilot { text-align: center; background: var(--navy); color: #fff; }
.pilot h2 { color: #fff; margin: 0 auto 14px; }
.pilot p { font-size: 16px; max-width: 640px; margin: 0 auto 24px; color: rgba(255,255,255,0.85); }
.pilot-cta { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.pilot .ghost-btn { background: transparent; color: #fff; border-color: rgba(255,255,255,0.4); }
.pilot .ghost-btn:hover { border-color: #fff; }

.landing-foot { padding: 28px 24px; border-top: 1px solid var(--border); background: #fff; }
.landing-foot-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.landing-foot .brand { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--navy); }
.landing-foot .brand img { width: 22px; height: 22px; border-radius: 4px; }

/* ---------- Admin dashboard ---------- */
.admin-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.kpi-value { font-size: 26px; font-weight: 700; color: var(--navy); line-height: 1.1; }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-sub   { margin-top: 2px; }

.admin-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }

.admin-sort-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 12px;
}
.admin-sort-row select {
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}
.admin-project-people {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text);
}
.admin-project-people .muted { font-weight: 600; }
.admin-project-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
  background: #fff;
  transition: border-color 120ms ease;
}
.admin-project-row:hover { border-color: var(--teal); }
.admin-project-main { flex: 1; min-width: 0; }
.admin-project-name { font-weight: 600; margin-bottom: 2px; }
.admin-project-bar {
  margin-top: 8px;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.admin-project-bar > div { height: 100%; background: var(--success); }
.admin-project-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
  text-align: right;
}

.activity-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.activity-row:last-child { border-bottom: none; }
.activity-kind {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  white-space: nowrap;
  flex-shrink: 0;
}
.activity-kind.vo         { background: #ecfeff; color: #0e7490; }
.activity-kind.defect     { background: #fef2f2; color: #b91c1c; }
.activity-kind.inspection { background: #ecfdf5; color: #047857; }
.activity-kind.chat       { background: #eff6ff; color: #1d4ed8; }
.activity-body { flex: 1; min-width: 0; }
.activity-text { font-size: 13.5px; line-height: 1.4; }
.activity-link {
  font-size: 12px;
  color: var(--teal-dark);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
  align-self: center;
}
.activity-link:hover { text-decoration: underline; }

.admin-users { width: 100%; border-collapse: collapse; }
.admin-users th, .admin-users td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13.5px;
  vertical-align: middle;
}
.admin-users th {
  background: #f8fafc;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.admin-users .role-select {
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

/* ---------- Responsive polish (mobile pass) ---------- */
@media (max-width: 720px) {
  .container { padding: 20px 14px; }
  .topbar-inner { padding: 0 14px; gap: 10px; flex-wrap: wrap; }
  .brand { font-size: 18px; gap: 10px; }
  .brand img { height: 36px; width: 36px; }
  .user-chip { gap: 8px; font-size: 13px; }
  .user-chip .role { display: none; } /* save room */
  .page-head { flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
  .page-head h1 { font-size: 22px; }

  /* Tabs: horizontal scroll instead of wrapping */
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs li { white-space: nowrap; padding: 10px 12px; font-size: 13.5px; }

  /* Admin */
  .admin-project-row { flex-direction: column; align-items: stretch; }
  .admin-project-side { align-items: flex-start; text-align: left; }
  .admin-users { display: block; overflow-x: auto; }
  .admin-grid { gap: 12px; }
  .admin-kpis { gap: 8px; }
  .kpi-value { font-size: 22px; }
  .admin-sort-row { flex-wrap: wrap; }

  /* Inspection modal foot — stack the buttons full-width on phones */
  .inspection-foot { flex-direction: column; align-items: stretch; }
  .inspection-foot-actions { width: 100%; justify-content: stretch; }
  .inspection-foot-btn { flex: 1; min-width: 0; }

  /* Defect rows */
  .defect-row { flex-direction: column; align-items: stretch; }
  .defect-row .actions { flex-direction: row; align-items: stretch; flex-wrap: wrap; }

  /* Hero stack reorder — show product card above copy */
  .hero { padding: 36px 16px 32px; }
  .hero-copy h1 { font-size: 28px; }
  .hero-copy .lede { font-size: 15px; }
  .hero-cta .primary-btn, .hero-cta .ghost-btn { flex: 1; }

  /* Sections trim padding */
  .features, .roles, .pilot { padding: 40px 16px; }
  .features h2, .roles h2, .pilot h2 { font-size: 24px; margin-bottom: 22px; }
}

