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

/* ============ Design Tokens ============ */
:root {
  --primary: #004585;
  --primary-hover: #003a70;
  --primary-10: rgba(0, 69, 133, 0.1);
  --primary-20: rgba(0, 69, 133, 0.2);
  --primary-5: rgba(0, 69, 133, 0.05);
  --accent-red: #cc0000;

  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-50: rgba(248, 250, 252, 0.5);
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  --success: #16a34a;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --warning: #ca8a04;
  --warning-bg: #fef9c3;
  --warning-text: #854d0e;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --blue-100: #dbeafe;
  --blue-700: #1d4ed8;
  --green-100: #dcfce7;
  --green-700: #15803d;

  --radius: 0.25rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --shadow-primary: 0 10px 15px rgba(0, 69, 133, 0.2);

  --font: 'Public Sans', sans-serif;
}

/* ============ Body ============ */
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ============ Header ============ */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 5rem;
}

@media (min-width: 1024px) {
  .nav { padding: 0 2.5rem; }
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--primary);
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  padding: 0.5rem;
  border-radius: var(--radius);
}

.logo-icon .material-symbols-outlined {
  color: white;
  font-size: 1.5rem;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.logo-brand {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: -0.05em;
}

.logo-sub {
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.nav-links {
  display: none;
  align-items: center;
  gap: 2.5rem;
}

@media (min-width: 768px) {
  .nav-links { display: flex; }
}

.nav-links a {
  color: var(--slate-600);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid transparent;
  padding-bottom: 0.25rem;
  transition: color 0.15s, border-color 0.15s;
}

.nav-links a:hover {
  color: var(--primary);
}

.nav-links a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-actions .icon-btn {
  padding: 0.5rem;
  color: var(--slate-500);
  background: none;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.15s;
}

.nav-actions .icon-btn:hover {
  background: var(--slate-100);
}

.nav-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
  background: var(--primary-10);
  border: 2px solid var(--primary-20);
  overflow: hidden;
}

/* ============ Main ============ */
.main {
  flex-grow: 1;
  padding: 3rem 1.5rem 6rem;
}

.main-narrow {
  max-width: 56rem;
  margin: 0 auto;
}

.main-wide {
  max-width: 1200px;
  margin: 0 auto;
}

/* ============ Hero / Page Header ============ */
.page-header {
  margin-bottom: 3rem;
}

.page-header--center {
  text-align: center;
}

.page-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--primary-10);
  color: var(--primary);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.page-title {
  font-size: 2.25rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.033em;
  line-height: 1.1;
  margin-bottom: 0.75rem;
}

@media (min-width: 768px) {
  .page-title { font-size: 3rem; }
}

.page-subtitle {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 40rem;
  line-height: 1.6;
}

/* ============ Cards ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-body {
  padding: 2rem;
}

.card-footer {
  padding: 1rem 2rem;
  border-top: 1px solid var(--border);
  background: var(--slate-50);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.card-footer-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-footer-actions {
  display: flex;
  gap: 1rem;
}

.card-footer-link {
  background: none;
  border: none;
  color: var(--slate-600);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: color 0.15s;
}

.card-footer-link:hover { color: var(--accent-red); }

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 1rem;
  height: 2.5rem;
  border: none;
  border-radius: var(--radius-lg);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--slate-300);
}

.btn-ghost {
  background: var(--primary-10);
  color: var(--primary);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--primary);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger);
  color: white;
}

/* Manual entry for failed/unidentified items */
.manual-entry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.375rem;
  margin-top: 0.5rem;
  padding: 0.625rem;
  background: var(--slate-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.cell-input-sm {
  width: 100%;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-family: var(--font);
  outline: none;
  background: white;
  transition: border-color 0.15s;
}
.cell-input-sm:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-10);
}
.cell-input-sm::placeholder { color: var(--text-light); }

