/* ==========================================================================
   SMART DOCUMENT & HARDWARE FLATBED SCANNER UTILITY - CSS
   ========================================================================== */

:root {
  --scanner-primary: #0284c7;
  --scanner-primary-dark: #0369a1;
  --scanner-primary-light: #e0f2fe;
  --scanner-emerald: #059669;
  --scanner-amber: #d97706;
  --scanner-purple: #7c3aed;
  --scanner-bg-surface: #ffffff;
  --scanner-bg-subtle: #f8fafc;
  --scanner-border: #e2e8f0;
  --scanner-text: #0f172a;
  --scanner-text-muted: #64748b;
  --scanner-radius: 12px;
  --scanner-shadow: 0 10px 30px -5px rgba(15, 23, 42, 0.08);
}

.scanner-body {
  background-color: #f1f5f9;
  font-family: 'Inter', var(--font-body, -apple-system, sans-serif);
  color: var(--scanner-text);
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@keyframes scannerPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.desktop-only-badge {
  display: inline-block;
}
@media (max-width: 640px) {
  .desktop-only-badge { display: none; }
}

/* Header Buttons */
.scanner-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #334155;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 5px 10px;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.scanner-back-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.scanner-tool-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 800;
  color: #d97706;
  background: #fef3c7;
  border: 1px solid #fde68a;
  padding: 5px 10px;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.scanner-tool-switch-btn:hover {
  background: #fde68a;
  transform: translateY(-1px);
}

/* Main Studio Workspace */
.scanner-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0.75rem 1rem 1rem 1rem;
  overflow-y: auto;
  background: #f1f5f9;
  box-sizing: border-box;
}

/* Stamp Chips */
.stamp-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.35rem 0.3rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-align: center;
}

.stamp-chip:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #0284c7;
  transform: translateY(-1px);
}

/* Pages Thumbnails Feed in Sidebar */
.pages-thumbnails-container {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 2px;
  min-height: 54px;
  scrollbar-width: thin;
}

.no-pages-msg {
  font-size: 0.7rem;
  color: #94a3b8;
  font-style: italic;
  padding: 10px 0;
  text-align: center;
  width: 100%;
}

.page-thumb-card {
  position: relative;
  width: 44px;
  height: 60px;
  border-radius: 4px;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  flex-shrink: 0;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transition: all 0.15s ease;
}

.page-thumb-card.active {
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.25);
}

.page-thumb-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.page-thumb-card .thumb-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 800;
  padding: 1px 3px;
  border-radius: 2px;
}

.page-thumb-card .thumb-del {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #ef4444;
  color: #fff;
  border: none;
  width: 14px;
  height: 14px;
  font-size: 0.6rem;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.setting-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  color: #334155;
  margin-bottom: 4px;
}

