:root {
  --bg: #1a1a1f;
  --surface: #252530;
  --surface2: #2e2e38;
  --text: #f0f0f2;
  --muted: #9ca3af;
  --border: #3d3d48;
  --blue: #2563eb;
  --blue-dark: #1a4a8a;
  --orange: #3b82f6;
  --red: #1a4a8a;
  --ok: #2e7d52;
  --radius: 10px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-tap-highlight-color: rgba(59, 130, 246, 0.2);
}

.app-shell.app-locked { display: none; }

.auth-gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(37, 99, 235, 0.14), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(26, 74, 138, 0.18), transparent 50%),
    linear-gradient(165deg, #1a1a1f 0%, #252530 45%, #1f1f28 100%);
}

.auth-gate.hidden { display: none; }

.auth-card {
  width: min(400px, 100%);
  padding: 2rem 1.75rem;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface2), var(--surface));
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.auth-logo {
  width: 72px;
  height: auto;
  margin-bottom: 0.75rem;
}

.auth-title {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.auth-int { color: #5eb8e8; }
.auth-sep { color: var(--muted); margin: 0 0.2rem; }
.auth-fix { color: var(--orange); }

.auth-tagline {
  margin: 0 0 1.25rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.auth-prompt {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--text);
}

.auth-form { text-align: left; }

.auth-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--muted);
}

.auth-input {
  width: 100%;
  margin-bottom: 0.65rem;
}

.auth-password-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

.auth-password-row .auth-input {
  flex: 1;
  margin-bottom: 0;
}