tr.needs-entry { background: #fffbeb; }
tr.needs-entry:hover { background: #fef3c7; }

.text-muted { color: var(--text-muted); font-style: italic; }

.btn-warning {
  background: #f59e0b;
  color: white;
  border: 1px solid #f59e0b;
}
.btn-warning:hover:not(:disabled) {
  background: #d97706;
  border-color: #d97706;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem 0;
  margin-top: 0.5rem;
}
.pagination-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.btn-sm {
  height: 2rem;
  padding: 0 0.75rem;
  font-size: 0.8125rem;
}

.btn-lg {
  height: 3rem;
  padding: 0 2rem;
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  box-shadow: var(--shadow-primary);
}

.btn-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ============ Dropzone ============ */
.dropzone-card {
  padding: 2rem;
}

.dropzone-outer {
  position: relative;
}

/* The gradient blur glow */
.dropzone-glow {
  position: absolute;
  inset: -4px;
  background: linear-gradient(to right, var(--primary-20), var(--primary-5));
  border-radius: var(--radius-xl);
  filter: blur(10px);
  opacity: 0.25;
  transition: opacity 1s;
  pointer-events: none;
}

.dropzone-outer:hover .dropzone-glow {
  opacity: 1;
  transition: opacity 0.2s;
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--slate-300);
  border-radius: var(--radius-xl);
  background: var(--surface-50);
  padding: 3rem 2rem;
  cursor: pointer;
  transition: all 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
  background: var(--surface);
  border-color: var(--primary);
}

.dropzone-icon-circle {
  width: 5rem;
  height: 5rem;
  border-radius: var(--radius-full);
  background: var(--primary-10);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  transition: transform 0.2s;
}

.dropzone:hover .dropzone-icon-circle,
.dropzone.dragover .dropzone-icon-circle {
  transform: scale(1.1);
}

.dropzone-icon-circle .material-symbols-outlined {
  font-size: 2.25rem;
  color: var(--primary);
}

.dropzone-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  text-align: center;
}

.dropzone-hint {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  text-align: center;
  max-width: 20rem;
}

/* ============ Batch Name Section ============ */
.batch-name-section {
  padding: 2rem;
}

.batch-name-section label {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--slate-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.input-with-icon {
  position: relative;
}

.input-with-icon .material-symbols-outlined {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem;
  color: var(--text-light);
  pointer-events: none;
}

.input-with-icon input {
  width: 100%;
  padding: 1rem 1rem 1rem 2.75rem;
  background: var(--slate-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-family: var(--font);
  font-size: 1rem;
  color: var(--text);
  transition: all 0.15s;
}

.input-with-icon input::placeholder {
  color: var(--text-light);
}

.input-with-icon input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-10);
}

/* Legacy batch-name-row support */
.batch-name-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.batch-name-row label {
  font-weight: 700;
  font-size: 0.8125rem;
  white-space: nowrap;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.batch-name-row input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-family: var(--font);
  background: var(--slate-50);
}

.batch-name-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-10);
}

/* ============ Section Header ============ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  margin-top: 4rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title-bar {
  width: 0.5rem;
  height: 2rem;
  background: var(--primary);
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.section-link {
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
}

.section-link:hover { text-decoration: underline; }

/* ============ File Queue ============ */
.file-queue {
  margin-top: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.file-queue-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.file-queue-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.file-queue-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.file-list-scroll {
  max-height: 400px;
  overflow-y: auto;
}

.file-count {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.file-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--slate-50); }

.file-thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--slate-100);
}

.file-info { flex: 1; min-width: 0; }

.file-name {
  font-size: 0.875rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-status {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius);
}

.file-status.pending { color: var(--text-muted); }
.file-status.processing { color: var(--blue-700); background: var(--blue-100); }
.file-status.complete { color: var(--green-700); background: var(--green-100); }
.file-status.failed { color: var(--danger-text); background: var(--danger-bg); }

.file-remove {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1.25rem;
  line-height: 1;
}
.file-remove:hover { color: var(--danger); }

/* ============ Photo Card Grid (Upload Grouping) ============ */
.photo-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
  padding: 1rem 1.5rem 1.5rem;
  max-height: 500px;
  overflow-y: auto;
}

