/* ═══════════════════════════════════════════════════════════════════
   Vision OCR — Modern Dark Glass UI
   ═══════════════════════════════════════════════════════════════════ */

:root {
  color-scheme: dark;

  /* Palette */
  --bg-deep: #0a0f1a;
  --bg-surface: rgba(15, 23, 42, 0.65);
  --bg-elevated: rgba(30, 41, 59, 0.55);
  --bg-input: rgba(15, 23, 42, 0.72);
  --border: rgba(148, 163, 184, 0.12);
  --border-hover: rgba(148, 163, 184, 0.28);
  --border-accent: rgba(99, 102, 241, 0.5);

  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent: #818cf8;
  --accent-glow: rgba(129, 140, 248, 0.35);
  --green: #34d399;
  --green-glow: rgba(52, 211, 153, 0.3);
  --red: #fb7185;
  --red-glow: rgba(251, 113, 133, 0.25);
  --amber: #fbbf24;
  --amber-glow: rgba(251, 191, 36, 0.35);
  --cyan: #22d3ee;

  /* Glass */
  --glass-bg: rgba(15, 23, 42, 0.6);
  --glass-border: rgba(148, 163, 184, 0.1);
  --glass-blur: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px var(--accent-glow);

  /* Radius */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 9999px;

  /* Transition */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 0.2s;

  /* Font */
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
}

/* ─── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; background: none; }
img, video { display: block; max-width: 100%; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: 'JetBrains Mono', monospace; font-size: 0.88rem; }
a { color: var(--accent); text-decoration: none; }

/* ─── Body & Background ─────────────────────────────────────────── */
body {
  min-height: 100dvh;
  background: var(--bg-deep);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.bg-mesh::before,
.bg-mesh::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.4;
  animation: drift 25s ease-in-out infinite alternate;
}

.bg-mesh::before {
  width: 600px; height: 600px;
  top: -10%; left: -8%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.3), transparent 70%);
}

.bg-mesh::after {
  width: 500px; height: 500px;
  bottom: -10%; right: -10%;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.25), transparent 70%);
  animation-delay: -12s;
  animation-direction: alternate-reverse;
}

/* Grain overlay */
.bg-noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='a'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23a)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 180px;
}

@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(60px, 40px) scale(1.15); }
}

/* ─── Layout Shell ──────────────────────────────────────────────── */
.app-shell {
  position: relative;
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

/* ─── Compact Top Bar ───────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  margin-bottom: 8px;
}

/* ─── Navbar ────────────────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  margin-bottom: 32px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1rem;
  color: var(--bg-deep);
}

.navbar-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.navbar-title span {
  color: var(--text-secondary);
  font-weight: 400;
  margin-left: 6px;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber-glow);
}

.badge-dot.green {
  background: var(--green);
  box-shadow: 0 0 8px var(--green-glow);
}

/* ─── Hero ──────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  margin-bottom: 40px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.hero h1 {
  font-size: clamp(2rem, 4.5vw, 3.4rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 14px;
}

.hero p {
  max-width: 620px;
  margin: 0 auto;
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.65;
}

/* ─── Steps Indicator ───────────────────────────────────────────── */
.steps-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 28px;
}

.step-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--duration) var(--ease);
  position: relative;
}

.step-indicator.active {
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-accent);
}

.step-indicator.done {
  color: var(--green);
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: all var(--duration) var(--ease);
}

.step-indicator.active .step-number {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-deep);
}

.step-indicator.done .step-number {
  background: var(--green);
  border-color: var(--green);
  color: var(--bg-deep);
}

.step-connector {
  width: 48px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
  transition: background var(--duration) var(--ease);
}

.step-connector.filled {
  background: var(--green);
}

/* ─── Main Layout ───────────────────────────────────────────────── */
.main-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr 1fr;
}

/* ─── Glass Card ────────────────────────────────────────────────── */
.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.card:hover {
  border-color: var(--border-hover);
}

.card-body {
  padding: 24px;
}

.card-label {
  display: inline-block;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.card-desc {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.55;
  margin-bottom: 20px;
}

/* ─── Capture Hero / Preview ────────────────────────────────────── */
.capture-hero {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.9);
  margin-bottom: 16px;
}

.capture-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
}

.capture-icon {
  font-size: 3rem;
  opacity: 0.5;
  line-height: 1;
}

.capture-placeholder span {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.capture-preview {
  position: relative;
}

.capture-preview img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  display: block;
}