.auth-show-pw {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.auth-show-pw input { cursor: pointer; }

.auth-error {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.82rem;
  color: #ffb4b4;
  background: rgba(139, 26, 26, 0.25);
  border-left: 3px solid var(--red);
  border-radius: 4px;
}

.auth-error.hidden { display: none; }

.auth-submit {
  width: 100%;
  margin-top: 0.25rem;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.nav {
  background: linear-gradient(180deg, #1e1e26 0%, #252530 100%);
  border-right: 2px solid var(--orange);
  border-left: 2px solid var(--red);
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  position: relative;
  z-index: 2;
}

.brand-lock {
  text-align: center;
  background: linear-gradient(180deg, #141418, #1e1e26);
  border-radius: 8px;
  padding: 0.65rem 0.35rem 1rem;
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.brand-lock img { width: 100%; max-width: 180px; height: auto; display: block; margin: 0 auto; }

.app-head {
  text-align: center;
  background: linear-gradient(135deg, #1e1e26, #2a2a32);
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--orange);
  border-radius: var(--radius);
  padding: 0.85rem 1rem 0.75rem;
  margin-bottom: 1rem;
}

.app-head-logo { max-width: 200px; max-height: 72px; width: auto; height: auto; object-fit: contain; }

.app-head-sub {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.app-head-sub span { color: var(--orange); font-weight: 600; }

.nav h1 {
  font-size: 0.75rem;
  margin: 0.5rem 0.5rem 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav button {
  text-align: left;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.85);
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
}

.nav button:hover { background: rgba(255,102,0,0.12); }
.nav button.active {
  background: linear-gradient(90deg, var(--red), var(--orange));
  color: #fff;
  font-weight: 600;
}

.nav-actions {
  margin-top: auto;
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.main { padding: 1rem 1.25rem 2rem; max-width: 960px; }

.top-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: var(--radius);
}

.top-bar .report-no {
  font-weight: 700;
  color: var(--orange);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.55rem;
  font: inherit;
  min-width: 14rem;
}

.section { display: none; }
.section.active { display: block; }

.panel {
  background: linear-gradient(180deg, var(--surface), #22222c);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
  border-top: 2px solid var(--orange);
}

.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  color: var(--orange);
}

.hint { font-size: 0.8rem; color: var(--muted); margin: 0 0 0.85rem; }

.grid-2 { display: grid; gap: 0.75rem; }

@media (min-width: 680px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.field-example {
  display: block;
  font-size: 0.72rem;
  color: #7a8a9a;
  font-style: italic;
  margin: 0.25rem 0 0.65rem;
  line-height: 1.35;
}

.top-bar-field { flex: 1; min-width: 12rem; }

input[type='text'],
input[type='date'],
textarea,
select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 2px rgba(255,102,0,0.2);
}

textarea { min-height: 100px; resize: vertical; }

.yesno-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.yesno-row .label { font-size: 0.88rem; font-weight: 600; text-transform: none; color: var(--text); flex: 1; }

.yn-pills { display: flex; gap: 0.35rem; }

.yn-pills button {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
}

.yn-pills button.active-yes { background: var(--ok); border-color: var(--ok); color: #fff; }
.yn-pills button.active-no { background: var(--red); border-color: var(--red); color: #fff; }

.doc-image-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 680px) {
  .doc-image-grid { grid-template-columns: 1fr 1fr; }
}

.doc-image-card {
  position: relative;
  isolation: isolate;
  background: var(--surface2);
  border: 2px dashed #4a4a55;
  border-radius: 10px;
  padding: 0.85rem;
}

.doc-image-card.has-image { border-style: solid; border-color: var(--orange); }
.doc-image-card .title { font-weight: 700; font-size: 0.9rem; }
.doc-image-card .caption { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.35rem; }
.doc-prompt {
  font-size: 0.78rem;
  color: var(--orange);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.doc-preview {
  margin-bottom: 0.5rem;
  text-align: center;
}

.doc-preview img {
  max-width: 100%;
  max-height: 140px;
  border-radius: 6px;
  border: 1px solid var(--border);
  object-fit: contain;
  background: #fff;
}

.doc-drop {
  display: block;
  margin-top: 0.25rem;
  min-height: 5.5rem;
  position: relative;
  z-index: 3;
}

@media (min-width: 769px) {
  .doc-drop {
    min-height: 6rem;
    padding: 1rem 0.75rem;
  }
}

.sig-pad-wrap { margin-top: 0.5rem; }

.sig-canvas {
  width: 100%;
  max-width: 520px;
  height: 140px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 8px;
  touch-action: none;
  cursor: crosshair;
  display: block;
}

.sig-pad-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.sig-upload-btn {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  margin: 0;
}
.sig-upload-btn input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.sig-preview {
  margin-top: 0.65rem;
  min-height: 2rem;
}

.sig-preview img {
  max-height: 48px;
  max-width: 200px;
  background: #fff;
  border-radius: 4px;
  padding: 2px;
  vertical-align: middle;
}

.sig-saved { font-size: 0.78rem; color: var(--ok); margin-left: 0.5rem; }
.sig-hint { font-size: 0.78rem; color: var(--muted); font-style: italic; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.photo-card {
  position: relative;
  isolation: isolate;
  background: var(--surface2);
  border: 2px dashed #4a4a55;
  border-radius: 10px;
  padding: 0.85rem;
}

.photo-card .drop-zone {
  position: relative;
  z-index: 3;
  min-height: 5.5rem;
}

.photo-card.has-image { border-style: solid; border-color: var(--ok); }
.photo-card .title { font-weight: 700; font-size: 0.9rem; }
.photo-card .caption { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.5rem; }

.photo-slot-extra {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.photo-slot-prompt {
  font-size: 0.78rem;
  color: var(--orange);
  font-weight: 600;
  margin-bottom: 0.45rem;
  line-height: 1.35;
}

.photo-yn-row .yn-pills { margin-top: 0; }

.photo-angle-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.photo-angle-input {
  width: 100%;
  max-width: 220px;
}

.drop-zone {
  position: relative;
  border: 2px dashed #4a4a55;
  border-radius: 8px;
  padding: 0.75rem;
  min-height: 100px;
  cursor: pointer;
  text-align: center;
  transition: 0.15s;
  touch-action: manipulation;
}

.drop-zone:hover, .drop-zone.drag-over { border-color: var(--orange); background: rgba(255,102,0,0.08); }
label.drop-zone {
  display: block;
  margin: 0;
}
label.drop-zone input[type="file"],
.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.drop-zone-inner { position: relative; z-index: 1; pointer-events: none; }
.drop-zone strong { display: block; font-size: 0.82rem; }
.drop-zone span { display: block; font-size: 0.72rem; color: var(--muted); }

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.thumb-wrap {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; }

.thumb-wrap button {
  position: absolute;
  top: 2px; right: 2px;
  border: none;
  background: rgba(139,26,26,0.9);
  color: #fff;
  width: 20px; height: 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.7rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(90deg, var(--red), var(--orange));
  border-color: var(--orange);
  color: #fff;
}

.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: #3d3d48; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.78rem; }
.btn-block { width: 100%; }

.export-panel {
  text-align: center;
  padding: 2rem 1.5rem;
  background: linear-gradient(160deg, var(--surface) 0%, #1e1e26 100%);
  border: 2px solid var(--orange);
  border-radius: 12px;
}

.export-logo {
  max-width: 180px;
  max-height: 64px;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 0 auto 0.75rem;
  display: block;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
  text-align: left;
}

.summary-item {
  background: var(--surface2);
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.78rem;
  border: 1px solid var(--border);
}

.summary-item strong {
  display: block;
  color: var(--orange);
  font-size: 0.65rem;
  text-transform: uppercase;
  margin-bottom: 0.1rem;
}

#toast {
  position: fixed;
  bottom: 1rem; right: 1rem;
  background: #2a2a32;
  color: #fff;
  padding: 0.6rem 1rem;
  border-left: 4px solid var(--orange);
  border-radius: 8px;
  opacity: 0;
  transition: 0.2s;
  z-index: 9999;
}

#toast.show { opacity: 1; }

.upload-loading {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(10, 10, 14, 0.72);
  backdrop-filter: blur(2px);
}

.upload-loading.show {
  display: flex;
}

.upload-loading-card {
  min-width: min(280px, 90vw);
  padding: 1.25rem 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, #2a2a32 0%, #1e1e26 100%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.upload-loading-spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 0.85rem;
  border: 3px solid rgba(255, 102, 0, 0.25);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: upload-spin 0.9s linear infinite;
}

.upload-loading-text {
  margin: 0;
  color: #f0f0f2;
  font-size: 0.92rem;
  font-weight: 600;
}

body.upload-busy {
  overflow: hidden;
}

@keyframes upload-spin {
  to { transform: rotate(360deg); }
}

#print-root { display: none; }
#print-root.pdf-render {
  display: block !important;
  position: fixed;
  left: -9999px;
  top: 0;
  width: 210mm;
  z-index: -1;
  pointer-events: none;
}

body.pdf-exporting {
  overflow: hidden !important;
}

body.pdf-exporting::after {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 31, 0.72);
  z-index: 10000;
  pointer-events: none;
}

body.pdf-exporting #print-root.pdf-render,
#print-root.pdf-render.pdf-exporting {
  position: fixed !important;
  left: 0 !important;
  top: 0 !important;
  width: 794px !important;
  min-width: 794px !important;
  max-width: none !important;
  z-index: 10001 !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: none !important;
  background: #ffffff !important;
  overflow: visible !important;
}

body.pdf-exporting #print-root .print-page {
  width: 794px !important;
  min-width: 794px !important;
  max-width: none !important;
  box-sizing: border-box;
}

body.pdf-capture-mode {
  background: #ffffff !important;
}

body.pdf-capture-mode .app-shell,
body.pdf-capture-mode .report-preview-modal,
body.pdf-capture-mode #toast {
  display: none !important;
}

body.pdf-capture-mode #print-root.pdf-render {
  position: static !important;
  left: auto !important;
  width: 100% !important;
  z-index: 1 !important;
  pointer-events: auto !important;
}

.section-next-bar {
  display: flex;
  justify-content: flex-end;
  padding: 1.25rem 0 0.25rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.section-next-btn {
  min-width: 8rem;
}

.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  margin-top: 0.5rem;
}

.report-preview-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.75);
  padding: 1rem;
}

.report-preview-modal.open { display: flex; align-items: center; justify-content: center; }

.report-preview-modal.pdf-export-mode {
  background: #ffffff;
  padding: 0;
  z-index: 10002;
}

.report-preview-modal.pdf-export-mode .report-preview-dialog {
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
}

.report-preview-modal.pdf-export-mode .report-preview-toolbar {
  display: none;
}

.report-preview-modal.pdf-export-mode .report-preview-body {
  padding: 0;
  overflow: visible;
  max-height: none;
  background: #ffffff;
}

.drop-zone {
  display: block;
}

.report-preview-dialog {
  background: #fff;
  color: #1a1a1f;
  width: min(920px, 100%);
  max-height: 92vh;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 2px solid var(--orange);
}

.report-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  background: #252530;
  color: #fff;
}

.report-preview-body {
  overflow: auto;
  padding: 12px;
  background: #e8eaed;
}

/* ——— Mobile: touch-friendly layout for phones & tablets ——— */
@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    display: block;
    min-height: 100dvh;
  }

  .nav {
    position: sticky;
    top: 0;
    z-index: 100;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.35rem;
    padding: 0.45rem 0.5rem;
    padding-top: calc(0.45rem + env(safe-area-inset-top, 0px));
    border-right: none;
    border-bottom: 2px solid var(--orange);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar { display: none; }

  .brand-lock,
  .nav h1 { display: none; }

  .nav button[data-section] {
    flex: 0 0 auto;
    min-width: max-content;
    text-align: center;
    font-size: 0.78rem;
    padding: 0.55rem 0.7rem;
    line-height: 1.25;
    min-height: 44px;
    touch-action: manipulation;
  }

  .nav-actions {
    flex: 0 0 auto;
    width: auto;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 0.35rem;
    padding-top: 0;
    margin-top: 0;
    margin-left: auto;
  }

  .nav-actions .btn,
  .nav-actions .btn-sm,
  .nav-actions select {
    min-height: 44px;
    font-size: 0.78rem;
    padding: 0.45rem 0.65rem;
    touch-action: manipulation;
  }

  .insp-my-reports {
    min-width: 7.5rem;
    font-size: 0.8rem;
    padding: 0.45rem 0.5rem;
  }

  body.trial-demo-active .nav {
    top: calc(3.25rem + env(safe-area-inset-top, 0px));
  }

  .trial-demo-bar {
    padding: 0.5rem 0.65rem;
    padding-top: calc(0.5rem + env(safe-area-inset-top, 0px));
    gap: 0.4rem;
  }

  .trial-demo-bar .btn-sm {
    min-height: 40px;
    flex: 1 1 auto;
  }

  .trial-demo-label {
    width: 100%;
    font-size: 0.75rem;
    line-height: 1.3;
  }

  .trial-demo-bar:not(.hidden) ~ .app-shell {
    padding-top: 0;
  }

  .trial-demo-bar ~ .app-shell .nav,
  .trial-demo-bar ~ .app-shell .main {
    margin-top: 0;
  }

  .app-head { display: none; }

  .main {
    padding: 0.65rem 0.65rem calc(2rem + env(safe-area-inset-bottom, 0px));
    max-width: none;
    overflow-x: hidden;
  }

  .top-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.65rem;
  }

  .top-bar .report-no { min-width: 0; width: 100%; font-size: 1rem; }

  .panel { padding: 0.85rem 0.9rem; margin-bottom: 0.75rem; }

  .panel h2 { font-size: 0.95rem; }

  label { font-size: 0.72rem; margin-bottom: 0.35rem; }

  input[type='text'],
  input[type='email'],
  input[type='password'],
  input[type='date'],
  textarea,
  select {
    font-size: 16px;
    padding: 0.75rem 0.8rem;
    min-height: 44px;
    background: #1e1e26;
    color: #ffffff;
    border: 1px solid #505060;
    -webkit-text-fill-color: #ffffff;
  }

  input::placeholder, textarea::placeholder {
    color: #8a9099;
    opacity: 1;
  }

  textarea { min-height: 110px; line-height: 1.45; }

  .field-example { font-size: 0.7rem; margin-bottom: 0.5rem; }

  .yesno-row {
    flex-direction: column;
    align-items: stretch;
    padding: 0.65rem 0.75rem;
  }

  .yesno-row .label { font-size: 0.85rem; }

  .yn-pills { width: 100%; }
  .yn-pills button {
    flex: 1;
    padding: 0.55rem 0.9rem;
    font-size: 0.85rem;
    min-height: 44px;
  }

  .btn,
  .btn-sm,
  .btn-primary,
  .btn-secondary {
    min-height: 44px;
    touch-action: manipulation;
  }

  .browse-mode-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .browse-mode-bar .btn { width: 100%; }

  .folder-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .folder-toolbar .btn,
  .folder-breadcrumb { width: 100%; }

  .folder-breadcrumb { margin-bottom: 0.25rem; }

  .add-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .add-inline .btn { width: 100%; }

  .filter-bar { grid-template-columns: 1fr; }

  .filter-bar .btn { width: 100%; }

  .folder-row {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .folder-open {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
  }

  .folder-meta {
    margin-left: 0;
    width: 100%;
  }

  .folder-row.report-row {
    flex-direction: column;
    align-items: stretch;
  }

  .folder-row.report-row > .btn {
    width: 100%;
    margin-top: 0.35rem;
  }

  .insp-report-row {
    flex-direction: column;
    align-items: stretch;
  }

  .insp-report-actions {
    width: 100%;
    flex-direction: column;
  }

  .insp-report-actions .btn { width: 100%; }

  .insp-brief { width: 100%; }

  .insp-img-row {
    flex-direction: column;
    align-items: stretch;
  }

  .insp-thumb {
    width: 100%;
    height: auto;
    max-height: 220px;
  }

  .insp-img-fields select,
  .insp-img-fields input {
    min-height: 44px;
    font-size: 16px;
  }

  .photo-grid { grid-template-columns: 1fr; gap: 0.75rem; }

  .doc-image-grid { grid-template-columns: 1fr; }

  .sig-canvas {
    max-width: none;
    height: 120px;
  }

  .drop-zone {
    min-height: 4.5rem;
    padding: 1rem 0.75rem;
  }

  .export-panel { padding: 1.25rem 1rem; }
  .export-logo { max-width: 140px; max-height: 48px; }
  .export-actions { flex-direction: column; }
  .export-actions .btn { width: 100%; }

  .compile-bar { flex-direction: column; }
  .compile-bar .btn { width: 100%; }

  .report-table-wrap {
    overflow-x: visible;
    margin-top: 0.65rem;
  }

  .report-table.report-table-mobile-cards thead { display: none; }

  .report-table.report-table-mobile-cards tbody tr {
    display: block;
    margin-bottom: 0.65rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
  }

  .report-table.report-table-mobile-cards tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-bottom: none;
    font-size: 0.88rem;
  }

  .report-table.report-table-mobile-cards tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--muted);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    padding-top: 0.1rem;
  }

  .report-table.report-table-mobile-cards tbody td[data-label='']::before {
    display: none;
  }

  .report-table.report-table-mobile-cards tbody td:last-child {
    display: block;
    padding-top: 0.55rem;
    margin-top: 0.25rem;
    border-top: 1px solid var(--border);
  }

  .report-table.report-table-mobile-cards tbody td:last-child .btn {
    width: 100%;
  }

  .insp-bom-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-card,
  .bom-modal-card {
    width: 100%;
    max-height: 92dvh;
    border-radius: 12px 12px 0 0;
    margin: 0;
  }

  .bom-modal-card {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }

  .report-preview-modal {
    padding: 0;
    align-items: stretch;
  }

  .report-preview-dialog {
    width: 100%;
    max-width: none;
    max-height: 100dvh;
    border-radius: 0;
  }

  .report-preview-body {
    max-height: calc(100dvh - 3.25rem);
  }

  .admin-card.user-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .admin-stats { grid-template-columns: repeat(2, 1fr); }

  #toast {
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    left: 0.75rem;
    right: 0.75rem;
    max-width: none;
    text-align: center;
  }

  .auth-gate { padding: 1rem; }

  .auth-card {
    width: 100%;
    padding: 1.5rem 1.25rem;
  }

  .auth-input { font-size: 16px; min-height: 44px; }
}