.photo-card {
  position: relative;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: grab;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.photo-card:active { cursor: grabbing; }

.photo-card.dragging {
  opacity: 0.4;
  border-color: var(--primary);
}

.photo-card.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-20);
}

.photo-card-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.photo-card-info {
  padding: 0.375rem 0.5rem;
}

.photo-card-name {
  font-size: 0.6875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  margin-bottom: 0.125rem;
}

.photo-card-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.photo-card:hover .photo-card-remove,
.photo-group-card:hover > .photo-card-remove { opacity: 1; }

/* Photo Group Card */
.photo-group-card {
  position: relative;
  grid-column: span 2;
  background: var(--primary-5);
  border: 2px solid var(--primary-20);
  border-radius: var(--radius-lg);
  padding: 0.625rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.photo-group-card.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-20);
}

.photo-group-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.group-name-input {
  flex: 1;
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  background: transparent;
  padding: 0.125rem 0.25rem;
  border-radius: var(--radius);
  font-family: var(--font);
  color: var(--text);
}

.group-name-input:focus {
  background: var(--surface);
  outline: 1px solid var(--primary);
}

.photo-group-thumbs {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.photo-card-mini {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: grab;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

.photo-card-mini:active { cursor: grabbing; }
.photo-card-mini.dragging { opacity: 0.4; }

.photo-card-mini img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-card-mini .file-status {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  background: rgba(0,0,0,0.5);
  color: white;
  padding: 1px 2px;
}

.photo-card-mini .file-status.complete { background: rgba(22,163,74,0.8); }
.photo-card-mini .file-status.failed { background: rgba(220,38,38,0.8); }

.photo-card-ungroup {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 0.625rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.photo-card-mini:hover .photo-card-ungroup { opacity: 1; }

.grouping-hint {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

/* ============ Progress ============ */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 1rem 0;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

/* ============ Recent Grid ============ */
.recent-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1rem;
}

@media (min-width: 768px) {
  .recent-grid { grid-template-columns: repeat(2, 1fr); }
}

.recent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.15s;
}

.recent-card:hover {
  box-shadow: var(--shadow-md);
}

.recent-card-thumb {
  width: 4rem;
  height: 4rem;
  border-radius: var(--radius);
  background: var(--slate-100);
  flex-shrink: 0;
  overflow: hidden;
}

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

.recent-card-info { flex: 1; }

.recent-card-title {
  font-weight: 700;
  font-size: 0.9375rem;
}

.recent-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

.recent-card-arrow {
  color: var(--text-light);
}

/* Scrollable table card — enables sticky headers + horizontal scroll */
.card.table-card {
  overflow: auto;
  max-height: calc(100vh - 260px);
}

/* ============ Results Table ============ */
.results-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.results-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--slate-50);
  position: sticky;
  top: 0;
  z-index: 2;
}

.results-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.results-table tr:hover { background: var(--slate-50); }
.results-table tr:last-child td { border-bottom: none; }

.result-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  object-fit: cover;
}

.lot-title {
  font-weight: 700;
  color: var(--text);
}

/* ============ Badges ============ */
.confidence-badge {
  display: inline-flex;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.confidence-high { background: var(--green-100); color: var(--green-700); }
.confidence-medium { background: var(--warning-bg); color: var(--warning-text); }
.confidence-low { background: var(--danger-bg); color: var(--danger-text); }

.category-badge {
  display: inline-flex;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--primary-10);
  color: var(--primary);
}

