* { box-sizing: border-box; }

:root {
  /* Brand */
  --brand-dark: #1e3a5f;
  --brand: #2c5282;
  --brand-light: #ebf2fa;

  /* Surfaces */
  --bg: #f4f6f8;
  --card: #ffffff;

  /* Text */
  --text: #1f2937;
  --text-strong: #111827;
  --text-muted: #6b7280;

  /* Borders */
  --border: #d1d5db;
  --border-soft: #e5e7eb;

  /* Status — text + bg + accent (the bold version used for icons/borders) */
  --error: #b91c1c;
  --error-bg: #fef2f2;
  --error-accent: #dc2626;
  --error-border: #fecaca;
  --success: #065f46;
  --success-bg: #f0fdf4;
  --success-accent: #00c875;
  --success-border: #bbf7d0;
  --warn: #92400e;
  --warn-bg: #fffbeb;
  --warn-accent: #f59e0b;
  --warn-border: #fcd34d;
  --info-bg: #dbeafe;
  --info: #1e40af;

  /* Spacing scale (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 14px;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-card-hover: 0 4px 12px rgba(44, 82, 130, 0.12);
  --shadow-header: 0 2px 6px rgba(0,0,0,0.1);
  --shadow-modal: 0 12px 30px rgba(0,0,0,0.3);
  --shadow-elevated: 0 10px 30px rgba(0,0,0,0.18);
  --shadow-sticky: 0 -4px 12px rgba(0,0,0,0.05);

  /* Motion */
  --t-fast: 0.12s;
  --t-base: 0.15s;
  --t-slow: 0.25s;

  /* Type */
  --font-sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Montserrat', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  margin: 0;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Industrial mono small-caps — used for metadata strips, status pills, tower IDs */
.mono-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

header.app-header {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: white;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
header.app-header h1 { margin: 0; font-size: 1.15rem; font-weight: 600; }
header.app-header .sub { font-size: 0.78rem; opacity: 0.85; margin-top: 0.2rem; }
header.app-header .user-chip {
  font-size: 0.8rem;
  opacity: 0.92;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
header.app-header .logout-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: white;
  font-size: 0.78rem;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
header.app-header .logout-btn:hover { background: rgba(255,255,255,0.22); }

header.app-header .dev-fill-btn {
  background: #f59e0b;
  border: 1px solid #d97706;
  color: #1f2937;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
header.app-header .dev-fill-btn:hover { background: #fbbf24; }
header.app-header .dev-fill-btn:disabled { opacity: 0.6; cursor: wait; }

main {
  max-width: 720px;
  margin: 1.5rem auto;
  padding: 0 1rem 4rem;
}

/* Auth pages — centered narrow card */
.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  background: linear-gradient(160deg, var(--brand-dark) 0%, var(--brand) 60%, #4a6b95 100%);
}
.auth-brand {
  text-align: center;
  margin-bottom: 1rem;
}
.auth-logo-wrap {
  background: white;
  border-radius: 14px;
  padding: 1rem 1.25rem;
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
.auth-logo {
  display: block;
  width: 100%;
  height: auto;
}
.auth-card {
  background: var(--card);
  border-radius: 14px;
  padding: 1.5rem 1.5rem 1.75rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
}
.auth-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}
.auth-card h2.brand {
  font-size: 1.7rem;
  margin: 0 0 1rem;
  color: var(--brand);
}
.auth-card .auth-desc {
  margin: 0 0 1.1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
  text-align: center;
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.card h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 1rem;
  font-weight: 600;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  margin: 0.85rem 0 0.3rem;
}
input, select, textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.15);
}
textarea { min-height: 80px; resize: vertical; }

/* Monospace text style (originally from the S/N inputs) on every form field —
   inputs the tech types into AND dropdowns. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
textarea,
select {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* Treat the placeholder option (value="") like an input placeholder: muted
   when shown as the closed select's value, normal color once a real option
   is chosen. The second rule keeps the open dropdown panel readable. */
select:has(option[value=""]:checked) { color: var(--text-muted); }
select option { color: #1f2937; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--brand);
  color: white;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}
.btn-secondary {
  background: white;
  color: var(--brand);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #f9fafb; border-color: var(--brand); }

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  font-size: 0.85rem;
}
.auth-links a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
}
.auth-links a:hover { text-decoration: underline; }

.alert {
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}
.alert.error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid #fecaca;
}
.alert.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #bbf7d0;
}
.alert.show { display: block; }

.help-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.divider {
  height: 1px;
  background: var(--border-soft);
  margin: 1.25rem 0;
}