.scanner-select {
  width: 100%;
  padding: 7px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  color: #0f172a;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.scanner-select:focus {
  border-color: var(--scanner-primary);
  background: #ffffff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* Source Selection Pills */
.source-pills-row {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
}

.source-pill {
  flex: 1;
  padding: 6px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  border: none;
  background: transparent;
  color: #475569;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-align: center;
}

.source-pill.active {
  background: #ffffff;
  color: var(--scanner-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Enhancement Toggles Card */
.enhancement-toggles-card {
  background: #f8fafc;
  border: 1px solid var(--scanner-border);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.switch-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: 0.72rem;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
}

.switch-label input[type="checkbox"] {
  accent-color: var(--scanner-primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* Action Buttons Box (Preview & Final Scan) */
.scan-action-buttons-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.btn-prescan {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  color: #1e293b;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-prescan:hover {
  background: #f0f9ff;
  border-color: var(--scanner-primary);
  color: var(--scanner-primary);
}

.btn-main-scan {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 900;
  padding: 12px 16px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.38);
  letter-spacing: 0.5px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-main-scan:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(2, 132, 199, 0.48);
}

.btn-main-scan:active {
  transform: scale(0.98);
}

/* Camera Live Tray */
.camera-live-tray {
  margin-top: 12px;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  position: relative;
}

#cameraVideo {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.camera-tray-controls {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  z-index: 5;
}

.camera-tray-controls button {
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.camera-tray-controls .btn-cam-snap {
  background: var(--scanner-primary);
  border-color: #fff;
  font-weight: 800;
}

/* Demo Doc Loader */
.demo-doc-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid var(--scanner-border);
  padding: 8px 12px;
  border-radius: 10px;
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--scanner-text-muted);
}

.btn-demo {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0284c7;
  font-weight: 700;
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-demo:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

/* ==========================================================================
   CENTER PANEL (Flatbed Platen Frame, Rulers & Optical Beam)
   ========================================================================== */

.scanner-center-panel {
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.canvas-top-bar {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  width: 100%;
  box-sizing: border-box;
}

.scanner-telemetry-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  padding: 5px 12px;
  border-radius: 9999px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  color: #0f172a;
  width: 100%;
  box-sizing: border-box;
}

.telemetry-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

.telemetry-dot.scanning {
  background: #0284c7;
  box-shadow: 0 0 10px #0284c7;
  animation: scannerPulse 0.8s infinite;
}

.canvas-tools-group {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 6px;
  width: 100%;
  padding: 2px 2px 4px 2px;
  box-sizing: border-box;
}

.canvas-tools-group::-webkit-scrollbar {
  display: none;
}

.btn-canvas-action {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-sizing: border-box;
}

.btn-canvas-action:hover {
  background: #f1f5f9;
  color: var(--scanner-primary);
  border-color: var(--scanner-primary);
}

/* Flatbed Platen Frame with Measurement Rulers */
.flatbed-frame-container {
  position: relative;
  width: 100%;
  background: #0f172a;
  border-radius: 12px;
  padding: 20px 8px 8px 20px;
  box-shadow: inset 0 3px 12px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.12);
  border: 2px solid #334155;
  box-sizing: border-box;
}

.platen-ruler-top {
  position: absolute;
  top: 3px;
  left: 20px;
  right: 8px;
  height: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.platen-ruler-left {
  position: absolute;
  top: 20px;
  bottom: 8px;
  left: 3px;
  width: 15px;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.ruler-mark {
  position: absolute;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.52rem;
  color: #94a3b8;
  transform: translateX(-50%);
  user-select: none;
}

.platen-ruler-left .ruler-mark {
  transform: translateY(-50%);
  left: 2px;
}

.ruler-mark {
  position: absolute;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.58rem;
  color: #94a3b8;
  transform: translateX(-50%);
  user-select: none;
}

.platen-ruler-left .ruler-mark {
  transform: translateY(-50%);
  left: 2px;
}

/* Glass Viewport */
.flatbed-glass-viewport {
  position: relative;
  width: 100%;
  min-height: 460px;
  background: radial-gradient(circle, #243044 0%, #0f172a 100%);
  border-radius: 8px;
  padding: 36px 24px;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.7);
}

.platen-empty-state {
  text-align: center;
  padding: 40px 20px;
  max-width: 440px;
  color: #f8fafc;
}

.scanner-glass-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
}

.platen-empty-state h3 {
  font-size: 1.2rem;
  font-weight: 800;
  margin: 0 0 6px 0;
  color: #ffffff;
}

.platen-empty-state p {
  font-size: 0.8rem;
  color: #94a3b8;
  line-height: 1.5;
  margin: 0 0 20px 0;
}

.empty-btn-group {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.id-dual-dropzone-container {
  display: flex;
  gap: 14px;
  margin: 12px 0 16px 0;
  width: 100%;
}

.id-card-dropzone-card {
  flex: 1;
  background: rgba(30, 41, 59, 0.75);
  border: 2px dashed #9333ea;
  border-radius: 12px;
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.id-card-dropzone-card:hover {
  background: rgba(147, 51, 234, 0.2);
  border-color: #c084fc;
  transform: translateY(-3px);
  box-shadow: 0 12px 25px rgba(147, 51, 234, 0.3);
}

.id-card-dropzone-card.loaded {
  border-style: solid;
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.15);
}

.btn-load-platen {
  background: var(--scanner-primary);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 9px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.btn-load-platen:hover {
  transform: translateY(-1px);
}

.btn-load-camera {
  background: #059669;
}

.btn-load-camera:hover {
  background: #047857;
}

.btn-load-sample {
  background: #334155;
  border: 1px solid #475569;
}

.btn-load-sample:hover {
  background: #475569;
}

/* Canvas Stage & Pinning Overlay */
.canvas-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  max-height: 520px;
  margin: 20px auto;
  overflow: visible;
}

#docCanvas {
  display: block;
  max-width: 100%;
  max-height: 500px;
  border-radius: 6px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.1);
  background: #ffffff;
}

.crop-svg-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible !important;
  pointer-events: auto;
  cursor: crosshair;
}

/* OKEN Dark Outer Dimming Mask */
.crop-dim-mask {
  fill: rgba(15, 23, 42, 0.68);
  pointer-events: none;
  transition: d 0.05s ease-out;
}

.crop-polygon {
  fill: transparent;
  stroke: none;
}

/* OKEN Scanner Solid Glowing Green Boundary Lines */
.crop-line {
  stroke: #10b981;
  stroke-width: 3;
  filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.85));
}

