/* ============================================================
   Inspection App — Modern UI (Mobile-first, WCAG AA)
   ============================================================ */

:root {
  --blue-950: #0f2547;
  --blue-900: #1e3a5f;
  --blue-800: #1e40af;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-50:  #eff6ff;
  --blue-100: #dbeafe;
  --green-700: #15803d;
  --green-600: #16a34a;
  --green-500: #22c55e;
  --green-100: #dcfce7;
  --green-50:  #f0fdf4;
  --red-700:   #b91c1c;
  --red-600:   #dc2626;
  --red-100:   #fee2e2;
  --red-50:    #fef2f2;
  --amber-600: #d97706;
  --amber-500: #f59e0b;
  --amber-100: #fef3c7;
  --amber-50:  #fffbeb;
  --slate-950: #020617;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50:  #f8fafc;
  --white:     #ffffff;

  /* Semantic aliases */
  --gray-900:  var(--slate-900);
  --gray-700:  var(--slate-700);
  --gray-500:  var(--slate-500);
  --gray-300:  var(--slate-300);
  --gray-100:  var(--slate-100);
  --gray-50:   var(--slate-50);

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-xs: 0 1px 2px rgba(15,23,42,.06);
  --shadow:    0 1px 3px rgba(15,23,42,.08), 0 4px 12px rgba(15,23,42,.06);
  --shadow-md: 0 4px 16px rgba(15,23,42,.1),  0 1px 4px rgba(15,23,42,.06);
  --shadow-lg: 0 8px 32px rgba(15,23,42,.12), 0 2px 8px rgba(15,23,42,.06);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Shared chrome color — nav bar, sidebar, login bg */
  --chrome: #0f2547;
  --chrome-border: rgba(255,255,255,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--slate-100);
  color: var(--slate-900);
  min-height: 100dvh;
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── View routing ──────────────────────────────────────────── */
.view { display: none; min-height: 100dvh; }
.view.active { display: block; }

/* ── App Shell / Nav bar ────────────────────────────────────── */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15,37,71,.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--white);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  padding: 0 12px;
  height: 58px;
  border-bottom: 1px solid var(--chrome-border);
}
.app-nav .nav-start { display: flex; align-items: center; }
.app-nav .nav-title {
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -.01em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
}
.app-nav .nav-end { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.app-nav .btn-ghost {
  background: none;
  border: none;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  padding: 0;
  border-radius: var(--radius-sm);
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.app-nav .btn-ghost:hover { background: rgba(255,255,255,.12); color: var(--white); }
.app-nav .btn-ghost svg { display: block; }

/* ── Container ──────────────────────────────────────────────── */
.container { padding: 16px; max-width: 680px; margin: 0 auto; }
.container-wide { padding: 20px 24px; max-width: 1140px; margin: 0 auto; }

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: -.02em;
  margin-bottom: 4px;
}
.page-header-sub {
  color: var(--slate-500);
  font-size: .875rem;
}

/* ── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow .2s ease, transform .15s ease;
}
.card-hover:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.card-body   { padding: 18px 20px; }
.card-header { padding: 14px 20px; border-bottom: 1px solid var(--slate-100); font-weight: 600; font-size: .95rem; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  min-width: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  text-decoration: none;
  letter-spacing: -.01em;
  transition: filter .15s, box-shadow .15s, background .15s, transform .08s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--blue-600);
  color: var(--white);
  box-shadow: 0 1px 2px rgba(37,99,235,.3), 0 0 0 1px rgba(37,99,235,.2);
}
.btn-primary:hover   { background: var(--blue-700); }

.btn-success {
  background: var(--green-600);
  color: var(--white);
  box-shadow: 0 1px 2px rgba(22,163,74,.3);
}
.btn-success:hover { background: var(--green-700); }

.btn-danger {
  background: var(--red-600);
  color: var(--white);
  box-shadow: 0 1px 2px rgba(220,38,38,.25);
}
.btn-danger:hover { background: var(--red-700); }

.btn-outline {
  background: var(--white);
  border: 1.5px solid var(--slate-200);
  color: var(--slate-700);
  box-shadow: var(--shadow-xs);
}
.btn-outline:hover { background: var(--slate-50); border-color: var(--slate-300); }

.btn-sm    { min-height: 34px; padding: 0 12px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn-icon  { padding: 0; width: 42px; border-radius: 50%; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
label { display: block; font-size: .84rem; font-weight: 500; color: var(--slate-700); margin-bottom: 5px; }
input[type=text],
input[type=email],
input[type=password],
input[type=number],
input[type=date],
input[type=datetime-local],
select,
textarea {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-family: var(--font);
  background: var(--white);
  color: var(--slate-900);
  min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow-xs);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}
textarea { min-height: 90px; resize: vertical; }
.form-error { color: var(--red-600); font-size: .82rem; margin-top: 5px; }

/* ── Toggle (Pass/Fail) ─────────────────────────────────────── */
.toggle-group { display: flex; gap: 10px; }
.toggle-btn {
  flex: 1;
  min-height: 54px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--slate-200);
  background: var(--white);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow-xs);
}
.toggle-btn.pass { border-color: var(--green-600); color: var(--green-600); }
.toggle-btn.pass.active { background: var(--green-600); color: var(--white); box-shadow: 0 2px 8px rgba(22,163,74,.3); }
.toggle-btn.fail { border-color: var(--red-600); color: var(--red-600); }
.toggle-btn.fail.active { background: var(--red-600); color: var(--white); box-shadow: 0 2px 8px rgba(220,38,38,.3); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  text-transform: uppercase;
}
.badge-success  { background: var(--green-50);  color: var(--green-700); border: 1px solid var(--green-100); }
.badge-danger   { background: var(--red-50);    color: var(--red-700);   border: 1px solid var(--red-100); }
.badge-warning  { background: var(--amber-50);  color: var(--amber-600); border: 1px solid var(--amber-100); }
.badge-info     { background: var(--blue-50);   color: var(--blue-700);  border: 1px solid var(--blue-100); }
.badge-gray     { background: var(--slate-100); color: var(--slate-600); border: 1px solid var(--slate-200); }
.badge-pass     { background: var(--green-50);  color: var(--green-700); border: 1px solid var(--green-100); }
.badge-fail     { background: var(--red-50);    color: var(--red-700);   border: 1px solid var(--red-100); }