.status-badge {
  display: inline-flex;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-pending { background: var(--slate-100); color: var(--text-muted); }
.status-processing { background: var(--blue-100); color: var(--blue-700); }
.status-complete { background: var(--green-100); color: var(--green-700); }
.status-failed { background: var(--danger-bg); color: var(--danger-text); }

/* ============ Stats Bar ============ */
.stats-bar {
  display: flex;
  gap: 2rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.stat { display: flex; flex-direction: column; }

.stat-value {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text);
}

.stat-label {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============ Feedback ============ */
.feedback-row {
  display: flex;
  gap: 0.375rem;
  align-items: center;
}

.feedback-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.15s;
}

.feedback-btn:hover { background: var(--slate-50); }
.feedback-btn.active-yes { background: var(--green-100); border-color: var(--success); }
.feedback-btn.active-no { background: var(--danger-bg); border-color: var(--danger); }

.correction-input {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.correction-input input {
  flex: 1;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: var(--font);
}

/* ============ History / Batch Cards ============ */
.batch-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  margin-bottom: 0.75rem;
  overflow: hidden;
  transition: box-shadow 0.15s;
}

.batch-card:hover { box-shadow: var(--shadow-md); }

.batch-header {
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.1s;
}

.batch-header:hover { background: var(--slate-50); }

.batch-title {
  font-weight: 700;
  font-size: 1rem;
}

.batch-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.batch-photos {
  display: flex;
  gap: 0.25rem;
  padding: 0 1.5rem 1rem;
  overflow-x: auto;
}

.batch-photos img {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  object-fit: cover;
}

.batch-delete-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem 0.75rem;
  margin-left: 0.5rem;
  transition: color 0.15s;
  flex-shrink: 0;
}

.batch-delete-btn:hover { color: var(--danger); }

/* ============ Projects ============ */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1.5rem;
}

@media (min-width: 768px)  { .projects-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .projects-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px) { .projects-grid { grid-template-columns: repeat(4, 1fr); } }

.project-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
  position: relative;
}

.project-card:hover { box-shadow: var(--shadow-md); }

.project-card-image {
  width: 100%;
  height: 10rem;
  background: var(--slate-100);
  position: relative;
}

.project-card-image .status-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
}

.project-card-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.project-card-title {
  font-weight: 700;
  font-size: 1rem;
  transition: color 0.15s;
}

.project-card:hover .project-card-title {
  color: var(--primary);
}

.project-card-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.project-card-meta-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.project-card-meta-row .material-symbols-outlined {
  font-size: 0.875rem;
}

.project-card-action {
  margin-top: auto;
  padding: 0 1rem 1rem;
}

.project-card-action button {
  width: 100%;
  padding: 0.5rem;
  border-radius: var(--radius-lg);
  background: var(--primary-10);
  color: var(--primary);
  border: none;
  font-family: var(--font);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.15s;
}

.project-card-action button:hover {
  background: var(--primary);
  color: white;
}

.project-delete {
  position: absolute;
  right: 0.75rem;
  top: 0.75rem;
  background: rgba(0,0,0,0.4);
  border: none;
  font-size: 1.1rem;
  color: white;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
}

.project-card:hover .project-delete { opacity: 1; }
.project-delete:hover { background: var(--danger); }

/* Legacy list-style project cards */
.project-card-counts {
  display: flex;
  gap: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* New project inline form */
.new-project-form,
.project-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.new-project-form input,
.project-form input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-family: var(--font);
  background: var(--slate-50);
}

.new-project-form input:focus,
.project-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-10);
}

/* Project indicator on batch page */
.project-indicator {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.project-indicator a { color: var(--primary); text-decoration: none; font-weight: 700; }
.project-indicator a:hover { text-decoration: underline; }

/* Project pick buttons in modal */
.project-pick-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.75rem 1rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text);
  margin-bottom: 0.5rem;
  transition: all 0.15s;
}

.project-pick-btn:hover {
  background: var(--primary-10);
  border-color: var(--primary);
  color: var(--primary);
}

/* ============ Spreadsheet View ============ */
.spreadsheet-filter-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.spreadsheet-filter-bar input,
.spreadsheet-filter-bar select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-family: var(--font);
  background: var(--slate-50);
}

.spreadsheet-filter-bar input:focus,
.spreadsheet-filter-bar select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-10);
}

.spreadsheet-filter-bar input { flex: 1; min-width: 200px; }