/* Midpoint Edge Touch Grips */
.midpoint-group {
  cursor: move;
  transition: transform 0.15s ease;
}

.crop-midpoint-rect {
  fill: #10b981;
  stroke: #ffffff;
  stroke-width: 2.5;
  cursor: move;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.45));
  transition: fill 0.15s ease, stroke-width 0.15s ease;
}

.midpoint-group:hover .crop-midpoint-rect, .midpoint-group.dragging .crop-midpoint-rect {
  fill: #059669;
  stroke: #ffffff;
  stroke-width: 3;
}

.crop-midpoint-dot {
  fill: #ffffff;
  pointer-events: none;
}

/* OKEN Scanner 4-Corner Target Pins */
.pin-group {
  cursor: grab;
  transition: transform 0.15s ease;
}

.pin-group.dragging {
  cursor: grabbing;
}

.crop-pin-halo {
  fill: rgba(16, 185, 129, 0.22);
  stroke: rgba(16, 185, 129, 0.7);
  stroke-width: 1.5;
  pointer-events: none;
  animation: scannerPulse 2s infinite ease-in-out;
}

.crop-pin {
  fill: #10b981;
  stroke: #ffffff;
  stroke-width: 3.5;
  cursor: grab;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
  transition: r 0.15s ease, fill 0.15s ease;
}

.pin-group:hover .crop-pin, .pin-group.dragging .crop-pin {
  r: 17;
  fill: #059669;
  stroke: #ffffff;
  stroke-width: 4;
}

.crop-pin-core {
  fill: #ffffff;
  pointer-events: none;
}

.crop-pin-bracket {
  stroke: #ffffff;
  stroke-width: 2.5;
  fill: none;
  stroke-linecap: round;
  pointer-events: none;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6));
}

/* Floating OKEN Apply FAB Button */
.oken-floating-apply-btn {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 10px 20px;
  border-radius: 9999px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.5);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  z-index: 60;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.oken-floating-apply-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 30px rgba(16, 185, 129, 0.65);
}

.oken-floating-apply-btn:active {
  transform: scale(0.97);
}

/* Loupe Zoom Badge */
.loupe-zoom-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: #10b981;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 9999px;
  font-family: monospace;
}

.oken-btn-auto {
  background: #ecfdf5 !important;
  color: #059669 !important;
  border-color: #a7f3d0 !important;
  font-weight: 800 !important;
}

.oken-btn-id {
  background: #fffbeb !important;
  color: #b45309 !important;
  border-color: #fde68a !important;
  font-weight: 800 !important;
}

/* Optical Scanner Laser Beam Animation */
.scanner-optical-beam {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 6px;
  pointer-events: none;
  display: none;
  z-index: 50;
}

.beam-glow {
  position: absolute;
  inset: -15px 0;
  background: linear-gradient(180deg, rgba(56, 189, 248, 0) 0%, rgba(56, 189, 248, 0.35) 50%, rgba(56, 189, 248, 0) 100%);
}

.beam-laser-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 2px;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, #38bdf8 20%, #ffffff 50%, #38bdf8 80%, transparent 100%);
  box-shadow: 0 0 14px #38bdf8, 0 0 24px #0284c7;
}

/* Magnifier Loupe */
.magnifier-loupe {
  position: absolute;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 3.5px solid #ffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 2px #0284c7;
  overflow: hidden;
  pointer-events: none;
  display: none;
  z-index: 100;
  background: #ffffff;
}

#loupeCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.loupe-crosshair {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.loupe-crosshair::before, .loupe-crosshair::after {
  content: '';
  position: absolute;
  background: rgba(220, 38, 38, 0.85);
}

.loupe-crosshair::before {
  top: 50%;
  left: 20%;
  right: 20%;
  height: 1.5px;
  transform: translateY(-50%);
}