/* ── Job list items ─────────────────────────────────────────── */
.job-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--slate-100);
  cursor: pointer;
  transition: background .1s;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  -webkit-tap-highlight-color: transparent;
}
.job-item:hover { background: var(--slate-50); }
.job-item:active { background: var(--slate-100); }
.job-item:last-child { border-bottom: none; }
.job-meta { flex: 1; min-width: 0; }
.job-title { font-weight: 600; font-size: .95rem; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-sub   { font-size: .83rem; color: var(--slate-500); }
.job-icon  { flex-shrink: 0; margin-top: 2px; width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.job-icon-scheduled { background: var(--blue-50); color: var(--blue-600); }
.job-icon-progress  { background: var(--amber-50); color: var(--amber-600); }
.job-icon-done      { background: var(--green-50); color: var(--green-600); }
.job-icon-overdue   { background: var(--red-50); color: var(--red-600); }

/* ── Progress bar ───────────────────────────────────────────── */
.progress-wrap { background: var(--slate-100); border-radius: 999px; height: 6px; overflow: hidden; }
.progress-bar  { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue-500), var(--blue-600)); transition: width .4s ease; }
.progress-label { font-size: .78rem; color: var(--slate-500); text-align: right; margin-top: 3px; }

/* ── Section header in checklist ────────────────────────────── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 16px 7px 20px;
  background: var(--slate-700);
  color: var(--slate-200);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-left: 3px solid var(--blue-500);
}
.section-header-count {
  font-size: .7rem;
  font-weight: 700;
  color: var(--slate-400);
  background: var(--slate-800);
  padding: 1px 7px;
  border-radius: 10px;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}
.section-header-count--done {
  color: var(--green-400);
  background: rgba(34,197,94,.15);
}

.checklist-item {
  background: var(--white);
  border-bottom: 1px solid var(--slate-100);
  padding: 14px 20px;
  cursor: pointer;
  transition: background .1s;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.checklist-item:hover { background: var(--slate-50); }
.checklist-item:active { background: var(--slate-100); }
.check-status {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 50%; border: 2px solid var(--slate-200);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; margin-top: 1px; background: var(--white);
  font-weight: 700; color: var(--slate-500);
}
.check-status.done-pass { background: var(--green-600); border-color: var(--green-600); color: var(--white); }
.check-status.done-fail { background: var(--red-600);   border-color: var(--red-600);   color: var(--white); }
.check-status.done-text { background: var(--blue-600);  border-color: var(--blue-600);  color: var(--white); }
.check-status.done-ni   { background: var(--slate-400); border-color: var(--slate-400); color: var(--white); }
.check-info { flex: 1; min-width: 0; }
.check-title { font-weight: 500; font-size: .95rem; }
.check-desc  { font-size: .82rem; color: var(--slate-500); margin-top: 3px; }

/* ── Check item full-screen card ────────────────────────────── */
.check-card { background: var(--white); min-height: calc(100dvh - 58px); display: flex; flex-direction: column; }
.check-card-body { flex: 1; padding: 24px 20px; overflow-y: auto; }
.check-card-footer { padding: 14px 20px; border-top: 1px solid var(--slate-100); display: flex; gap: 10px; background: var(--white); }
.expected-box {
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: .88rem;
  color: var(--blue-800);
}