.row-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}

.spreadsheet-table {
  width: 100%;
  min-width: 1100px;
  border-collapse: collapse;
  font-size: 0.8125rem;
  table-layout: auto;
}

.spreadsheet-table th {
  text-align: left;
  padding: 0.5rem 0.625rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  user-select: none;
  background: var(--slate-50);
  position: sticky;
  top: 0;
  z-index: 2;
}

.spreadsheet-table th.sortable { cursor: pointer; }
.spreadsheet-table th.sortable:hover { color: var(--primary); }

.sort-arrow { font-size: 0.625rem; }

.spreadsheet-table td {
  padding: 0.5rem 0.625rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.spreadsheet-table tr:hover { background: var(--slate-50); }
.spreadsheet-table tr:last-child td { border-bottom: none; }
.spreadsheet-table tr.clickable-row { cursor: pointer; }
.spreadsheet-table tr.clickable-row:hover { background: var(--primary-5); }

.spreadsheet-table td[data-editable] { cursor: text; }
.spreadsheet-table td[data-editable]:hover { background: var(--primary-10); }

.spreadsheet-table td.editing { padding: 0.25rem; background: white; }

.cell-input {
  width: 100%;
  padding: 0.25rem 0.375rem;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-family: var(--font);
  outline: none;
}

@keyframes flash-green {
  0% { background: #bbf7d0; }
  100% { background: transparent; }
}

.spreadsheet-table td.saved { animation: flash-green 0.6s ease-out; }

.thumb-tiny {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  object-fit: cover;
}

.connected-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  margin-left: 4px;
  vertical-align: middle;
}

.spreadsheet-wrapper {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.empty-spreadsheet {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
}

/* ============ Page Header Row ============ */
.page-header-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 2rem;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* ============ Modals ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  margin: 1rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 1.5rem; }

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  text-align: right;
}

/* ============ Settings ============ */
.settings-section { margin-bottom: 1.5rem; }
.settings-section:last-child { margin-bottom: 0; }

.settings-section h3 { font-size: 0.875rem; font-weight: 700; margin-bottom: 0.5rem; }

.settings-section label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
  margin-top: 0.75rem;
}

.settings-section input,
.settings-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-family: var(--font);
  font-size: 0.875rem;
  background: var(--slate-50);
}

.settings-section input:focus,
.settings-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-10);
}

.settings-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }
.settings-hint a { color: var(--primary); font-weight: 700; }

/* ============ Export Dropdown ============ */
.export-dropdown { position: relative; }

.export-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: 100;
  overflow: hidden;
}

.export-menu.open { display: block; }

.export-option {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  background: none;
  text-align: left;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
}

.export-option:hover { background: var(--slate-50); }

.export-settings-btn { color: var(--text-muted); font-size: 0.75rem; }

.export-divider { height: 1px; background: var(--border); margin: 2px 0; }

/* ============ Empty State ============ */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  opacity: 0.25;
  margin-bottom: 1rem;
}

/* ============ Password Form ============ */
.password-form {
  max-width: 360px;
  margin: 4rem auto;
  text-align: center;
}

.password-form input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-family: var(--font);
  margin-bottom: 1rem;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--text);
  color: white;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden {
  opacity: 0;
  transform: translateY(1rem);
  pointer-events: none;
}

/* ============ Spinner ============ */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ============ Row Delete ============ */
.row-delete-cell { width: 32px; text-align: center; padding: 0 !important; }

.row-delete-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

tr:hover .row-delete-btn { opacity: 1; }
.row-delete-btn:hover { color: var(--danger); }

/* ============ Image Lightbox ============ */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90vw;
  max-height: 90vh;
}

.lightbox-content img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
  color: white;
  font-size: 0.9375rem;
  margin-top: 0.75rem;
  text-align: center;
  max-width: 600px;
  opacity: 0.85;
}