.loupe-crosshair::after {
  left: 50%;
  top: 20%;
  bottom: 20%;
  width: 1.5px;
  transform: translateX(-50%);
}

/* Filter Controls Shelf */
.filter-controls-shelf {
  background: #f8fafc;
  border: 1px solid var(--scanner-border);
  border-radius: 12px;
  padding: 12px;
  margin-top: 14px;
}

.sliders-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: center;
}

@media (max-width: 768px) {
  .sliders-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

.slider-group label {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 3px;
}

.slider-group input[type="range"] {
  width: 100%;
  accent-color: var(--scanner-primary);
  height: 4px;
}

.btn-reset-tune {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-reset-tune:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

/* Quick Stamp Bar */
.stamp-quick-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--scanner-border);
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
}

.stamp-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #475569;
  width: 100%;
  margin-bottom: 2px;
}

.stamp-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1 1 auto;
  text-align: center;
}

.stamp-chip:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn-clear-stamps {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
  flex: 1 1 100%;
  text-align: center;
  margin-top: 4px;
}

/* ==========================================================================
   RIGHT PANEL (ADF Document Feeder & PDF Export)
   ========================================================================== */

.scanner-right-panel {
  display: flex;
  flex-direction: column;
}

.pages-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.pages-count-badge {
  font-size: 0.74rem;
  font-weight: 800;
  color: #1e293b;
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: 6px;
}

.btn-scan-next {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: var(--scanner-primary);
  font-weight: 800;
  font-size: 0.72rem;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-scan-next:hover {
  background: #dbeafe;
}

.pages-thumbnails-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
  background: #f8fafc;
  border: 1px solid var(--scanner-border);
  border-radius: 12px;
  margin-bottom: 16px;
}

.no-pages-msg {
  grid-column: span 2;
  text-align: center;
  font-size: 0.72rem;
  color: #94a3b8;
  padding: 24px 8px;
}

.page-thumb-card {
  position: relative;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  padding: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.page-thumb-card:hover {
  border-color: var(--scanner-primary);
  transform: translateY(-2px);
}

.page-thumb-card.active {
  border-color: var(--scanner-primary);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

.page-thumb-img {
  width: 100%;
  max-height: 120px;
  object-fit: contain;
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.page-thumb-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #475569;
}

.btn-del-page {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
}

.btn-del-page:hover {
  background: #fee2e2;
}

/* Export Settings Card */
.export-settings-card {
  background: #f8fafc;
  border: 1px solid var(--scanner-border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
}

.export-settings-card h4 {
  font-size: 0.82rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 10px 0;
}

.setting-field {
  margin-bottom: 8px;
}

.setting-field label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 2px;
}

.select-field, .input-field {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

.file-size-estimator {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.7rem;
  color: #166534;
  margin-top: 8px;
}

/* Export Action Buttons */
.export-actions-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.btn-export-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.84rem;
  padding: 12px 16px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-export-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.45);
}

.secondary-exports-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.btn-export-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  color: #1e293b;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-export-secondary:hover {
  border-color: var(--scanner-primary);
  background: #f0f9ff;
  color: var(--scanner-primary);
}

/* Privacy Card */
.privacy-guarantee-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 10px 12px;
  border-radius: 10px;
  margin-top: auto;
}

.priv-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.priv-text {
  display: flex;
  flex-direction: column;
}

.priv-text strong {
  font-size: 0.72rem;
  color: #166534;
}

.priv-text span {
  font-size: 0.65rem;
  color: #15803d;
  line-height: 1.3;
}

/* Features Section */
.scanner-features-section {
  padding: 40px 0;
  background: #ffffff;
  border-top: 1px solid var(--scanner-border);
}

.section-title {
  text-align: center;
  font-size: 1.45rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 28px 0;
}

.features-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

@media (max-width: 992px) {
  .features-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 576px) {
  .features-cards-grid {
    grid-template-columns: 1fr;
  }
}

.feature-card {
  background: #f8fafc;
  border: 1px solid var(--scanner-border);
  padding: 20px;
  border-radius: 14px;
  transition: transform 0.2s ease;
}

.feature-card:hover {
  transform: translateY(-3px);
}

.feat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  margin-bottom: 12px;
}

.feature-card h3 {
  font-size: 0.95rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 6px 0;
}

.feature-card p {
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.5;
  margin: 0;
}

/* ==========================================================================
   DEDICATED MOBILE & TABLET RESPONSIVE OPTIMIZATIONS (Smartphones & Handhelds)
   ========================================================================== */