/* ── Photo grid ─────────────────────────────────────────────── */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.photo-thumb { width: 100%; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; position: relative; background: var(--slate-100); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .del-btn,
.photo-thumb .inline-del-photo-btn {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,.65); color: white; border: none;
  border-radius: 50%; width: 24px; height: 24px; cursor: pointer;
  font-size: .7rem; display: flex; align-items: center; justify-content: center;
}
.photo-add {
  width: 100%; aspect-ratio: 1; border-radius: var(--radius-sm);
  border: 2px dashed var(--slate-300);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 6px; cursor: pointer;
  color: var(--slate-400); font-size: .78rem; background: var(--slate-50);
  transition: border-color .15s, background .15s;
}
.photo-add:hover { border-color: var(--blue-400,#60a5fa); background: var(--blue-50); color: var(--blue-600); }

/* ── Photo action row (compact buttons outside grid) ──────── */
.photo-actions { display: flex; gap: 6px; margin-top: 8px; align-items: stretch; }
.photo-action-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 0 12px; border-radius: 6px;
  border: 1px solid var(--slate-200); background: var(--white);
  font-size: .75rem; font-weight: 500; color: var(--slate-600);
  cursor: pointer; transition: all .12s;
  font-family: var(--font);
  min-height: 32px; height: 32px;
  white-space: nowrap;
}
.photo-action-btn:hover { background: var(--slate-50); border-color: var(--slate-300); }
.photo-action-btn.gallery { color: var(--blue-600); border-color: var(--blue-200); }
.photo-action-btn.gallery:hover { background: var(--blue-50); }
.photo-action-btn.pool { color: var(--amber-600); border-color: var(--amber-200); }
.photo-action-btn.pool:hover { background: var(--amber-50); }



/* ── Photo Pool Modal ───────────────────────────────────────── */
.pool-modal {
  display: flex; flex-direction: column;
  max-height: 88dvh; overflow: hidden;
}
.pool-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.pool-modal-title { font-weight: 700; font-size: 1rem; }
.pool-modal-sub   { font-size: .82rem; color: var(--slate-500); margin: 0 0 12px; }

#pool-grid { overflow-y: auto; flex: 1; }

.pool-empty {
  text-align: center; padding: 28px 16px;
  color: var(--slate-400); font-size: .88rem;
}

.pool-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--slate-100);
}
.pool-item-thumb {
  width: 60px; height: 60px; border-radius: var(--radius-sm);
  overflow: hidden; flex-shrink: 0; background: var(--slate-100);
}
.pool-item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pool-item-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}
.pool-item-body  { flex: 1; min-width: 0; }
.pool-item-time  { font-size: .72rem; color: var(--slate-400); margin-bottom: 6px; }
.pool-item-status { font-size: .8rem; color: var(--slate-500); font-style: italic; }
.pool-item-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Assign Item Modal ──────────────────────────────────────── */
.assign-modal {
  display: flex; flex-direction: column;
  max-height: 85dvh; overflow: hidden;
}
.assign-item-list {
  overflow-y: auto; flex: 1; margin: 0 -20px;
}
.assign-section-header {
  font-size: .72rem; padding: 8px 16px; font-weight: 700;
}
.assign-item-btn {
  display: block; width: 100%; text-align: left;
  padding: 12px 16px; background: none; border: none;
  border-bottom: 1px solid var(--slate-100);
  cursor: pointer; min-height: 48px;
}
.assign-item-btn:hover, .assign-item-btn:active { background: var(--slate-50); }
.assign-item-title { font-size: .88rem; font-weight: 500; }
.assign-item-sub   { font-size: .75rem; color: var(--slate-400); margin-top: 2px; }

