/* ==========================================================================
   Barcode Studio v4 — Apple Liquid Glassmorphism & Fluid Motion Design System
   Optical Scanner Guardrail: Barcode scan pads remain 100% pure #FFFFFF
   ========================================================================== */

:root {
  --fedex-purple: #4d148c;
  --fedex-orange: #ff6600;
}

/* DARK THEME — Deep Obsidian Liquid Glass */
html.dark {
  color-scheme: dark;
  --bg-base: #040712;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --glass-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0.03) 55%, rgba(148, 163, 184, 0.05) 100%);
  --glass-border: rgba(255, 255, 255, 0.18);
  --glass-rim-top: rgba(255, 255, 255, 0.42);
  --glass-rim-side: rgba(255, 255, 255, 0.16);
  --glass-rim-bottom: rgba(129, 140, 248, 0.22);
  --glass-shadow:
    0 24px 56px -14px rgba(0, 0, 0, 0.72),
    0 8px 20px -6px rgba(0, 0, 0, 0.48);
  --specular-glow: rgba(255, 255, 255, 0.13);
  --meniscus: linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0) 100%);
  --inset-bg: rgba(5, 9, 20, 0.56);
  --inset-border: rgba(255, 255, 255, 0.14);
  --inset-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.52), 0 1px 0 rgba(255, 255, 255, 0.08);
  --card-bg: linear-gradient(145deg, rgba(255, 255, 255, 0.11) 0%, rgba(255, 255, 255, 0.03) 100%);
  --card-border: rgba(255, 255, 255, 0.17);
  --btn-glass-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.05) 100%);
  --btn-glass-hover: linear-gradient(180deg, rgba(255, 255, 255, 0.24) 0%, rgba(255, 255, 255, 0.10) 100%);
  --btn-glass-border: rgba(255, 255, 255, 0.22);
  --btn-glass-shadow:
    0 8px 20px -6px rgba(0, 0, 0, 0.52),
    inset 0 1px 0 rgba(255, 255, 255, 0.34),
    inset 0 -1px 0 rgba(0, 0, 0, 0.28);
  --divider: rgba(255, 255, 255, 0.12);
  --chip-bg: rgba(255, 255, 255, 0.08);
  --chip-hover: rgba(255, 255, 255, 0.15);
  --popover-bg: rgba(11, 17, 34, 0.90);
  --select-bg: #0f172a;
  --select-fg: #f8fafc;
  --fedex-fed-color: #ffffff;
  --header-veil: linear-gradient(180deg, rgba(4, 7, 18, 0.72) 0%, rgba(4, 7, 18, 0) 100%);
  --modal-backdrop: rgba(3, 6, 15, 0.84);
}

/* LIGHT THEME — Apple Translucent Crystal Liquid Glass */
html.light {
  color-scheme: light;
  --bg-base: #e6eefb;
  --text-primary: #0f172a;
  --text-secondary: #1e293b;
  --text-muted: #475569;
  --glass-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.56) 0%, rgba(255, 255, 255, 0.30) 55%, rgba(255, 255, 255, 0.44) 100%);
  --glass-border: rgba(255, 255, 255, 0.78);
  --glass-rim-top: rgba(255, 255, 255, 0.98);
  --glass-rim-side: rgba(255, 255, 255, 0.72);
  --glass-rim-bottom: rgba(99, 102, 241, 0.18);
  --glass-shadow:
    0 22px 48px -16px rgba(30, 41, 59, 0.18),
    0 8px 18px -8px rgba(30, 41, 59, 0.10);
  --specular-glow: rgba(255, 255, 255, 0.55);
  --meniscus: linear-gradient(180deg, rgba(255, 255, 255, 0.75) 0%, rgba(255, 255, 255, 0) 100%);
  --inset-bg: rgba(255, 255, 255, 0.54);
  --inset-border: rgba(255, 255, 255, 0.72);
  --inset-shadow: inset 0 2px 6px rgba(15, 23, 42, 0.08), 0 1px 0 rgba(255, 255, 255, 0.92);
  --card-bg: linear-gradient(145deg, rgba(255, 255, 255, 0.62) 0%, rgba(255, 255, 255, 0.34) 100%);
  --card-border: rgba(255, 255, 255, 0.80);
  --btn-glass-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.78) 0%, rgba(255, 255, 255, 0.45) 100%);
  --btn-glass-hover: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.68) 100%);
  --btn-glass-border: rgba(255, 255, 255, 0.85);
  --btn-glass-shadow:
    0 8px 18px -8px rgba(15, 23, 42, 0.18),
    inset 0 1.5px 0 rgba(255, 255, 255, 1),
    inset 0 -1px 0 rgba(15, 23, 42, 0.08);
  --divider: rgba(15, 23, 42, 0.09);
  --chip-bg: rgba(255, 255, 255, 0.46);
  --chip-hover: rgba(255, 255, 255, 0.72);
  --popover-bg: rgba(255, 255, 255, 0.86);
  --select-bg: #ffffff;
  --select-fg: #0f172a;
  --fedex-fed-color: #4d148c;
  --header-veil: linear-gradient(180deg, rgba(230, 238, 251, 0.78) 0%, rgba(230, 238, 251, 0) 100%);
  --modal-backdrop: rgba(15, 23, 42, 0.55);
}