.capture-preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(10, 15, 26, 0.8);
  backdrop-filter: blur(4px);
}

.capture-preview-overlay span:not(.spinner) {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

/* ─── Capture Action Buttons ────────────────────────────────────── */
.capture-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.capture-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 12px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

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

.capture-btn-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.capture-btn-primary {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  border: none;
  color: #fff;
  box-shadow: 0 2px 16px var(--accent-glow);
}

.capture-btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 24px rgba(99, 102, 241, 0.45);
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.capture-btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
}

.capture-btn-secondary:hover:not(:disabled) {
  border-color: var(--border-hover);
  background: rgba(99, 102, 241, 0.1);
  transform: translateY(-1px);
}

.canvas-hidden { display: none; }

/* ─── Drop Zone ─────────────────────────────────────────────────── */
.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  transition: all var(--duration) var(--ease);
  cursor: pointer;
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.06);
}

.dropzone-icon {
  font-size: 2rem;
  margin-bottom: 10px;
  opacity: 0.6;
}

.dropzone-text {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.5;
}

.dropzone-text strong {
  color: var(--accent);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-hint {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.divider-or {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.divider-or::before,
.divider-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Preview Panel ─────────────────────────────────────────────── */
.preview-area {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.9);
  aspect-ratio: 4 / 3;
}

.preview-area img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.preview-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 14px;
  padding: 32px;
  text-align: center;
}

.preview-idle-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  opacity: 0.5;
}

.preview-idle strong {
  color: var(--text-secondary);
}

.preview-idle span {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* Info row under preview */
.info-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.info-chip {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.84rem;
}

.info-chip-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.info-chip-value {
  color: var(--text-secondary);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ─── Buttons ───────────────────────────────────────────────────── */
.action-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  border: none;
  color: #fff;
  box-shadow: 0 2px 16px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 24px rgba(99, 102, 241, 0.45);
  filter: brightness(1.1);
}

.btn-danger {
  color: var(--red);
  border-color: rgba(251, 113, 133, 0.2);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(251, 113, 133, 0.1);
  border-color: rgba(251, 113, 133, 0.4);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  font-style: normal;
  font-size: 1.05em;
}

.btn-full { flex: 1; }

/* ─── Loading Spinner ───────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
  border-color: rgba(129, 140, 248, 0.2);
  border-top-color: var(--accent);
}

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

/* Processing overlay */
.processing-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(10, 15, 26, 0.85);
  backdrop-filter: blur(6px);
  z-index: 10;
  border-radius: var(--radius-lg);
}

.processing-overlay span {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

/* ─── Alerts ────────────────────────────────────────────────────── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.55;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
}

.alert-icon {
  flex-shrink: 0;
  font-style: normal;
  font-size: 1.1rem;
  line-height: 1;
  margin-top: 1px;
}

.alert-info {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.15);
  color: var(--text-secondary);
}

.alert-error {
  background: rgba(251, 113, 133, 0.08);
  border: 1px solid rgba(251, 113, 133, 0.2);
  color: #fecdd3;
}

.alert-success {
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.2);
  color: #a7f3d0;
}

/* ─── Results ───────────────────────────────────────────────────── */
.results-section {
  margin-top: 24px;
}

.results-card {
  grid-column: 1 / -1;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.results-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
}

.result-stats {
  display: flex;
  gap: 8px;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.stat-chip-value {
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
}

/* Fields grid  */
.fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.field-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: border-color var(--duration) var(--ease);
}

.field-card:hover {
  border-color: var(--border-hover);
}

.field-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.field-label-icon {
  font-style: normal;
  font-size: 0.9rem;
}

.field-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.field-value.null-value {
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
}

/* Raw output accordion */
.raw-section {
  margin-top: 16px;
}

.raw-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  width: 100%;
  text-align: left;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.raw-toggle:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.raw-toggle-arrow {
  transition: transform var(--duration) var(--ease);
  font-style: normal;
}

.raw-toggle-arrow.open {
  transform: rotate(90deg);
}

.raw-content {
  margin-top: 10px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(2, 6, 23, 0.85);
  border: 1px solid var(--border);
  max-height: 300px;
  overflow: auto;
  color: var(--text-secondary);
  animation: fadeSlideIn 0.2s var(--ease);
}

/* Empty results */
.empty-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  text-align: center;
  gap: 12px;
}

