:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-strong: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --line: #dbe3ee;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #e5e7eb; border-radius: 6px; padding: 0.1rem 0.35rem; }

.auth-page {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top left, #dbeafe, transparent 34rem), var(--bg);
}
.auth-card {
  width: min(440px, 100%);
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.auth-card-wide { width: min(520px, 100%); }
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 18px 0 16px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
}
.auth-tab {
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  min-height: 38px;
  cursor: pointer;
}
.auth-tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.12);
}
.auth-panel { display: none; }
.auth-panel.active { display: grid; gap: 12px; }
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.04em;
}
h1, h2, h3 { margin: 0 0 12px; line-height: 1.15; }
h1 { font-size: clamp(1.7rem, 2vw, 2.3rem); }
h2 { font-size: 1rem; }
h3 { font-size: 0.98rem; }
.muted { color: var(--muted); }
.small-text { font-size: 0.85rem; }

.notice {
  display: none;
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 0.92rem;
}
.notice:not(:empty) { display: block; }
.notice.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.notice.success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }

.stacked-form { display: grid; gap: 14px; }
.stacked-form label { display: grid; gap: 6px; font-weight: 650; font-size: 0.9rem; }
.stacked-form label span, .stacked-form legend { color: #334155; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}
.checkbox { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 8px !important; font-weight: 600 !important; }
.checkbox input { width: auto; }
.checkbox-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  gap: 7px;
}
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: #1f2937;
  font-weight: 750;
  min-height: 40px;
  padding: 9px 13px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.button:hover { text-decoration: none; border-color: #b5c4d8; }
.button:disabled { opacity: 0.55; cursor: not-allowed; }
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-dark); }
.button.danger { background: #fff1f2; border-color: #fecdd3; color: #b91c1c; }
.button.small { min-height: 32px; padding: 6px 9px; border-radius: 9px; font-size: 0.82rem; }
.button.full { width: 100%; }
.button-row, .inline-actions { display: flex; align-items: center; gap: 8px; }
.button-row.wrap { flex-wrap: wrap; }

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: rgba(255,255,255,0.96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar > div { display: grid; gap: 2px; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.map { width: 100%; height: 100%; min-height: 320px; background: #dbeafe; }
.map-shell {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 22px rgba(15, 23, 42, 0.08);
}
.map-error { display: grid; place-items: center; height: 100%; padding: 24px; text-align: center; color: #991b1b; }

.mobile-page { min-height: 100%; display: grid; grid-template-rows: auto auto minmax(360px, 1fr) auto; }
.mobile-toolbar {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.instruction { margin: 0; color: #334155; font-weight: 650; }
.mobile-map-shell {
  height: min(58vh, 620px);
  min-height: 380px;
  margin: 12px;
}
.bottom-panel {
  margin: 0 12px calc(12px + var(--safe-bottom));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.panel-heading h2 { margin: 0; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 0.8rem;
  font-weight: 800;
}
.record-list { list-style: none; padding: 0; margin: 0; max-height: 220px; overflow: auto; }
.record-list li { border-top: 1px solid #eef2f7; }
.record-list li:first-child { border-top: 0; }
.record-list button {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 0;
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--text);
}
.record-list button:hover { background: #f8fafc; }
.record-list span { color: var(--muted); font-size: 0.86rem; }
.empty { color: var(--muted); text-align: center; padding: 18px; }

.desktop-layout {
  height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}
.sidebar {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 14px;
}
.filters-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stats-grid div {
  display: grid;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px;
}
.stats-grid strong { font-size: 1.35rem; }
.stats-grid span { color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.workspace { min-width: 0; display: grid; grid-template-rows: auto minmax(360px, 1fr) minmax(220px, 34vh); gap: 12px; }
.desktop-toolbar {
  display: grid;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.desktop-search-row { max-width: 720px; }
.desktop-map-shell { min-height: 360px; }
.results-panel {
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-scroll { overflow: auto; height: calc(100% - 50px); }
.compact-table { max-height: 320px; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 10px 12px; border-bottom: 1px solid #edf2f7; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; background: #f8fafc; color: #334155; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: #fbfdff; }
.row-actions { white-space: nowrap; }
.row-actions .button { margin-right: 4px; }

.modal-dialog {
  width: min(560px, calc(100vw - 24px));
  border: 0;
  border-radius: 20px;
  padding: 0;
  box-shadow: var(--shadow);
}
.modal-dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.dialog-form { padding: 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  transform: translate(-50%, 20px);
  max-width: min(520px, calc(100vw - 24px));
  padding: 11px 14px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 1000;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #991b1b; }
.toast.success { background: #166534; }
.toast.info { background: #111827; }

.info-window { max-width: 280px; font-size: 0.9rem; }
.info-window h3 { margin-bottom: 6px; }
.info-window p { margin: 8px 0; }
.advanced-pin {
  width: 24px;
  height: 24px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: grid;
  place-items: center;
  background: #4b5563;
  border: 2px solid #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.28);
}
.advanced-pin span { transform: rotate(45deg); color: #fff; font-size: 0.75rem; font-weight: 900; }
.advanced-pin.damage-minor { background: #16a34a; }
.advanced-pin.damage-moderate { background: #d97706; }
.advanced-pin.damage-severe { background: #dc2626; }
.advanced-pin.user-pin { background: #2563eb; border-radius: 999px; transform: none; }
.advanced-pin.user-pin span { transform: none; font-size: 0.67rem; }

@media (max-width: 1100px) {
  .desktop-layout { grid-template-columns: 320px minmax(0, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .desktop-layout { height: auto; grid-template-columns: 1fr; }
  .workspace { grid-template-rows: auto 60vh auto; }
  .sidebar { overflow: visible; }
  .desktop-page { min-height: 100%; }
  .topbar { height: auto; min-height: 64px; flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .results-panel { min-height: 320px; }
}

@media (max-width: 560px) {
  .auth-card { padding: 24px; border-radius: 18px; }
  .mobile-toolbar { padding: 10px; }
  .button-row .button { flex: 1 1 auto; }
  .search-row { grid-template-columns: 1fr; }
  .mobile-map-shell { margin: 8px; min-height: 340px; height: 52vh; }
  .bottom-panel { margin: 0 8px calc(8px + var(--safe-bottom)); }
  .top-actions { width: 100%; justify-content: flex-start; }
  .grid-2 { grid-template-columns: 1fr; }
}

.record-photo {
  display: block;
  width: 100%;
  max-width: 260px;
  max-height: 180px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  margin: 8px 0;
}
.photo-preview {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  border-radius: 12px;
  background: #f8fafc;
  word-break: break-all;
}
.photo-preview img {
  width: 86px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
}

.form-section {
  border: 1px solid var(--border-color, #d7dee8);
  border-radius: 12px;
  padding: 0.75rem;
  margin: 0.5rem 0;
}
.form-section legend {
  padding: 0 0.35rem;
  font-weight: 700;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 0.5rem;
  margin: 0.5rem 0;
}
.photo-gallery img,
.photo-preview img.record-photo,
.record-photo {
  width: 100%;
  max-width: 160px;
  height: 90px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border-color, #d7dee8);
}
.info-window .photo-gallery {
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  max-width: 360px;
}
@media (max-width: 640px) {
  .grid-3 { grid-template-columns: 1fr; }
}

.tech-map-avatar {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  overflow: hidden;
  border: 3px solid #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,.28);
  background: #2563eb;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.tech-map-avatar img, .tech-popup-photo, .table-avatar {
  object-fit: cover;
  border-radius: 999px;
}
.tech-map-avatar img { width: 100%; height: 100%; display: block; }
.tech-popup-photo { width: 72px; height: 72px; border: 2px solid #e5e7eb; }
.table-avatar { width: 34px; height: 34px; vertical-align: middle; margin-right: .45rem; border: 1px solid #e5e7eb; }
.stats-layout { padding: 1rem; display: grid; gap: 1rem; }
.stats-grid-wide { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* v12: circular technician photo markers on Google Maps, including shared-hosting fallback markers. */
.hdm-html-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}
.tech-map-avatar {
  width: 46px;
  height: 46px;
  min-width: 46px;
  min-height: 46px;
  border-radius: 50% !important;
  overflow: hidden;
  clip-path: circle(50% at 50% 50%);
  border: 3px solid #fff;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.32);
  background: #2563eb;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  line-height: 1;
}
.tech-map-avatar img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  border-radius: 50% !important;
}
.tech-popup-photo,
.table-avatar {
  object-fit: cover;
  border-radius: 50% !important;
}

/* v13 mobile auto-capture switch and circular technician map photos */
.switch-control {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 38px;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border-color, #d7dee8);
  border-radius: 999px;
  background: #ffffff;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}
.switch-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch-slider {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  transition: background 0.18s ease;
  flex: 0 0 auto;
}
.switch-slider::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  position: absolute;
  top: 3px;
  left: 3px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.3);
  transition: transform 0.18s ease;
}
.switch-control input:checked + .switch-slider { background: #16a34a; }
.switch-control input:checked + .switch-slider::after { transform: translateX(18px); }
.status-on { background: #dcfce7; color: #166534; border-color: #86efac; }
.status-off { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.walk-capture-active .walk-capture-switch { border-color: #86efac; box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12); }

.hdm-html-map-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 50;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  line-height: 0;
}
.hdm-html-map-marker .tech-map-avatar,
.tech-map-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,.28);
  background: #2563eb;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.tech-map-avatar img,
.tech-popup-photo,
.table-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.tech-popup-photo { width: 72px; height: 72px; border: 2px solid #e5e7eb; }
.table-avatar { width: 34px; height: 34px; vertical-align: middle; margin-right: .45rem; border: 1px solid #e5e7eb; }

.address-preview-panel {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(-8px);
  transition: max-height 0.22s ease, opacity 0.18s ease, transform 0.18s ease;
}
.address-preview-panel.open {
  max-height: 720px;
  opacity: 1;
  transform: translateY(0);
}
.address-preview-panel[hidden] { display: none; }

/* v13 final: true background walked-address switch and stats preview drawer */
.auto-capture-control {
  align-items: center;
  gap: 0.65rem;
  white-space: normal;
}
.switch-copy {
  display: grid;
  gap: 0.1rem;
  line-height: 1.1;
}
.switch-copy small {
  font-weight: 600;
  color: #64748b;
  max-width: 280px;
}
.walked-auto-active .auto-capture-control {
  border-color: #86efac;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.14);
}
.walked-auto-active .switch-copy small {
  color: #166534;
}
.address-preview-panel.is-open,
.address-preview-panel.open {
  max-height: 760px;
  opacity: 1;
  transform: translateY(0);
}
#walkedPreviewTable td:nth-child(2) {
  min-width: 260px;
}
.hdm-html-marker .tech-map-avatar,
.hdm-html-map-marker .tech-map-avatar,
.tech-map-avatar {
  border-radius: 50% !important;
  overflow: hidden !important;
  clip-path: circle(50% at 50% 50%);
  aspect-ratio: 1 / 1;
}
.hdm-html-marker .tech-map-avatar img,
.hdm-html-map-marker .tech-map-avatar img,
.tech-map-avatar img,
.tech-popup-photo,
.table-avatar {
  border-radius: 50% !important;
  object-fit: cover;
}

/* v14: inline stats address preview drawer */
.address-preview-row td {
  padding: 0 !important;
  background: #f8fafc;
  border-top: 0;
}
.address-preview-inner {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.24s ease;
}
.address-preview-inner.open {
  max-height: 520px;
  overflow: auto;
}
.address-preview-card {
  padding: 12px 14px;
  border-top: 1px solid var(--border-color, #d7dee8);
}
.address-preview-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.compact-table {
  width: 100%;
  border-collapse: collapse;
}
.compact-table th,
.compact-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
}

/* WebRTC video calling */

.video-incoming-overlay[hidden] { display: none !important; pointer-events: none !important; }
.video-incoming-overlay {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.35);
  pointer-events: none;
}
.video-incoming-overlay.is-visible { pointer-events: auto; }
.video-incoming-card {
  width: min(430px, calc(100vw - 28px));
  background: #fff;
  color: #0f172a;
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.38);
  border: 1px solid rgba(15, 23, 42, 0.12);
  pointer-events: auto;
}

.video-call-dock {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1200;
  width: min(440px, calc(100vw - 24px));
  background: rgba(15, 23, 42, 0.98);
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.38);
  overflow: hidden;
}
.video-call-dock[hidden] { display: none !important; }
.video-call-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}
.video-call-header strong { display: block; font-size: 1rem; }
.video-call-header .muted { display: block; color: #cbd5e1; margin-top: 2px; }
.video-call-body {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px;
}
.video-frame {
  position: relative;
  background: #020617;
  border-radius: 14px;
  overflow: hidden;
  min-height: 210px;
  border: 1px solid rgba(148, 163, 184, 0.22);
}
.video-frame.local {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 34%;
  min-height: 90px;
  aspect-ratio: 4 / 3;
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
}
.video-frame video {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: block;
  object-fit: cover;
  background: #020617;
}
.video-frame span {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 3px 7px;
  font-size: .75rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.74);
  color: #f8fafc;
}
.video-call-actions { padding: 0 10px 10px; }
.video-call-dock .button { border-color: rgba(255,255,255,0.22); }
.video-call-dock .tiny-text { color: #94a3b8; padding: 0 12px 12px; margin: 0; word-break: break-all; }
.video-call-dock.is-minimized .video-call-body,
.video-call-dock.is-minimized .video-call-actions,
.video-call-dock.is-minimized .tiny-text { display: none; }
.video-call-dialog .dialog-form { max-width: 420px; }
.video-incoming-card h2 { margin-bottom: .25rem; }
.video-call-copy { line-height: 1.45; }
.video-call-btn { white-space: nowrap; }
.mobile-video-call-btn { font-weight: 700; }
@media (max-width: 720px) {
  .video-call-dock {
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    border-radius: 16px;
  }
  .video-frame { min-height: 250px; }
  .video-frame.local { width: 38%; min-height: 92px; right: 16px; bottom: 16px; }
}

/* v23 fallback answer button. This remains visible even if the full incoming-call card is hidden behind a browser/UI layer. */
.video-incoming-fallback[hidden] { display: none !important; }
.video-incoming-fallback {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 2700;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.35);
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 800;
}


/* v25: make incoming mobile call UI impossible to miss. */
body.hdm-video-ringing .video-incoming-overlay.is-visible {
  display: grid !important;
  visibility: visible !important;
  opacity: 1 !important;
}
.video-incoming-fallback.is-visible {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  visibility: visible !important;
  opacity: 1 !important;
  z-index: 2147483000;
}
.video-incoming-overlay.is-visible {
  z-index: 2147482999;
}

/* v28 customer live inspection view */
.customer-view-link-panel,
.customer-view-incoming-panel {
  position: fixed;
  z-index: 1300;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  max-width: 620px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, .14);
  border-radius: 18px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, .22);
  padding: 1rem;
}
.customer-view-link-close {
  position: absolute;
  top: .6rem;
  right: .75rem;
  border: 0;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.customer-view-link-input {
  width: 100%;
  font-size: .92rem;
  border: 1px solid rgba(15, 23, 42, .18);
  border-radius: 12px;
  padding: .7rem .8rem;
  margin: .5rem 0 .75rem;
}
.customer-view-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #f8fafc, #e0f2fe);
  padding: 1rem;
}
.customer-view-shell {
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 1rem;
  align-items: start;
}
.customer-view-card,
.customer-video-panel {
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .12);
  border: 1px solid rgba(15, 23, 42, .08);
  padding: 1rem;
}
.customer-view-logo {
  max-width: 180px;
  display: block;
  margin-bottom: .75rem;
}
.customer-video-panel video {
  width: 100%;
  min-height: 320px;
  background: #020617;
  border-radius: 18px;
  display: block;
}
.customer-view-btn {
  border-color: rgba(14, 165, 233, .35);
}
@media (max-width: 760px) {
  .customer-view-shell { grid-template-columns: 1fr; }
  .customer-video-panel video { min-height: 240px; }
}

/* v29 live technician status bar */
.live-status-bar {
  position: sticky;
  top: 64px;
  z-index: 18;
  display: grid;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(248, 250, 252, 0.98);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}
.live-status-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.live-status-head > div:first-child { display: grid; gap: 2px; }
.live-status-summary {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}
.live-status-summary span {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 4px 8px;
}
.live-status-summary b { color: var(--text); }
.live-status-summary em { font-style: normal; color: #64748b; }
.live-status-chips {
  display: flex;
  align-items: stretch;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.live-user-chip {
  flex: 0 0 auto;
  min-width: 245px;
  max-width: 330px;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  grid-template-areas:
    "dot initial main"
    "dot initial meta";
  align-items: center;
  gap: 0 8px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 8px 10px;
  cursor: pointer;
  box-shadow: 0 2px 7px rgba(15, 23, 42, 0.06);
}
.live-user-chip:hover { border-color: #93c5fd; }
.live-user-chip.is-green { border-color: #86efac; background: linear-gradient(180deg, #f0fdf4, #fff); }
.live-user-chip.is-red { border-color: #fecaca; background: linear-gradient(180deg, #fef2f2, #fff); }
.live-user-dot {
  grid-area: dot;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  align-self: center;
  background: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
}
.live-user-chip.is-green .live-user-dot {
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.16);
}
.live-user-initial {
  grid-area: initial;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e2e8f0;
  color: #334155;
  font-weight: 900;
}
.live-user-chip.is-green .live-user-initial { background: #bbf7d0; color: #166534; }
.live-user-chip.is-red .live-user-initial { background: #fee2e2; color: #991b1b; }
.live-user-main {
  grid-area: main;
  min-width: 0;
  display: grid;
  gap: 1px;
}
.live-user-main strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.88rem;
}
.live-user-main small {
  color: #334155;
  font-size: 0.76rem;
  font-weight: 850;
}
.live-user-chip.is-green .live-user-main small { color: #166534; }
.live-user-chip.is-red .live-user-main small { color: #b91c1c; }
.live-user-meta {
  grid-area: meta;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.1;
}
.live-user-meta span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 145px;
}
.live-status-empty {
  border: 1px dashed var(--line);
  color: var(--muted);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  font-size: 0.86rem;
}
.live-status-empty.error {
  color: #991b1b;
  border-color: #fecaca;
  background: #fef2f2;
}
.desktop-page .live-status-bar + .desktop-layout {
  height: calc(100vh - 64px - 104px);
}
@media (max-width: 980px) {
  .live-status-bar { position: static; padding: 10px 12px; }
  .live-status-head { align-items: flex-start; flex-direction: column; }
  .desktop-page .live-status-bar + .desktop-layout { height: auto; }
  .live-user-chip { min-width: 230px; }
}

/* v29b live desktop status refinements */
.live-status-injected { display: block; }
.device-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #64748b;
  border-radius: 999px;
  padding: 1px 6px;
  margin-right: 4px;
  font-size: 10px;
  line-height: 1.45;
  font-weight: 700;
}
.device-badge.is-on {
  border-color: #86efac;
  background: #dcfce7;
  color: #166534;
}
.live-status-empty a { color: #1d4ed8; font-weight: 700; }

/* v29e live status hard-color fallback */
#liveUserStatus .live-user-chip.is-green {
  border: 2px solid #16a34a !important;
  background: linear-gradient(180deg, #bbf7d0, #ffffff) !important;
  color: #14532d !important;
}
#liveUserStatus .live-user-chip.is-red {
  border: 2px solid #dc2626 !important;
  background: linear-gradient(180deg, #fecaca, #ffffff) !important;
  color: #7f1d1d !important;
}
#liveUserStatus .live-user-chip.is-green .live-user-dot {
  background: #16a34a !important;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, .22) !important;
}
#liveUserStatus .live-user-chip.is-red .live-user-dot {
  background: #dc2626 !important;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, .18) !important;
}