.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.5rem;
  opacity: 0.7;
  z-index: 301;
}
.lightbox-close:hover { opacity: 1; }

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: white;
  font-size: 2.5rem;
  cursor: pointer;
  padding: 1rem 0.75rem;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.15s, background 0.15s;
  border-radius: var(--radius);
  z-index: 301;
}

.lightbox-nav:hover { opacity: 1; background: rgba(255, 255, 255, 0.15); }
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

.thumb-tiny, .result-thumb, .batch-photos img {
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}

.thumb-tiny:hover, .result-thumb:hover, .batch-photos img:hover {
  opacity: 0.8;
  transform: scale(1.1);
}

/* ============ Footer ============ */
.footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 1.5rem 2.5rem;
  background: var(--surface);
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

@media (min-width: 768px) {
  .footer-inner { flex-direction: row; justify-content: space-between; }
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.footer-copyright {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.footer-links {
  display: flex;
  gap: 1rem;
}

.footer-links a {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  text-decoration: none;
  transition: color 0.15s;
}

.footer-links a:hover { color: var(--primary); }

.footer-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.footer-right span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.footer-right .status-label {
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  background: #22c55e;
  border-radius: 50%;
}

/* ============ Pagination ============ */
#pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem;
}

#page-info {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ============ History Table ============ */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.history-table th {
  text-align: left;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--slate-50);
}

.history-table td {
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.history-table tr:hover { background: var(--slate-50); }
.history-table tr:last-child td { border-bottom: none; }

/* ============ Icon Action Buttons ============ */
.icon-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.icon-action-btn:hover {
  background: var(--primary-10);
  color: var(--primary);
  border-color: var(--primary-20);
}

.icon-action-btn .material-symbols-outlined {
  font-size: 1rem;
}

/* ============ Equipment Grouping ============ */
.view-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
}

.view-toggle-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.view-toggle-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}

.view-toggle-btn.active {
  background: var(--primary);
  color: white;
}

.equipment-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 0.75rem;
  transition: box-shadow 0.15s;
}

.equipment-group:hover {
  box-shadow: var(--shadow-md);
}

.equipment-group-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.equipment-group-header .group-checkbox {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--primary);
}

.equipment-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: var(--primary-10);
  color: var(--primary);
  border-radius: var(--radius);
  white-space: nowrap;
}

.equipment-group-title {
  font-size: 0.95rem;
  font-weight: 600;
  flex: 1;
}

.equipment-group-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.equipment-photo-strip {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.equipment-photo-strip img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s;
}

.equipment-photo-strip img:hover {
  border-color: var(--primary);
}

.equipment-photo-strip img.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-20);
}

.equipment-actions-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.equipment-actions-bar .btn {
  font-size: 0.75rem;
}

.equipment-group-details {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.equipment-group-details span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.photo-select-checkbox {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 0.875rem;
  height: 0.875rem;
  accent-color: var(--primary);
  cursor: pointer;
  z-index: 1;
}

.photo-wrapper {
  position: relative;
  display: inline-block;
}

/* ============ Equipment Folder View ============ */
.equipment-folder {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 0.75rem;
  transition: box-shadow 0.15s;
}

.equipment-folder:hover {
  box-shadow: var(--shadow-md);
}

.equipment-folder-main {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.equipment-folder-cover {
  position: relative;
  flex-shrink: 0;
  width: 96px;
  height: 96px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--slate-100);
  display: flex;
  align-items: center;
  justify-content: center;
}

.equipment-folder-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-count-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius);
  line-height: 1.2;
}

/* Grouped table row styles */
.grouped-photo-cell {
  position: relative;
  display: inline-block;
}

.photo-count-inline {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 0.0625rem 0.25rem;
  border-radius: var(--radius);
  line-height: 1.2;
}

.grouped-row-photos {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.grouped-row-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  object-fit: cover;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}

.grouped-row-thumb:hover {
  opacity: 0.8;
  transform: scale(1.1);
}

.btn-link-sm {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  font-size: 0.7rem;
}

.btn-link-sm:hover {
  text-decoration: underline;
}