.empty-results-icon {
  font-size: 2.5rem;
  opacity: 0.4;
}

.empty-results strong {
  color: var(--text-secondary);
}

.empty-results span {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 380px;
  line-height: 1.6;
}

/* ─── Toast ─────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  pointer-events: auto;
  animation: toastIn 0.3s var(--ease);
}

.toast.exiting {
  animation: toastOut 0.25s var(--ease) forwards;
}

.toast-icon {
  font-style: normal;
  font-size: 1.15rem;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(8px) scale(0.96); }
}

/* ─── Utilities / Animations ────────────────────────────────────── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeSlideIn 0.35s var(--ease);
}

/* ─── Responsive ────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .results-card {
    grid-column: 1;
  }

  .hero h1 {
    font-size: clamp(1.6rem, 6vw, 2.6rem);
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: 100%;
    padding: 4px 6px 0;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .topbar {
    margin-bottom: 4px;
    padding: 2px 4px;
    flex-shrink: 0;
  }

  .topbar .badge {
    padding: 4px 10px;
    font-size: 0.72rem;
  }

  .capture-panel,
  .results-panel {
    flex: 1;
    min-height: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
  }

  .capture-panel > .card,
  .results-panel > .card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-md);
  }

  .capture-panel .card-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 8px;
  }

  .capture-hero {
    flex: 1;
    min-height: 0;
    margin-bottom: 10px;
  }

  .capture-placeholder {
    height: 100%;
    padding: 24px 16px;
  }

  .capture-preview {
    height: 100%;
  }

  .capture-preview img {
    height: 100%;
    max-height: none;
    object-fit: contain;
  }

  .capture-actions {
    gap: 8px;
    margin-bottom: 8px;
    flex-shrink: 0;
  }

  .capture-btn {
    padding: 14px 10px;
    font-size: 0.88rem;
  }

  .dropzone {
    padding: 10px;
    flex-shrink: 0;
  }

  .dropzone-text {
    font-size: 0.82rem;
  }

  .dropzone-hint {
    margin-top: 2px;
    font-size: 0.7rem;
  }

  .card-body { padding: 8px; }

  .fields-grid {
    grid-template-columns: 1fr;
  }

  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  /* Results panel mobile fit */
  .results-panel .card-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px;
  }

  .results-header {
    margin-bottom: 10px;
  }
}

/* ─── Capture / Results panel (single-column layout) ──────────── */
.capture-panel,
.results-panel {
  max-width: 720px;
  margin: 0 auto 40px;
  width: 100%;
}

.processing-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  margin-top: 12px;
  border-radius: var(--radius-sm);
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.25);
  color: var(--amber);
  font-size: 0.9rem;
  font-weight: 500;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.65; }
}

/* ─── Inventory Lookup Section ───────────────────────────────── */
.inventory-section {
  margin-top: 24px;
  padding: 20px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
}

.inventory-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.inventory-header h4 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.inventory-icon {
  font-size: 1.2rem;
}

.inventory-count {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(129, 140, 248, 0.12);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(129, 140, 248, 0.2);
}

.inventory-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.inventory-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.inventory-table th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  background: rgba(30, 41, 59, 0.6);
  border-bottom: 1px solid var(--border);
}

.inventory-table td {
  padding: 12px 16px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.88rem;
}

.inventory-table tbody tr:last-child td {
  border-bottom: none;
}

.inventory-table tbody tr:hover {
  background: rgba(129, 140, 248, 0.06);
}

.inventory-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.inv-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.inv-thumb:hover {
  transform: scale(2.5);
  box-shadow: var(--shadow-lg);
  z-index: 10;
  position: relative;
}

.ebay-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.25);
  color: var(--cyan);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s var(--ease);
}

.ebay-link:hover {
  background: rgba(34, 211, 238, 0.2);
  border-color: rgba(34, 211, 238, 0.5);
}

/* ─── Login Screen ───────────────────────────────────────────── */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 32px 32px;
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-header h2 {
  margin: 12px 0 4px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.login-field input {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-field input::placeholder {
  color: var(--text-muted);
}

.login-btn {
  margin-top: 4px;
  padding: 13px 0;
  font-size: 0.95rem;
}

/* ─── Logout Button ──────────────────────────────────────────── */
.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: rgba(251, 113, 133, 0.08);
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.btn-logout:hover {
  background: rgba(251, 113, 133, 0.18);
  border-color: rgba(251, 113, 133, 0.4);
}