html {
  scroll-behavior: smooth;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Plus Jakarta Sans', 'Segoe UI', Roboto, sans-serif;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.font-mono-code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ==========================================================================
   LIVE FLUID CANVAS BACKDROP
   ========================================================================== */
#liquid-bg-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: -3;
  pointer-events: none;
  filter: blur(22px) saturate(135%);
  transform: scale(1.06);
}

.liquid-ambient-frost {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.09) 0%, transparent 65%);
}

/* Sticky Header Top Scrim — Eliminates scrolled content peeking above header */
.header-sticky-wrap {
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-sticky-wrap::before {
  content: '';
  position: absolute;
  inset: 0 0 -10px 0;
  background: var(--header-veil);
  pointer-events: none;
  z-index: -1;
}

/* ==========================================================================
   APPLE LIQUID GLASS MATERIAL (Specular Fresnel Rim + Cursor Caustic Glow)
   ========================================================================== */
.liquid-glass {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: blur(30px) saturate(215%) contrast(1.03);
  -webkit-backdrop-filter: blur(30px) saturate(215%) contrast(1.03);
  border: 1px solid var(--glass-border);
  box-shadow:
    var(--glass-shadow),
    inset 0 1.5px 0 var(--glass-rim-top),
    inset 1px 0 0 var(--glass-rim-side),
    inset -1px -1.5px 2px var(--glass-rim-bottom);
}

.liquid-glass::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--meniscus);
  height: 44%;
  pointer-events: none;
  opacity: 0.45;
}

.liquid-glass::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), var(--specular-glow), transparent 62%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.28s ease;
}

.liquid-glass:hover::after {
  opacity: 1;
}

.liquid-glass > * {
  position: relative;
  z-index: 1;
}

.glass-popover {
  background: var(--popover-bg);
  backdrop-filter: blur(28px) saturate(210%);
  -webkit-backdrop-filter: blur(28px) saturate(210%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-rim-top);
}

.glass-inset {
  background: var(--inset-bg);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid var(--inset-border);
  box-shadow: var(--inset-shadow);
  color: var(--text-primary);
}

.glass-inset:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.85);
  box-shadow: var(--inset-shadow), 0 0 0 3px rgba(99, 102, 241, 0.24);
}

select.glass-inset option {
  background-color: var(--select-bg);
  color: var(--select-fg);
}

.divider-line { border-color: var(--divider); }
.text-t-primary { color: var(--text-primary); }
.text-t-secondary { color: var(--text-secondary); }
.text-t-muted { color: var(--text-muted); }

.chip-neutral {
  background: var(--chip-bg);
  color: var(--text-secondary);
  backdrop-filter: blur(12px);
}
.chip-neutral:hover { background: var(--chip-hover); }

/* Liquid Glass KPI Tiles */
.kpi-liquid {
  position: relative;
  overflow: hidden;
  background: var(--card-bg);
  backdrop-filter: blur(26px) saturate(210%);
  -webkit-backdrop-filter: blur(26px) saturate(210%);
  border: 1px solid var(--card-border);
  box-shadow:
    var(--glass-shadow),
    inset 0 1.5px 0 var(--glass-rim-top),
    inset -1px -1px 2px var(--glass-rim-bottom);
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease;
}