.editable-title {
  cursor: pointer;
  border-bottom: 1px dashed transparent;
  transition: border-color 0.15s;
}

.editable-title:hover {
  border-bottom-color: var(--primary);
}

.editable-title-input {
  font: inherit;
  font-weight: 600;
  width: 100%;
  padding: 0.125rem 0.25rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  outline: none;
  box-sizing: border-box;
}

.equipment-row td {
  vertical-align: top;
  padding-top: 0.75rem;
}

.equipment-folder-info {
  flex: 1;
  min-width: 0;
}

.equipment-folder-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.equipment-folder-top .group-checkbox {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--primary);
}

.equipment-folder-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  display: block;
  margin-bottom: 0.25rem;
}

a.equipment-folder-title:hover {
  color: var(--primary);
}

.equipment-folder-details {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.equipment-folder-details span {
  display: inline-flex;
  align-items: center;
}

.equipment-folder-actions {
  flex-shrink: 0;
  display: flex;
  gap: 0.375rem;
  align-items: flex-start;
}

.equipment-photo-strip.collapsed {
  display: none;
}

.equipment-folder .equipment-photo-strip {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.equipment-folder.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-20);
  background: var(--primary-5);
}

.equipment-folder .photo-wrapper[draggable="true"] {
  cursor: grab;
}

.equipment-folder .photo-wrapper[draggable="true"]:active {
  cursor: grabbing;
}

.equipment-folder .photo-wrapper.dragging {
  opacity: 0.3;
}

/* ============ Equipment Detail Page ============ */
.eq-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (min-width: 768px) {
  .eq-details-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
  .eq-details-grid { grid-template-columns: repeat(4, 1fr); }
}

.eq-detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.eq-detail-label {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.eq-detail-value {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.eq-photo-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  .eq-photo-gallery { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
  .eq-photo-gallery { grid-template-columns: repeat(4, 1fr); }
}

.eq-gallery-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.eq-gallery-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  cursor: pointer;
  transition: opacity 0.15s;
}

.eq-gallery-img:hover { opacity: 0.85; }

.eq-gallery-caption {
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text);
  border-top: 1px solid var(--border);
}

/* ============ Price Cells ============ */
.price-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}

.editable-price {
  cursor: pointer;
  border-bottom: 1px dashed transparent;
  transition: border-color 0.15s;
}

.editable-price:hover {
  border-bottom-color: var(--primary);
  background: var(--primary-5);
}

.price-input {
  font: inherit;
  width: 100%;
  max-width: 120px;
  padding: 0.125rem 0.25rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  outline: none;
  text-align: right;
  font-size: 0.8125rem;
  font-family: var(--font);
}

/* ============ AI Search Bar ============ */
.ai-search-bar {
  margin-bottom: 1rem;
}

.ai-search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 0.5rem 0.75rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ai-search-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-10);
}

.ai-search-icon {
  color: var(--primary);
  font-size: 1.25rem;
  flex-shrink: 0;
}

.ai-search-input-wrapper input {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 0.875rem;
  background: transparent;
  color: var(--text);
}

.ai-search-input-wrapper input::placeholder {
  color: var(--text-light);
}

.ai-search-summary {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  background: var(--primary-5);
  border: 1px solid var(--primary-20);
  border-radius: var(--radius-lg);
  font-size: 0.8125rem;
  color: var(--text);
  margin-top: 0.5rem;
}

#ai-search-results {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* ============ AI Chat Fab + Panel (Glassmorphism) ============ */

.chat-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 900;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, #0066cc 100%);
  box-shadow: 0 4px 20px rgba(0, 69, 133, 0.35), 0 0 0 0 rgba(0, 69, 133, 0);
  transition: transform 0.2s, box-shadow 0.2s;
}

.chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0, 69, 133, 0.45), 0 0 0 4px rgba(0, 69, 133, 0.1);
}

.chat-fab:active { transform: scale(0.96); }

.chat-fab.hidden { display: none; }

/* --- Panel --- */