/* ── Sign pad ───────────────────────────────────────────────── */
.sign-pad-wrap { border: 1.5px solid var(--slate-200); border-radius: var(--radius-sm); overflow: hidden; background: var(--white); }
#sign-pad { display: block; width: 100%; cursor: crosshair; touch-action: none; }

/* ── Sync bar ────────────────────────────────────────────────── */
.sync-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  font-size: .82rem; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 200;
}
.sync-bar.hidden  { display: none; }
.sync-bar.online  { background: var(--green-600); color: white; }
.sync-bar.offline { background: var(--slate-700); color: white; }
.sync-bar.syncing { background: var(--blue-900);  color: white; }
.sync-bar.error   { background: var(--red-600);   color: white; }
#sync-icon { display: inline-block; }
.sync-bar.syncing #sync-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 70px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--slate-900); color: var(--white);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: .88rem; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 500;
  white-space: nowrap; max-width: 90vw;
  overflow: hidden; text-overflow: ellipsis;
  box-shadow: var(--shadow-md);
}
.toast.show    { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green-600); }
.toast.error   { background: var(--red-600); }
.toast.warning { background: var(--amber-600); }

/* ── Spacing utilities ───────────────────────────────────────── */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .78rem; }
.text-gray { color: var(--slate-500); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-right { text-align: right; }
.hidden { display: none !important; }

/* ── Dashboard grid ─────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 24px; }
@media(min-width: 600px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card {
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--slate-200);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.stat-num  { font-size: 2rem; font-weight: 700; line-height: 1; letter-spacing: -.03em; }
.stat-lbl  { font-size: .78rem; color: var(--slate-500); margin-top: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data-table th {
  background: var(--slate-50); padding: 11px 14px;
  text-align: left; font-size: .75rem; font-weight: 600;
  color: var(--slate-500); letter-spacing: .04em; text-transform: uppercase;
  border-bottom: 1.5px solid var(--slate-200);
}
table.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--slate-100); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: var(--slate-50); }

.tpl-sortable-row.dragging td { opacity: .55; }
.tpl-section-card { cursor: grab; }
.tpl-section-card.dragging { opacity: .65; }
.tpl-section-card .card-header { display: flex; justify-content: space-between; align-items: center; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 400;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@media(min-width: 600px) { .modal-backdrop { align-items: center; } }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: 1px solid var(--slate-200);
  width: 100%; max-width: 560px; max-height: 92dvh;
  overflow-y: auto; padding: 24px 20px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@media(min-width: 600px) { .modal { border-radius: var(--radius-lg); } }
.modal-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 20px; letter-spacing: -.01em; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 56px 16px; color: var(--slate-400); }
.empty-icon  { font-size: 2.8rem; margin-bottom: 14px; opacity: .6; }

/* ── Login page ─────────────────────────────────────────────── */
.login-wrap {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, var(--chrome) 0%, #0c2340 50%, #0f1f3d 100%);
  padding: 24px;
}
.login-logo {
  width: 56px; height: 56px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  backdrop-filter: blur(8px);
}
.login-card {
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200);
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  padding: 28px 24px;
}

/* ── Sidebar layout (mobile drawer + desktop column) ────────── */

/* Mobile top bar with hamburger — hidden on desktop */
.mobile-topbar {
  position: sticky; top: 0; z-index: 250;
  display: flex; align-items: center; gap: 12px;
  background: rgba(15,37,71,.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--white);
  padding: 0 12px; height: 58px;
  border-bottom: 1px solid var(--chrome-border);
}
.mobile-menu-btn {
  background: none; border: none; color: rgba(255,255,255,.85);
  cursor: pointer; padding: 8px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.mobile-menu-btn:active { background: rgba(255,255,255,.1); }
.mobile-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: .95rem; font-weight: 700; letter-spacing: -.01em;
}