/* Dashboard tiles */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.tile {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.tile:hover {
  border-color: var(--brand);
  box-shadow: 0 4px 12px rgba(44, 82, 130, 0.12);
  transform: translateY(-1px);
}
.tile-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--brand-light);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
}
.tile-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.tile-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

@media (max-width: 480px) {
  .tile-grid { grid-template-columns: 1fr; }
}

.tile.placeholder {
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
  background: #f9fafb;
}
.tile.placeholder .tile-icon {
  background: #e5e7eb;
  color: #6b7280;
}
.tile.placeholder .tile-sub {
  color: #b45309;
  font-weight: 500;
}

/* Install modal */
.install-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.install-modal[hidden] { display: none; }
.install-modal-card {
  background: white;
  border-radius: 14px;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 12px 30px rgba(0,0,0,0.3);
}
.install-modal-card h3 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  color: var(--text);
  text-align: center;
}
.install-modal-card p { margin: 0 0 0.85rem; font-size: 0.9rem; color: #374151; }
.install-modal-card ol, .install-modal-card ul {
  margin: 0 0 1rem;
  padding-left: 1.4rem;
  color: #374151;
  font-size: 0.9rem;
  line-height: 1.6;
}
.install-modal-card .install-modal-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}
.install-modal-card .install-modal-close { margin-top: 0.5rem; }

/* ---------- Onboarding section download tiles ---------- */
.install-tile {
  display: none;
  font: inherit;
  text-align: center;
}
.install-tile.show { display: flex; }
.drawer-body .download-tile .tile-icon {
  background: #00c875;
  color: white;
}