.chat-panel {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 910;
  width: min(480px, calc(100vw - 2rem));
  height: min(600px, calc(100vh - 6rem));
  display: flex;
  flex-direction: column;
  border-radius: 1.25rem;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.25s ease, transform 0.25s ease;

  /* Glassmorphism */
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}

.chat-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* --- Header --- */

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}

.chat-panel-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
}

.chat-panel-actions {
  display: flex;
  gap: 0.25rem;
}

.chat-header-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.375rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
}

.chat-header-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}

/* --- Messages area --- */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text);
}

.chat-msg {
  max-width: 88%;
  padding: 0.625rem 0.875rem;
  border-radius: 1rem;
  font-size: 0.8125rem;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.chat-msg p { margin: 0 0 0.5rem; }
.chat-msg p:last-child { margin-bottom: 0; }

.chat-msg-user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}

.chat-msg-ai {
  align-self: flex-start;
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
  border-bottom-left-radius: 0.25rem;
}

.chat-msg-error {
  background: rgba(204, 0, 0, 0.08);
  color: var(--accent-red);
}

/* --- Streaming typing indicator --- */

.chat-typing {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: chatBounce 1.2s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* --- Markdown elements inside chat --- */

.chat-msg h2, .chat-msg h3, .chat-msg h4 {
  margin: 0.75rem 0 0.25rem;
  font-size: 0.875rem;
  font-weight: 700;
}

.chat-msg h2:first-child, .chat-msg h3:first-child, .chat-msg h4:first-child {
  margin-top: 0;
}

.chat-msg code {
  background: rgba(0, 0, 0, 0.06);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.chat-msg pre {
  background: rgba(0, 0, 0, 0.06);
  padding: 0.625rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 0.5rem 0;
}

.chat-msg pre code {
  background: none;
  padding: 0;
}

.chat-msg ul, .chat-msg ol {
  margin: 0.375rem 0;
  padding-left: 1.25rem;
}

.chat-msg li { margin-bottom: 0.125rem; }

.chat-msg hr {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  margin: 0.5rem 0;
}

.chat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  margin: 0.5rem 0;
}

.chat-table td {
  padding: 0.25rem 0.5rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  white-space: nowrap;
}

.chat-table tr:first-child td {
  font-weight: 600;
  background: rgba(0, 0, 0, 0.04);
}

.chat-msg strong { font-weight: 600; }

/* --- Input bar --- */

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}

.chat-input-bar input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0.5rem 0.875rem;
  font-family: var(--font);
  font-size: 0.8125rem;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-input-bar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-10);
}

.chat-input-bar input::placeholder { color: var(--text-light); }

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.chat-send-btn:hover { background: var(--primary-hover); }
.chat-send-btn:active { transform: scale(0.92); }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-send-btn .material-symbols-outlined { font-size: 1.125rem; }

/* ============ Responsive ============ */
@media (max-width: 768px) {
  .nav { padding: 0 1rem; height: 3.5rem; }
  .main { padding: 1.5rem 1rem 4rem; }
  .page-title { font-size: 1.75rem; }
  .stats-bar { flex-wrap: wrap; gap: 1rem; padding: 1rem; }
  .results-table th:nth-child(n+5),
  .results-table td:nth-child(n+5) { display: none; }
  .batch-name-row { flex-direction: column; align-items: stretch; }
  .spreadsheet-filter-bar { flex-direction: column; }
  .spreadsheet-filter-bar input { min-width: auto; width: 100%; }
  .page-header-row { flex-direction: column; gap: 0.75rem; }
  .lightbox-nav { font-size: 1.5rem; padding: 0.75rem 0.5rem; }
  .lightbox-close { font-size: 1.5rem; }
  .footer { padding: 1.5rem 1rem; }
  .footer-inner { text-align: center; }

  /* Chat panel full width on mobile */
  .chat-panel {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: calc(100vh - 3.5rem);
    border-radius: 1rem 1rem 0 0;
  }
  .chat-fab { bottom: 1rem; right: 1rem; }
}