@media (max-width: 992px) {
  .scanner-studio-container {
    margin-top: 10px !important;
    padding: 0 6px;
  }

  .scanner-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  /* Center Panel (Scanner Glass Stage & Cropping) placed FIRST on mobile */
  .scanner-center-panel {
    order: 1;
    padding: 10px;
    border-radius: 12px;
  }

  /* Left Panel (Resolution, Color Mode & Buttons) placed SECOND */
  .scanner-left-panel {
    order: 2;
    padding: 14px;
    border-radius: 12px;
  }

  /* Right Panel (ADF Queue & PDF Export) placed THIRD */
  .scanner-right-panel {
    order: 3;
    padding: 14px;
    border-radius: 12px;
  }

  .flatbed-frame-container {
    padding: 16px 6px 6px 16px;
    border-radius: 10px;
  }

  /* Compact rulers on mobile */
  .platen-ruler-top {
    display: block !important;
    top: 2px;
    left: 16px;
    right: 6px;
    height: 12px;
  }

  .platen-ruler-left {
    display: block !important;
    top: 16px;
    bottom: 6px;
    left: 2px;
    width: 14px;
  }

  .ruler-mark {
    font-size: 0.5rem;
  }

  .flatbed-glass-viewport {
    padding: 10px 4px;
    min-height: 300px;
    border-radius: 8px;
  }

  .canvas-stage {
    margin: 4px auto;
    max-height: 440px;
    width: 100%;
    display: flex;
    justify-content: center;
  }

  #docCanvas {
    max-height: 420px;
    max-width: 100%;
    height: auto;
    border-radius: 6px;
  }

  .crop-svg-overlay {
    touch-action: none !important;
    -webkit-user-select: none;
    user-select: none;
  }

  /* Canvas Top Bar: Smooth horizontally scrollable toolbar */
  .canvas-top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 8px;
    width: 100%;
  }

  .scanner-telemetry-badge {
    justify-content: center;
    font-size: 0.72rem;
    padding: 4px 10px;
  }

  .canvas-tools-group {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px 2px 6px 2px;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
  }

  .canvas-tools-group::-webkit-scrollbar {
    display: none;
  }

  .btn-canvas-action {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    padding: 6px 12px !important;
    font-size: 0.72rem !important;
    min-height: 34px;
    border-radius: 7px;
  }

  /* Post Processing Sliders */
  .sliders-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .color-modes-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .color-mode-card {
    padding: 8px 6px;
  }

  .oken-floating-apply-btn {
    bottom: 10px;
    right: 10px;
    font-size: 0.76rem;
    padding: 8px 16px;
    gap: 6px;
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.6);
  }

  .magnifier-loupe {
    width: 120px;
    height: 120px;
  }

  .pages-thumbnails-container {
    grid-template-columns: repeat(2, 1fr);
    max-height: 200px;
  }
}

@media (max-width: 576px) {
  .scanner-header-hero {
    padding: 14px 8px 8px 8px;
  }

  .scanner-title-box h1 {
    font-size: 1.2rem;
  }

  .scanner-title-box p {
    font-size: 0.72rem;
  }

  .scanner-badge-row {
    flex-wrap: wrap;
    gap: 4px;
  }

  .hardware-badge {
    font-size: 0.62rem;
    padding: 2px 6px;
  }

  .flatbed-glass-viewport {
    padding: 8px 4px;
    min-height: 240px;
  }

  .platen-empty-state {
    padding: 16px 6px;
  }

  .scanner-glass-icon {
    font-size: 2rem;
    margin-bottom: 4px;
  }

  .platen-empty-state h3 {
    font-size: 0.95rem;
  }

  .platen-empty-state p {
    font-size: 0.7rem;
    margin-bottom: 12px;
  }

  .empty-btn-group {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 6px;
  }

  .btn-load-platen {
    width: 100%;
    padding: 9px 12px;
    font-size: 0.76rem;
  }

  .btn-main-scan {
    padding: 12px 10px;
    font-size: 0.82rem;
  }

  .btn-prescan {
    padding: 9px 8px;
    font-size: 0.74rem;
  }

  .secondary-exports-row {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 4px;
  }

  .btn-export-secondary {
    font-size: 0.62rem;
    padding: 6px 2px;
  }

  .privacy-guarantee-card {
    padding: 8px 10px;
  }
}