/* Sidebar — base style is an off-canvas drawer (mobile) */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: min(280px, 85vw);
  background: var(--chrome);
  color: var(--white);
  display: flex; flex-direction: column;
  overflow-y: auto;
  z-index: 360;
  transform: translateX(-102%);
  transition: transform .22s ease;
}
.sidebar.open { transform: translateX(0); box-shadow: 0 0 48px rgba(2,6,23,.5); }

.sidebar-backdrop {
  position: fixed; inset: 0; z-index: 350;
  background: rgba(15,23,42,.55);
  opacity: 0; pointer-events: none;
  transition: opacity .22s ease;
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

.sidebar-brand {
  padding: 22px 20px;
  display: flex; align-items: center; gap: 10px;
  font-size: .95rem; font-weight: 700; letter-spacing: -.01em;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.sidebar-brand-icon {
  width: 32px; height: 32px;
  background: var(--blue-600);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-section {
  padding: 16px 12px 6px;
  font-size: .68rem; font-weight: 700; color: rgba(255,255,255,.3);
  letter-spacing: .08em; text-transform: uppercase;
}

.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; margin: 1px 8px;
  color: rgba(255,255,255,.6);
  cursor: pointer; font-size: .88rem; font-weight: 500;
  transition: background .15s ease, color .15s ease, border-left .15s ease;
  border: none; background: none;
  width: calc(100% - 16px);
  text-align: left;
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
}
.sidebar-link:hover  { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); }
.sidebar-link.active { background: rgba(59,130,246,.18); color: var(--white); border-left-color: var(--blue-500); font-weight: 600; }
.sidebar-link.active svg { color: var(--blue-500); }

.sidebar-footer {
  margin-top: auto; padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.main-content { min-width: 0; background: var(--slate-100); }

/* Desktop: static sidebar column, no topbar/backdrop */
@media(min-width: 768px) {
  .desktop-layout { display: flex; min-height: 100dvh; }

  .mobile-topbar, .sidebar-backdrop { display: none; }

  .sidebar {
    position: sticky; top: 0;
    width: 240px; height: 100dvh; flex-shrink: 0;
    transform: none; transition: none;
    border-right: 1px solid var(--chrome-border);
  }

  .main-content { flex: 1; }
}

/* ============================================================
   High-Density UI & Photo Pool Filmstrip Extensions
   ============================================================ */

/* ── Fresh Modern QC Item Card Design ── */
.qc-item-card {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-left: 4px solid var(--slate-300);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.qc-item-card:hover {
  border-color: var(--slate-300);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}
.qc-item-card.status-pass {
  border-left-color: #10b981;
  background: linear-gradient(to right, rgba(240, 253, 244, 0.5), #ffffff 25%);
}
.qc-item-card.status-fail {
  border-left-color: #ef4444;
  background: linear-gradient(to right, rgba(254, 242, 242, 0.5), #ffffff 25%);
}
.qc-item-card.status-ni {
  border-left-color: #94a3b8;
  opacity: 0.65;
}

.qc-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  flex-wrap: wrap;
}
.qc-card-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  min-width: 240px;
}
.qc-step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--slate-100);
  color: var(--slate-700);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  margin-top: 2px;
}
.qc-card-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.qc-card-title {
  font-size: 0.96rem;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.35;
}
.qc-card-desc {
  font-size: 0.84rem;
  color: #475569;
  line-height: 1.4;
}
.qc-pass-callout {
  font-size: 0.8rem;
  color: #15803d;
  background: linear-gradient(to right, #f0fdf4, #ecfdf5);
  border: 1px solid #bbf7d0;
  padding: 6px 10px;
  border-radius: 8px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-weight: 500;
  line-height: 1.35;
  margin-top: 2px;
}
.qc-req-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.qc-req-chip.photo { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.qc-req-chip.note  { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }

.qc-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border-top: 1px solid #f1f5f9;
  padding-top: 10px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.qc-card-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.qc-card-toggles {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

.qc-btn-pass {
  padding: 7px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
}
.qc-btn-pass:hover {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}
.qc-btn-pass.active {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.35);
}

.qc-btn-fail {
  padding: 7px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
}
.qc-btn-fail:hover {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #991b1b;
}
.qc-btn-fail.active {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.35);
}

.checklist-item--dense {
  background: var(--white);
  border-bottom: 1px solid var(--slate-100);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  transition: background-color 0.15s ease;
}
.checklist-item--dense:hover {
  background: var(--slate-50);
}

.dense-item-interactive-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  flex-wrap: wrap; /* Allows wrapping on small mobile screens */
}

.dense-row-left {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  min-width: 240px;
}

.dense-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  justify-content: flex-end;
  align-self: flex-start;
  flex-wrap: wrap;
}