/* ——— Desktop / PC: sidebar workspace, tables, keyboard focus ——— */
@media (min-width: 761px) {
  .app-shell {
    min-height: 100vh;
    align-items: start;
  }

  .nav {
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  .trial-demo-bar:not(.hidden) ~ .app-shell {
    padding-top: 3rem;
  }

  .trial-demo-bar:not(.hidden) ~ .app-shell .nav {
    top: 3rem;
    max-height: calc(100vh - 3rem);
  }

  .trial-demo-bar:not(.hidden) ~ .app-shell .nav,
  .trial-demo-bar:not(.hidden) ~ .app-shell .main {
    margin-top: 0;
  }

  .main {
    min-width: 0;
    width: 100%;
    max-width: 960px;
  }

  .nav button[data-section]:hover {
    background: rgba(255, 102, 0, 0.12);
  }

  .folder-row:hover {
    border-color: rgba(59, 130, 246, 0.45);
  }

  .report-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.06);
  }

  .insp-report-row:hover {
    border-color: rgba(59, 130, 246, 0.35);
  }

  .modal {
    align-items: center;
    padding: 1.5rem;
  }

  .modal-card {
    width: min(440px, 100%);
    border-radius: var(--radius);
    max-height: 88vh;
  }

  .bom-modal-card {
    width: min(920px, 96vw);
    max-height: min(85vh, 720px);
    border-radius: var(--radius);
  }

  .report-preview-modal {
    align-items: center;
    padding: 1rem;
  }

  .report-preview-dialog {
    width: min(920px, 96vw);
    max-height: 92vh;
    border-radius: 10px;
  }

  .report-table.report-table-mobile-cards thead {
    display: table-header-group;
  }

  .report-table.report-table-mobile-cards tbody tr {
    display: table-row;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
  }

  .report-table.report-table-mobile-cards tbody td {
    display: table-cell;
    padding: 0.5rem 0.45rem;
    border-bottom: 1px solid var(--border);
  }

  .report-table.report-table-mobile-cards tbody td::before {
    display: none;
  }

  .report-table.report-table-mobile-cards tbody td:last-child {
    display: table-cell;
    padding: 0.5rem 0.45rem;
    margin: 0;
    border-top: none;
  }

  .report-table.report-table-mobile-cards tbody td:last-child .btn {
    width: auto;
  }

  .btn:focus-visible,
  .nav button:focus-visible,
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible {
    outline: 2px solid var(--orange);
    outline-offset: 2px;
  }

  .browse-mode-bar,
  .folder-toolbar,
  .compile-bar,
  .insp-report-actions {
    flex-direction: row;
  }

  .browse-mode-bar .btn,
  .folder-toolbar .btn,
  .compile-bar .btn {
    width: auto;
  }

  .insp-img-row {
    flex-direction: row;
    align-items: flex-start;
  }

  .insp-thumb {
    width: 88px;
    height: 88px;
    max-height: none;
  }
}