.kpi-liquid::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(200px circle at var(--mx, 50%) var(--my, 0%), var(--specular-glow), transparent 70%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.kpi-liquid:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.55);
}

.kpi-liquid:hover::after { opacity: 1; }

/* Liquid Glass Barcode Cards */
.bc-card-liquid {
  position: relative;
  overflow: hidden;
  background: var(--card-bg);
  backdrop-filter: blur(26px) saturate(210%);
  -webkit-backdrop-filter: blur(26px) saturate(210%);
  border: 1px solid var(--card-border);
  box-shadow:
    var(--glass-shadow),
    inset 0 1.5px 0 var(--glass-rim-top),
    inset -1px -1px 2px var(--glass-rim-bottom);
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.22s ease;
  min-width: 0;
}

.bc-card-liquid::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(280px circle at var(--mx, 50%) var(--my, 0%), var(--specular-glow), transparent 65%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.bc-card-liquid:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 102, 0, 0.62);
}

.bc-card-liquid:hover::after { opacity: 1; }

/* Interactive Barcode Logo (Header) */
.brand-barcode-btn {
  position: relative;
  overflow: hidden;
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.22s ease;
}

.brand-barcode-btn:hover {
  transform: translateY(-2px) scale(1.06);
  box-shadow: 0 12px 26px -6px rgba(99, 102, 241, 0.72), 0 0 18px rgba(255, 102, 0, 0.45);
}