/* PWA install modal */
.install-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.install-modal[hidden] { display: none; }
.install-modal-card {
  background: white;
  border-radius: 14px;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 12px 30px rgba(0,0,0,0.3);
}
.install-modal-card h3 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  color: #1f2937;
  text-align: center;
}
.install-modal-card p { margin: 0 0 0.85rem; font-size: 0.9rem; color: #374151; }
.install-modal-card ol, .install-modal-card ul {
  margin: 0 0 1rem;
  padding-left: 1.4rem;
  color: #374151;
  font-size: 0.9rem;
  line-height: 1.6;
}
.install-modal-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}
.install-modal-close {
  margin-top: 0.5rem;
  width: 100%;
  background: var(--brand);
  color: white;
  border: none;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.install-modal-close:hover { background: var(--brand-dark); }

/* ---------- Brand mark (PULSE wordmark) ---------- */
.brand {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ---------- Dashboard hamburger + drawer ---------- */
.hamburger-btn,
.header-back-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  color: white;
  text-decoration: none;
  transition: background var(--t-base);
}
.hamburger-btn:hover,
.header-back-btn:hover { background: rgba(255,255,255,0.22); }
.hamburger-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: white;
  border-radius: 1px;
}
.header-back-btn {
  font-size: 1.15rem;
  line-height: 1;
}
.header-titles { flex: 1; min-width: 0; }
.header-titles h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Team pill (inspect header) — small mono badge */
.user-team-pill {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.22rem 0.5rem;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.user-team-pill:empty { display: none; }

/* Keep the inspect/admin header in one row on phones (no vertical stacking) */
@media (max-width: 480px) {
  header.app-header { padding: 0.85rem 1rem; gap: 0.6rem; }
  header.app-header .header-titles h1 { font-size: 0.95rem; }
  header.app-header .sub { font-size: 0.7rem; }
  header.app-header .user-chip { gap: 0.35rem; }
  header.app-header .logout-btn { padding: 0.3rem 0.55rem; font-size: 0.72rem; }
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 90;
  animation: drawerFade 0.2s ease;
}
@keyframes drawerFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: min(380px, 90vw);
  background: var(--bg);
  z-index: 100;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 16px rgba(0,0,0,0.18);
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: white;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.drawer-close {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.drawer-close:hover { background: rgba(255,255,255,0.22); }
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  -webkit-overflow-scrolling: touch;
}
.drawer-body .card { margin-bottom: 1rem; }
.drawer-body .tile-grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}
.drawer-body .tile {
  aspect-ratio: 1 / 1;
  padding: 0.55rem 0.4rem;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.4rem;
}
.drawer-body .tile .tile-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 0.85rem;
}
.drawer-body .tile .tile-title {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.drawer-body .tile .tile-sub { display: none; }

/* ---------- Admin user management table ---------- */
.admin-table-wrap {
  overflow-x: auto;
  margin: -0.25rem;
  padding: 0.25rem;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.admin-table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
.admin-table td {
  padding: 0.6rem 0.6rem;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table select {
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: white;
  border: 1px solid var(--border);
  min-width: 100px;
}
.admin-table select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.admin-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 1rem;
}
.admin-hint {
  margin: 0.85rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ---------- Dashboard activity lists ---------- */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.activity-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.85rem 1rem;
  background: white;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
a.activity-item:hover {
  border-color: var(--brand);
  box-shadow: 0 2px 8px rgba(44, 82, 130, 0.1);
}
.activity-item.warn {
  background: var(--warn-bg);
  border-color: #fcd34d;
}
.activity-item.warn .activity-title { color: var(--warn); }
.activity-title {
  font-weight: 600;
  font-size: 0.95rem;
}
.activity-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.activity-note {
  font-size: 0.85rem;
  color: #374151;
  margin-top: 0.3rem;
  font-style: italic;
}
.activity-empty {
  padding: 0.85rem 1rem;
  background: white;
  border-radius: 10px;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
}

/* ---------- Skeleton loaders (replaces "Loading…" text on activity feeds) ---------- */
.skeleton-stack {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.skeleton-row {
  background: linear-gradient(
    90deg,
    var(--border-soft) 0%,
    #f3f4f6 50%,
    var(--border-soft) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  border: 1px solid transparent;
}
.skeleton-line {
  height: 12px;
  background: rgba(0,0,0,0.06);
  border-radius: 4px;
}
.skeleton-line.title { width: 65%; height: 14px; margin-bottom: 8px; }
.skeleton-line.meta { width: 40%; height: 10px; }
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton-row { animation: none; }
}

/* ---------- Inspection page (lifted from inspect.html inline <style>) ---------- */
.inspect-meta-strip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: 0.65rem 0.9rem;
  margin-bottom: var(--space-4);
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.inspect-meta-strip .meta-key {
  color: var(--text-muted);
  margin-right: 0.35rem;
}
.inspect-meta-strip .meta-val {
  color: var(--text-strong);
  font-weight: 600;
  letter-spacing: 0.08em;
}
.inspect-meta-strip .meta-divider {
  width: 1px;
  align-self: stretch;
  background: var(--border-soft);
}

/* Repair sub-cards inside Repairs Logged */
.repair {
  background: #fafbfc;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  position: relative;
}
.repair-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}
.repair-num {
  font-weight: 600;
  color: var(--brand);
  font-size: 0.9rem;
}
.remove-btn {
  background: none;
  border: none;
  color: var(--error-accent);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.remove-btn:hover { background: var(--error-bg); }

.add-btn {
  width: 100%;
  background: white;
  border: 2px dashed #cbd5e0;
  color: #4a5568;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  transition: all var(--t-base);
}
.add-btn:hover { border-color: var(--brand); color: var(--brand); background: #f7fafc; }

/* Inspection 2-col row & sn 3-col row */
.row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.sn-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-3); }
@media (max-width: 480px) {
  .row { grid-template-columns: 1fr; }
  .sn-row { grid-template-columns: 1fr; }
}

/* Bottom action bar — sticky on mobile, inline (button-row only) on wide */
.button-row {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: var(--space-3);
  margin-top: var(--space-2);
}
@media (max-width: 480px) { .button-row { grid-template-columns: 1fr; } }

.inspect-actions-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-3) var(--space-4) max(var(--space-3), env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sticky);
  z-index: 50;
}
.inspect-actions-bar .button-row {
  margin: 0 auto;
  max-width: 720px;
}
/* Scope bottom-clear padding only to pages that actually have the fixed bar */
main:has(.inspect-actions-bar) {
  padding-bottom: calc(5.5rem + env(safe-area-inset-bottom));
}

.submit-btn, .save-btn {
  width: 100%;
  border: none;
  padding: 0.875rem;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--t-base), border-color var(--t-base), color var(--t-base);
}
.submit-btn { background: var(--brand); color: white; }
.submit-btn:hover:not(:disabled) { background: var(--brand-dark); }
.submit-btn:disabled { background: #9ca3af; cursor: not-allowed; }
.save-btn {
  background: white;
  color: #4a5568;
  border: 1px solid #cbd5e0;
}
.save-btn:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
  background: #f7fafc;
}
.save-btn:disabled { color: #9ca3af; cursor: not-allowed; }

/* Status banner inside the inspection page */
.status {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: 0.9rem;
  display: none;
}
.status.show { display: block; }
.status.loading { background: var(--info-bg); color: var(--info); }
.status.success { background: var(--success-bg); color: var(--success); }
.status.error { background: #fee2e2; color: #991b1b; }

/* Inspection-specific small bits */
.q-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-style: italic;
}
.part-filters {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
@media (max-width: 480px) { .part-filters { grid-template-columns: 1fr; } }
.part-filters select, .part-filters input {
  padding: var(--space-2) 0.625rem;
  font-size: 0.875rem;
}
.search-wrap { position: relative; }
.search-wrap::before {
  content: '🔍';
  position: absolute;
  left: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  opacity: 0.5;
  pointer-events: none;
}
.search-wrap input { padding-left: 2rem; }
.no-results {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
  padding: var(--space-2) 0;
}

/* Faulty/Malfunctioning diagnostic block + auto-issue-ticket message */
.faulty-block {
  background: var(--warn-bg);
  border-left: 3px solid var(--warn-accent);
  padding: 0.5rem 0.85rem 0.85rem;
  border-radius: var(--radius-sm);
  margin-top: var(--space-2);
}
.faulty-block label { color: var(--warn); }
.cascade-block {
  margin-top: 0.4rem;
  padding-left: 0.6rem;
  border-left: 2px solid var(--warn-accent);
}
.field-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: -0.05rem 0 0.3rem;
  font-style: italic;
}
.ticket-message {
  margin: var(--space-3) 0 0;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--warn-accent);
  background: #fef3c7;
  color: var(--warn);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-align: center;
}