/* ==========================================================================
   SCANNED RESULT MODAL & PREVIEW VIEWER
   ========================================================================== */
.scan-result-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  animation: fadeInModal 0.2s ease-out;
}

@keyframes fadeInModal {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.scan-result-modal-box {
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  border: 1px solid #cbd5e1;
  max-width: 850px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.scan-result-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.btn-close-result-modal {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #64748b;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-close-result-modal:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

.scan-result-modal-body {
  padding: 16px;
  background: radial-gradient(circle, #1e293b 0%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  min-height: 280px;
  max-height: calc(90vh - 120px);
}

.scan-result-img-wrapper {
  box-shadow: 0 10px 30px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.2);
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
  display: inline-flex;
  max-width: 100%;
}

.scan-result-img-wrapper img {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  display: block;
}

.scan-result-modal-footer {
  padding: 10px 16px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

/* ==========================================================================
   A4 PAGE PLACER & LAYOUT STUDIO MODAL
   ========================================================================== */
.a4-placer-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 12px;
  animation: fadeInModal 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.a4-placer-modal-box {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
  width: 100%;
  max-width: 960px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.a4-placer-modal-header {
  padding: 12px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.a4-placer-modal-body {
  display: grid;
  grid-template-columns: 310px 1fr;
  flex: 1;
  min-height: 480px;
  max-height: calc(90vh - 120px);
  overflow: hidden;
}

.a4-placer-sidebar {
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.a4-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.a4-preset-btn {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.a4-preset-btn:hover {
  border-color: #6366f1;
  background: #f5f3ff;
  color: #4f46e5;
}

.a4-preset-btn.active {
  border-color: #4f46e5;
  background: #ede9fe;
  color: #4338ca;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.a4-preview-viewport {
  background: radial-gradient(circle, #1e293b 0%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
}

.a4-sheet-canvas-wrapper {
  background: #ffffff;
  box-shadow: 0 15px 40px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.2);
  border-radius: 4px;
  position: relative;
  transition: transform 0.2s ease;
}

.a4-sheet-canvas-wrapper canvas {
  display: block;
  max-width: 100%;
  max-height: 68vh;
  width: auto;
  height: auto;
  border-radius: 4px;
}

@media (max-width: 768px) {
  .a4-placer-modal-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .a4-placer-sidebar {
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
    max-height: 240px;
  }
}

/* Modal Live Filter Switcher Buttons (Like documentscanner.ai) */
.btn-filter-modal {
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 9999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-filter-modal:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.btn-filter-modal.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35);
}

/* ==========================================================================
   SMART DOCUMENT SCANNER — UNIVERSAL PC SCREEN AUTO-FIT ENGINE
   ========================================================================== */
html, body {
  width: 100% !important;
  max-width: 100vw !important;
  overflow-x: clip !important;
}

.scanner-studio-container {
  width: 100% !important;
  max-width: min(1480px, 95vw) !important;
  margin: 10px auto !important;
}

@media (min-width: 1200px) {
  .scanner-grid {
    display: grid !important;
    grid-template-columns: minmax(280px, 320px) 1fr minmax(290px, 340px) !important;
    gap: 16px !important;
    align-items: start !important;
  }
}

@media (min-width: 850px) and (max-width: 1199px) {
  .scanner-grid {
    display: grid !important;
    grid-template-columns: minmax(270px, 320px) 1fr !important;
    gap: 14px !important;
  }

  .scanner-grid > :last-child {
    grid-column: 1 / -1 !important;
  }
}

@media (max-width: 849px) {
  .scanner-body {
    height: auto !important;
    overflow-y: auto !important;
  }

  .scanner-workspace {
    height: auto !important;
    padding: 0.5rem 0.5rem 6rem 0.5rem !important;
  }

  .scanner-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
  }

  .scanner-canvas-wrapper,
  .scanner-stage {
    max-width: 100% !important;
    overflow-x: auto !important;
  }

  .scanner-canvas-wrapper canvas,
  #scannerMainCanvas {
    max-width: 100% !important;
    height: auto !important;
  }

  .scanner-controls-panel,
  .scanner-sidebar {
    width: 100% !important;
    max-width: 100% !important;
  }

  .scanner-actions-bar,
  .action-buttons-group {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .btn-scanner-action {
    width: 100% !important;
    justify-content: center !important;
    padding: 0.75rem 1rem !important;
  }
}