.brand-barcode-btn .laser-line {
  position: absolute;
  left: 4px;
  right: 4px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #ff6600, #fde047, #ff6600, transparent);
  box-shadow: 0 0 8px #ff6600;
  top: 50%;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.brand-barcode-btn:hover .laser-line {
  opacity: 1;
  animation: laserSweep 1.15s ease-in-out infinite;
}

@keyframes laserSweep {
  0%, 100% { top: 20%; }
  50%      { top: 80%; }
}

/* ==========================================================================
   OFFICIAL FEDEX BRAND WORDMARK (Zero Gap — Tightly Kerned Flush Lockup)
   ========================================================================== */
.fedex-wordmark {
  display: inline-flex;
  align-items: baseline;
  font-family: 'Futura', 'Montserrat', 'Plus Jakarta Sans', 'Arial Black', sans-serif;
  font-weight: 900;
  font-size: 21px;
  line-height: 1;
  letter-spacing: -0.06em;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

.fedex-wordmark .fedex-fed {
  color: var(--fedex-fed-color);
  transition: color 0.25s ease;
}

.fedex-wordmark .fedex-ex {
  color: #ff6600;
  margin-left: -0.045em; /* Exact flush kerning between 'd' and 'E' — zero gap */
}

/* ==========================================================================
   ANTI-OVERFLOW OPTICAL SCAN SURFACES (Pure White #FFFFFF)
   ========================================================================== */
.optical-scan-pad {
  background: #ffffff !important;
  border-radius: 12px;
  padding: 10px 8px;
  width: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 6px 16px -6px rgba(15, 23, 42, 0.20);
}

.optical-scan-pad svg {
  display: block;
  width: auto !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: 145px;
  shape-rendering: crispEdges;
}

.modal-scan-pad {
  background: #ffffff !important;
  border-radius: 18px;
  padding: 22px 18px;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(15, 23, 42, 0.10);
  box-shadow: 0 20px 42px -12px rgba(0, 0, 0, 0.35);
}

.modal-scan-svg {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.modal-scan-svg svg {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: 250px;
  shape-rendering: crispEdges;
}

.scan-modal-backdrop {
  background: var(--modal-backdrop);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
}

/* ==========================================================================
   LIQUID GLASS 3D BUTTONS & FILTER PILLS
   ========================================================================== */
.btn-3d {
  position: relative;
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.16s ease, filter 0.16s ease, opacity 0.2s ease;
  user-select: none;
}

.btn-3d:active:not(:disabled) { transform: translateY(1.5px) scale(0.985); }

.btn-3d-primary {
  background: linear-gradient(135deg, #6366f1 0%, #4d148c 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow:
    0 10px 22px -6px rgba(79, 70, 229, 0.55),
    0 2.5px 0 #2e1065,
    inset 0 1.5px 0 rgba(255, 255, 255, 0.42);
}

.btn-3d-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-3d-orange {
  background: linear-gradient(135deg, #ff7a18 0%, #ea580c 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.30);
  box-shadow:
    0 10px 22px -6px rgba(255, 102, 0, 0.52),
    0 2.5px 0 #9a3412,
    inset 0 1.5px 0 rgba(255, 255, 255, 0.46);
}

.btn-3d-orange:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-3d-emerald {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow:
    0 10px 22px -6px rgba(16, 185, 129, 0.50),
    0 2.5px 0 #065f46,
    inset 0 1.5px 0 rgba(255, 255, 255, 0.42);
}

.btn-3d-emerald:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-3d-glass {
  background: var(--btn-glass-bg);
  color: var(--text-primary);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid var(--btn-glass-border);
  box-shadow: var(--btn-glass-shadow);
}

.btn-3d-glass:hover:not(:disabled) {
  background: var(--btn-glass-hover);
  transform: translateY(-1px);
}

.seg-shell {
  background: var(--inset-bg);
  border: 1px solid var(--inset-border);
  box-shadow: var(--inset-shadow);
}

.filter-pill {
  transition: transform 0.16s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}
.filter-pill:hover { transform: translateY(-1px); }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.40);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.62); }

/* ==========================================================================
   ADAPTIVE PRINT ENGINE — A4 (9 or 8/pg), A5 (4/pg), Thermal 4x6 (3/pg), Thermal 4x2 (1/pg)
   ========================================================================== */
.print-only-sheets {
  display: none;
}

@media print {
  body, html {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #liquid-bg-canvas,
  .liquid-ambient-frost,
  .no-print {
    display: none !important;
  }

  .print-only-sheets {
    display: block !important;
    width: 100% !important;
  }

  .print-sheet {
    width: 100%;
    page-break-after: always;
    break-after: page;
    display: flex;
    flex-direction: column;
    gap: 2.2mm;
  }

  .print-sheet:last-child {
    page-break-after: auto;
    break-after: auto;
  }

  .print-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 8.5pt;
    font-weight: 700;
    color: #334155;
    border-bottom: 0.4mm solid #cbd5e1;
    padding-bottom: 1.5mm;
    margin-bottom: 0.5mm;
  }

  .print-item-box {
    border: 0.35mm solid #cbd5e1;
    border-radius: 2mm;
    padding: 1.8mm 3mm;
    background: #ffffff !important;
    page-break-inside: avoid;
    break-inside: avoid;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .print-item-meta {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 8pt;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 1mm;
    font-family: 'JetBrains Mono', monospace;
  }

  .print-item-svg {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
  }

  .print-item-svg svg {
    display: block;
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    shape-rendering: crispEdges;
  }

  /* Paper-Specific Vertical Geometry Calibration */
  .print-paper-a4_9 .print-sheet { gap: 2.2mm; }
  .print-paper-a4_9 .print-item-box { height: 28.2mm; }
  .print-paper-a4_9 .print-item-svg svg { max-height: 20mm !important; }

  .print-paper-a4_8 .print-sheet { gap: 2.8mm; }
  .print-paper-a4_8 .print-item-box { height: 31.5mm; }
  .print-paper-a4_8 .print-item-svg svg { max-height: 23mm !important; }

  .print-paper-a5_4 .print-sheet { gap: 3mm; }
  .print-paper-a5_4 .print-item-box { height: 44mm; padding: 2.5mm 3mm; }
  .print-paper-a5_4 .print-item-svg svg { max-height: 33mm !important; }

  .print-paper-thermal_4x6 .print-sheet { gap: 2.5mm; }
  .print-paper-thermal_4x6 .print-item-box { height: 42mm; padding: 2mm 2.5mm; }
  .print-paper-thermal_4x6 .print-item-svg svg { max-height: 32mm !important; }

  .print-paper-thermal_4x2 .print-sheet-header { display: none !important; }
  .print-paper-thermal_4x2 .print-sheet { gap: 0; }
  .print-paper-thermal_4x2 .print-item-box {
    border: none !important;
    height: 43mm;
    padding: 1mm 2mm;
  }
  .print-paper-thermal_4x2 .print-item-svg svg { max-height: 34mm !important; }
}