/* Inspection checklist counter & items */
.checklist-counter {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.checklist-counter.complete { color: var(--success); }
.checklist-counter.incomplete { color: #b45309; }
.check-item {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.625rem var(--space-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  margin-bottom: 0.4rem;
  background: white;
  cursor: pointer;
  transition: all var(--t-fast);
}
.check-item:hover { border-color: #cbd5e0; background: #f7fafc; }
.check-item.checked {
  border-color: var(--success-accent);
  background: var(--success-bg);
}
.check-item input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0.125rem 0 0;
  flex-shrink: 0;
  accent-color: var(--success-accent);
  cursor: pointer;
}
.check-item label {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: #374151;
  cursor: pointer;
  flex: 1;
  font-weight: 400;
}
.check-item .check-num {
  font-weight: 700;
  color: var(--brand);
  margin-right: 0.25rem;
  font-family: var(--font-mono);
}
.check-item.checked .check-num { color: var(--success); }

/* SN inputs with fixed alphabetic prefix to the left */
.sn-input { display: flex; align-items: stretch; }
.sn-input input {
  flex: 1;
  min-width: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: none;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}
.sn-prefix {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 0 0.65rem;
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
  color: #4b5563;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
  user-select: none;
}
input[readonly] { background: #f9fafb; color: #4b5563; cursor: not-allowed; }

/* Photo upload slots */
.photo-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin-top: var(--space-2); }
.photo-slot {
  border: 2px dashed #cbd5e0;
  border-radius: var(--radius-md);
  padding: var(--space-2);
  background: white;
  text-align: center;
  cursor: pointer;
  transition: all var(--t-base);
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}
.photo-slot:hover { border-color: var(--brand); background: #f7fafc; }
.photo-slot.has-file { border-style: solid; border-color: var(--success-accent); padding: 0; }
.photo-slot input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.photo-slot .photo-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.photo-slot .photo-hint {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-top: 0.2rem;
}
.photo-slot img {
  max-width: 100%;
  max-height: 110px;
  border-radius: var(--radius-sm);
  display: block;
}
.photo-slot .photo-clear {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 1.4rem;
  height: 1.4rem;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  display: none;
  z-index: 2;
}
.photo-slot.has-file .photo-clear { display: block; }
.photo-multi { display: flex; flex-direction: column; }
.photo-thumbs:empty { display: none; }
.photo-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}
.photo-thumb {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #f3f4f6;
  border: 1px solid var(--success-accent);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .thumb-x {
  position: absolute;
  top: 0.15rem;
  right: 0.15rem;
  background: rgba(0,0,0,0.65);
  color: white;
  border: none;
  border-radius: 50%;
  width: 1.25rem;
  height: 1.25rem;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.required-photos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-2);
  margin-top: 0.25rem;
}
@media (max-width: 480px) { .required-photos-grid { grid-template-columns: 1fr 1fr; } }
.required-photos-grid .photo-slot { min-height: 110px; }
.required-photos-grid .photo-label { font-size: 0.72rem; }
.photo-slot.missing {
  border-color: var(--error-accent);
  background: var(--error-bg);
}
.photo-slot.missing .photo-label { color: var(--error-accent); }

/* ---------- Photos card: divider + optional multi-file blocks ---------- */
.photos-divider {
  border: none;
  border-top: 1px dashed #d1d5db;
  margin: 1rem 0 0.75rem;
}
#extra-multi-photos { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.75rem; }
.extra-multi-block { display: flex; flex-direction: column; }
.extra-multi-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.4rem;
}
.req-mark {
  color: #dc2626;
  margin-left: 0.15rem;
  font-weight: 600;
}

/* Read-only "pill" for fields auto-filled from another board (Customer, etc.). */
.readonly-pill {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f9fafb;
  color: #4b5563;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  font-size: 1rem;
  min-height: 2.85rem;
  display: flex;
  align-items: center;
}

/* ---------- Crew row (Submitter / Team / Teammate) — read-only ---------- */
.crew-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px dashed #e5e7eb;
}
@media (max-width: 480px) { .crew-row { grid-template-columns: 1fr; } }
.crew-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0 0.15rem;
}
.crew-cell:nth-child(2) { text-align: center; align-items: center; }
.crew-cell:nth-child(3) { text-align: right; align-items: flex-end; }
@media (max-width: 480px) {
  .crew-cell, .crew-cell:nth-child(2), .crew-cell:nth-child(3) {
    text-align: left;
    align-items: flex-start;
  }
}
.crew-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}
.crew-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #374151;
}