@media (min-width: 761px) and (max-width: 980px) {
  .app-shell {
    grid-template-columns: 190px 1fr;
  }

  .nav button[data-section] {
    font-size: 0.78rem;
    padding: 0.5rem 0.55rem;
  }
}

@media (min-width: 1200px) {
  .main {
    max-width: 1040px;
  }
}

/* VMS — Valley Maintenance Solutions overrides */
.auth-logo-vms {
  width: min(320px, 92vw);
  height: auto;
  margin: 0 auto 1rem;
  display: block;
}

.auth-company {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--blue-dark);
}

.auth-powered {
  margin: 1rem 0 0;
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.app-head-logo-vms {
  max-width: min(420px, 92vw);
  max-height: 96px;
}

.role-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--orange);
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  margin-left: 0.35rem;
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.folder-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.75rem;
  border: 2px dashed #4a4a55;
  border-radius: 10px;
  background: var(--surface2);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--text);
  transition: 0.15s;
}

.folder-card:hover,
.folder-card.active {
  border-style: solid;
  border-color: var(--orange);
  background: rgba(59, 130, 246, 0.08);
}

.folder-icon { font-size: 1.25rem; }
.folder-name { font-weight: 700; font-size: 0.88rem; }
.folder-meta { font-size: 0.72rem; color: var(--muted); }