.inline-input-wrap {
  flex: 1;
  min-width: 130px;
  max-width: 280px;
}

.inline-input-wrap input,
.inline-input-wrap select {
  height: 36px !important;
  min-height: 36px !important;
  padding: 6px 10px !important;
  font-size: 0.86rem !important;
  border-radius: 6px !important;
  margin-bottom: 0 !important;
  box-shadow: var(--shadow-xs) !important;
}

.item-inline-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-inline-action {
  background: var(--white);
  border: 1.5px solid var(--slate-200);
  border-radius: 6px;
  color: var(--slate-600);
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 36px;
  min-height: 36px;
  padding: 0 10px;
  cursor: pointer;
  transition: all 0.12s ease;
  position: relative;
  font-family: var(--font);
}
.btn-inline-action:hover {
  background: var(--slate-50);
  border-color: var(--slate-300);
  color: var(--slate-800);
}
.btn-inline-action.active {
  background: var(--blue-50);
  border-color: var(--blue-300);
  color: var(--blue-700);
}

.inline-badge {
  background: var(--blue-600);
  color: var(--white);
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 10px;
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

.inline-drawer {
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  animation: slideDownFade 0.2s ease-out;
  box-sizing: border-box;
}

@keyframes slideDownFade {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.inline-drawer-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--slate-500);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.inline-drawer textarea {
  min-height: 60px !important;
  padding: 8px 10px !important;
  font-size: 0.88rem !important;
  background: var(--white) !important;
  border-radius: 6px !important;
}

/* Quick Defect Note Chips */
.quick-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.quick-chip {
  background: var(--white);
  border: 1px solid var(--slate-300);
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--slate-700);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.quick-chip:hover {
  background: var(--blue-50);
  border-color: var(--blue-400);
  color: var(--blue-700);
}
.quick-chip:active {
  transform: scale(0.96);
}

/* Sticky Bottom Photo Pool (Collapsible) */
.sticky-photo-pool {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 1px solid var(--slate-200);
  box-shadow: 0 -4px 20px rgba(15,23,42,0.12);
  z-index: 200;
  padding: 8px 16px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  box-sizing: border-box;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sticky-photo-pool.collapsed .pool-filmstrip,
.sticky-photo-pool.collapsed .pool-instruction-banner {
  display: none !important;
}

body.has-photo-pool {
  padding-bottom: 70px !important;
}
body.has-photo-pool.pool-expanded {
  padding-bottom: 140px !important;
}

.pool-header-compact {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.pool-title-compact {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--slate-700);
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pool-filmstrip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 0;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.pool-filmstrip::-webkit-scrollbar {
  height: 4px;
}
.pool-filmstrip::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: 2px;
}

.pool-filmstrip-item {
  width: 58px;
  height: 58px;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  background: var(--slate-100);
  flex-shrink: 0;
  cursor: pointer;
  border: 2.5px solid transparent;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-xs);
}
.pool-filmstrip-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pool-filmstrip-item.selected {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.25);
  transform: translateY(-2px) scale(1.04);
}
.pool-filmstrip-item-status {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.pool-filmstrip-item-del {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(220,38,38,0.9);
  color: #fff;
  border: 2px solid #fff;
  font-size: 11px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.pool-filmstrip-item:hover .pool-filmstrip-item-del {
  opacity: 1;
}
.pool-filmstrip-item-del:hover {
  background: rgba(185,28,28,1);
  transform: scale(1.15);
}

.pool-filmstrip-add {
  width: 58px;
  height: 58px;
  border-radius: 6px;
  border: 2px dashed var(--slate-300);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--slate-400);
  background: var(--slate-50);
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.pool-filmstrip-add:hover {
  border-color: var(--blue-400);
  background: var(--blue-50);
  color: var(--blue-600);
}

.pool-instruction-banner {
  background: var(--blue-600);
  color: var(--white);
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 6px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-xs);
  animation: slideDownFade 0.2s ease-out;
}

.btn-cancel-selection {
  background: rgba(255,255,255,0.2);
  border: none;
  color: var(--white);
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font);
}
.btn-cancel-selection:hover {
  background: rgba(255,255,255,0.3);
}