/* ---------- Signature pad ---------- */
.signature-wrap { position: relative; }
.signature-pad {
  display: block;
  width: 100%;
  height: 160px;
  background: #fafbfc;
  border: 2px dashed #cbd5e0;
  border-radius: var(--radius-md);
  touch-action: none;        /* keep finger draws from scrolling the page */
  cursor: crosshair;
}
.signature-pad.has-ink { border-style: solid; border-color: var(--success-accent); background: white; }
.signature-pad.missing { border-color: var(--error-accent); background: var(--error-bg); }
.signature-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #9ca3af;
  font-size: 0.85rem;
  pointer-events: none;
  font-style: italic;
}
.signature-pad.has-ink + .signature-hint { display: none; }
.signature-clear {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: white;
  border: 1px solid var(--border);
  color: #4a5568;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.signature-clear:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- Part combobox (search + select unified) ---------- */
.combo-wrap { position: relative; }
.combo-row { display: flex; gap: 0.4rem; align-items: stretch; }
.combo-row > input { flex: 1; min-width: 0; }
.filter-wrap { position: relative; flex-shrink: 0; }
.filter-btn {
  width: 2.5rem;
  height: 100%;
  min-height: 2.5rem;
  background: white;
  border: 1px solid var(--border);
  color: #4a5568;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all var(--t-base);
}
.filter-btn:hover { border-color: var(--brand); color: var(--brand); background: #f7fafc; }
.filter-btn.active { border-color: var(--brand); color: var(--brand); background: #eff6ff; }
.filter-dot {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--brand);
}
.filter-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.25rem;
  min-width: 12rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  z-index: 60;
  padding: 0.25rem 0;
}
.filter-item {
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  font-size: 0.88rem;
  color: #374151;
}
.filter-item:hover { background: #f7fafc; }
.filter-item.selected { background: #eff6ff; color: var(--brand); font-weight: 500; }
.combo-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.25rem;
  max-height: 280px;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  z-index: 50;
}
.combo-item {
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  border-bottom: 1px solid #f1f5f9;
}
.combo-item:last-child { border-bottom: none; }
.combo-item:hover { background: #f7fafc; }
.combo-item.selected { background: #eff6ff; font-weight: 500; }
.combo-cat {
  font-size: 0.72rem;
  color: #6b7280;
  background: #f3f4f6;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  flex-shrink: 0;
  white-space: nowrap;
}
.combo-empty {
  padding: 0.65rem 0.75rem;
  color: #9ca3af;
  font-size: 0.88rem;
  font-style: italic;
}
.photo-thumb.is-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}
.photo-thumb .video-badge {
  position: absolute;
  bottom: 0.15rem;
  left: 0.2rem;
  color: white;
  font-size: 0.7rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  pointer-events: none;
}

/* ---------- Industrial status pills (used for Returned / Ticketed / Synced) ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill.warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: var(--warn-border);
}
.pill.error {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error-border);
}
.pill.success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}
.pill.muted {
  background: var(--bg);
  color: var(--text-muted);
  border-color: var(--border-soft);
}

/* ---------- Card section header refinement (industrial) ---------- */
.card h2 {
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
}