.component-list { margin: 0.75rem 0 1rem; }
.component-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.35rem;
  font-size: 0.82rem;
}

.add-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.5rem;
}

.add-inline input { flex: 1; min-width: 10rem; }

.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.report-table-wrap { overflow-x: auto; margin-top: 0.5rem; }
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.report-table th,
.report-table td {
  padding: 0.5rem 0.45rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.report-table th {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.compile-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0;
}

.count-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--orange);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.35rem;
}

.shell-hidden { display: none !important; }

.role-picker {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.auth-role-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
  text-align: center;
}

.insp-my-reports {
  width: 100%;
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  padding: 0.35rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.insp-upload-list { display: flex; flex-direction: column; gap: 0.65rem; }

.insp-upload-card, .insp-img-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.insp-thumb { width: 88px; height: 88px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }

.insp-img-fields { flex: 1; display: grid; gap: 0.35rem; }
.insp-img-fields label { font-size: 0.68rem; margin: 0; }
.insp-img-fields input, .insp-img-fields select {
  width: 100%;
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
}

.insp-img-fields select.insp-sev-high,
.insp-img-fields select.insp-thk-sev.insp-sev-high {
  background: #dc2626;
  border-color: #b91c1c;
  color: #fff;
  font-weight: 700;
}

.insp-img-fields select.insp-sev-medium,
.insp-img-fields select.insp-thk-sev.insp-sev-medium {
  background: #ea580c;
  border-color: #c2410c;
  color: #fff;
  font-weight: 700;
}

.insp-img-fields select.insp-sev-low,
.insp-img-fields select.insp-thk-sev.insp-sev-low {
  background: #eab308;
  border-color: #ca8a04;
  color: #1a1a1f;
  font-weight: 700;
}

.insp-sev-badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.3;
}