/* Pin Action button */
.btn-pin-photo {
  background: var(--amber-500);
  border: 1px solid var(--amber-600);
  color: var(--white);
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 36px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.1s ease;
  font-family: var(--font);
  animation: pulseAmber 2s infinite;
}
.btn-pin-photo:hover {
  background: var(--amber-600);
}
@keyframes pulseAmber {
  0% { box-shadow: 0 0 0 0 rgba(245,158,11,0.5); }
  70% { box-shadow: 0 0 0 6px rgba(245,158,11,0); }
  100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); }
}

/* Batch Actions Row */
.batch-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ── Unified Modern QC Action Toolbar Buttons ── */
.btn-qc-action {
  height: 36px !important;
  min-height: 36px !important;
  padding: 0 16px !important;
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
  border: 1px solid #cbd5e1 !important;
  background: #ffffff !important;
  color: #334155 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  white-space: nowrap !important;
  transition: all 0.15s ease !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
  box-sizing: border-box !important;
  font-family: inherit !important;
  line-height: 1 !important;
}

.btn-qc-action:hover {
  background: #f8fafc !important;
  border-color: #94a3b8 !important;
  color: #0f172a !important;
}

/* Pass Button State */
.btn-qc-action.pass {
  color: #166534 !important;
  border-color: #bbf7d0 !important;
  background: #f0fdf4 !important;
}
.btn-qc-action.pass:hover {
  background: #dcfce7 !important;
  border-color: #86efac !important;
}
.btn-qc-action.pass.active {
  background: linear-gradient(135deg, #16a34a, #15803d) !important;
  color: #ffffff !important;
  border-color: transparent !important;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.35) !important;
}

/* Fail Button State */
.btn-qc-action.fail {
  color: #991b1b !important;
  border-color: #fecaca !important;
  background: #fef2f2 !important;
}
.btn-qc-action.fail:hover {
  background: #fee2e2 !important;
  border-color: #fca5a5 !important;
}
.btn-qc-action.fail.active {
  background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
  color: #ffffff !important;
  border-color: transparent !important;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.35) !important;
}

/* Tool Buttons (Note / Photo / Pin) */
.btn-qc-action.btn-tool {
  background: #ffffff !important;
  color: #334155 !important;
  border-color: #cbd5e1 !important;
}
.btn-qc-action.btn-tool:hover {
  background: #f8fafc !important;
  border-color: #94a3b8 !important;
  color: #0f172a !important;
}
.btn-qc-action.btn-tool.active {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  border-color: #93c5fd !important;
}

/* ── Mobile: compact QC action toolbar so all 4 buttons fit on one line ─── */
@media (max-width: 520px) {
  .qc-card-footer {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }
  .qc-card-tools,
  .qc-card-toggles {
    display: contents;
  }
  .inline-input-wrap {
    grid-column: 3 / -1;
    min-width: 0;
  }
  .btn-qc-action,
  .qc-btn-pass,
  .qc-btn-fail {
    height: 30px !important;
    min-height: 30px !important;
    padding: 0 6px !important;
    font-size: 0.75rem !important;
    gap: 3px !important;
    min-width: 0;
    white-space: nowrap;
  }
  .inline-num-input,
  .inline-text-input,
  .inline-mc-select {
    font-size: 0.82rem;
    min-width: 0;
    width: 100%;
  }
}

/* ── Bulk Edit ─────────────────────────────────────────────── */
.bulk-row {
  cursor: pointer;
  transition: background 0.1s;
}
.bulk-row:hover {
  background: var(--blue-50) !important;
}
.bulk-row.bulk-row-selected {
  background: #dbeafe !important;
}
.bulk-editable {
  cursor: text;
  border-radius: 3px;
  padding: 1px 3px;
}
.bulk-editable:hover {
  background: #f0f9ff;
  outline: 1px dashed var(--blue-300);
}