.insp-sev-badge.insp-sev-high { background: #dc2626; color: #fff; }
.insp-sev-badge.insp-sev-medium { background: #ea580c; color: #fff; }
.insp-sev-badge.insp-sev-low { background: #eab308; color: #1a1a1f; }

.insp-mpi-panel { margin-bottom: 0.75rem; }
.insp-mpi-panel h3 { margin: 0 0 0.35rem; font-size: 0.95rem; color: var(--orange); }

.insp-bom-table input { width: 100%; font-size: 0.82rem; }

.insp-report-row { flex-wrap: wrap; }
.insp-brief { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 0.2rem; }
.insp-report-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.browse-mode-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.browse-mode-bar .btn.active { box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35); }

.folder-row.report-row { justify-content: space-between; }

.report-open { flex: 1; min-width: 0; }

.folder-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  padding: 0.65rem 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.folder-breadcrumb { flex: 1; font-weight: 700; font-size: 0.88rem; color: var(--orange); }

.folder-list { display: grid; gap: 0.45rem; margin-bottom: 1rem; }

.folder-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.folder-row.selected { border-color: var(--orange); background: rgba(59, 130, 246, 0.1); }

.folder-check {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

.folder-open {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0.25rem 0;
}

.folder-open.static { cursor: default; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(8, 8, 12, 0.75);
}

.modal.hidden { display: none; }

.modal-card {
  width: min(400px, 100%);
  margin: 0;
}

.bom-modal-card {
  width: min(920px, 100%);
  max-height: min(85vh, 720px);
  display: flex;
  flex-direction: column;
}

.bom-modal-table-wrap {
  overflow: auto;
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.bom-modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.bom-modal-table th,
.bom-modal-table td {
  padding: 0.55rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.bom-modal-table th {
  position: sticky;
  top: 0;
  background: var(--surface2);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  z-index: 1;
}

.bom-modal-table tr:last-child td { border-bottom: none; }

.bom-modal-empty {
  padding: 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.trial-demo-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: linear-gradient(90deg, #1e3a5f, #2d1b4e);
  border-bottom: 2px solid var(--orange);
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}

.trial-demo-bar.hidden { display: none; }

.trial-demo-label { font-size: 0.82rem; font-weight: 700; color: #fbbf24; margin-right: 0.25rem; }

.trial-demo-bar:not(.hidden) ~ .app-shell {
  padding-top: 3rem;
}

.trial-demo-bar:not(.hidden) ~ .app-shell .nav,
.trial-demo-bar:not(.hidden) ~ .app-shell .main {
  margin-top: 0;
}

.trial-action-blocked,
.trial-demo-active .trial-action-blocked {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.admin-stat {
  padding: 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
}

.admin-stat span { display: block; font-size: 1.75rem; font-weight: 800; color: var(--orange); }
.admin-stat label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.admin-section { display: none; }
.admin-section.active { display: block; }

.admin-card {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.admin-card.user-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.85rem;
}

.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.mono-link {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  word-break: break-all;
  padding: 0.5rem;
  background: var(--surface2);
  border-radius: 6px;
}

.status-bad { color: #f87171 !important; }