:root{
  --bg: #f0f4f8;
  --card: #ffffff;
  --border: #d1dce6;
  --text: #0f1419;
  --muted: #5a6c7d;
  --accent: #10b981;
  --accent2: #0ea5e9;
  --danger: #ef4444;
  --sidebar-width: 260px;
  --shadow: 0 10px 30px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 20px 40px rgba(0,0,0,0.1);
}

*{ 
  box-sizing:border-box;
  /* iOS tap highlight removal for cleaner touch experience */
  -webkit-tap-highlight-color: transparent;
}

html,body{ 
  height:100%; 
  /* Prevent rubber-band scrolling on iOS */
  overscroll-behavior: none;
  /* Enable smooth scrolling on iOS */
  -webkit-overflow-scrolling: touch;
}

body{
  margin:0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  background: linear-gradient(135deg, var(--bg) 0%, #e8eef6 100%);
  background-attachment: fixed;
  color: var(--text);
  font-size: 17px;
  line-height: 1.5;
  min-height: 100vh;
  animation: fadeIn 0.6s ease-out;
  transition: background-color 0.3s ease, color 0.3s ease;
  /* iOS-specific: Prevent text size adjustment */
  -webkit-text-size-adjust: 100%;
  /* Support for safe areas on notched iPads */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ================= HEADER ================= */

.topbar{
  position: sticky;
  top:0;
  z-index:50;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  padding: 12px 16px;
  display:flex;
  gap:14px;
  align-items:center;
  justify-content:space-between;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
  transition: all 0.3s ease;
  /* Support iPhone notch/dynamic island */
  padding-top: max(12px, env(safe-area-inset-top));
}

/* Mobile phones and small screens */
@media (max-width: 768px) {
  .topbar {
    padding: 10px 12px;
    padding-top: max(10px, env(safe-area-inset-top));
    gap: 8px;
  }
}

/* Very small phones (iPhone SE, older models) */
@media (max-width: 375px) {
  .topbar {
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
    gap: 6px;
  }
}

/* Header actions container */
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .actions {
    width: 100%;
    justify-content: stretch;
  }
  
  .actions .btn {
    flex: 1;
    min-width: 0;
  }
}

.brand{
  display:flex;
  gap:12px;
  align-items:center;
}

.dot{
  width:14px;
  height:14px;
  border-radius:999px;
  background: linear-gradient(135deg, #10b981 0%, #0ea5e9 100%);
  box-shadow: 0 4px 12px rgba(16,185,129,0.3);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite, float 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
}

@keyframes glow {
  0%, 100% { 
    box-shadow: 0 4px 12px rgba(16,185,129,0.3);
  }
  50% { 
    box-shadow: 0 6px 20px rgba(16,185,129,0.5);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes wiggle {
  0%, 100% { transform: rotateZ(0deg); }
  25% { transform: rotateZ(2deg); }
  75% { transform: rotateZ(-2deg); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes slideDown {
  from {
    transform: translateY(-10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateX(-50%) translateY(40px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

@keyframes slideInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.title{
  font-weight:800;
  font-size:16px;
  background: linear-gradient(135deg, #0f1419 0%, #1e293b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@media (max-width: 640px) {
  .title {
    font-size: 14px;
  }
}

@media (max-width: 375px) {
  .title {
    font-size: 13px;
  }
}

.sub{
  font-size:12px;
  color: var(--muted);
  margin-top: 2px;
}

/* Hide subtitle on very small screens */
@media (max-width: 640px) {
  .sub {
    display: none;
  }
}

.brand {
  flex: 1;
  min-width: 0; /* Allow text truncation */
  overflow: hidden;
}

.brand > div {
  overflow: hidden;
}

@media (max-width: 640px) {
  .brand {
    flex: 1 1 auto;
  }
}

/* ================= SIDEBAR ================= */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--card);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 100;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  /* iOS smooth momentum scrolling */
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  /* Safe area support for notched iPads in landscape */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.sidebar.open {
  transform: translateX(0);
  pointer-events: auto;
}

/* Compact nav (phones + touch tablets): off-canvas sidebar */
@media (max-width: 1180px) and (pointer: coarse), (max-width: 768px) {
  .sidebar {
    width: 85%;
    max-width: 320px;
    box-shadow: 4px 0 12px rgba(0,0,0,0.15);
  }
}

/* Desktop pointer devices: keep sidebar pinned and always visible */
@media (min-width: 769px) and (hover: hover) and (pointer: fine) {
  body {
    padding-left: var(--sidebar-width);
  }

  .sidebar {
    transform: translateX(0);
    pointer-events: auto;
    width: var(--sidebar-width);
    max-width: var(--sidebar-width);
  }

  .sidebar-overlay {
    display: none !important;
  }
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  padding-top: max(18px, calc(env(safe-area-inset-top) + 8px));
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--card);
}

.sidebar-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  flex: 1;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  font-size: 28px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  /* Increased for better iPad touch target */
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  /* iOS touch optimization */
  -webkit-touch-callout: none;
  touch-action: manipulation;
  transition: color 0.2s ease;
}

.sidebar-close:active {
  color: var(--danger);
}

@media (max-width: 1180px) and (pointer: coarse), (max-width: 768px) {
  .sidebar { width: 85%; max-width: 320px; }
  .sidebar-close { display: flex; }
}

.sidebar-nav {
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  /* Increased padding for iPad touch targets */
  padding: 16px 18px;
  min-height: 52px;
  background: none;
  border: none;
  text-align: left;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  /* iOS touch optimization */
  -webkit-touch-callout: none;
  touch-action: manipulation;
  border-left: 3px solid transparent;
}

.nav-item:active {
  background: rgba(16, 185, 129, 0.12);
}

.nav-item:hover {
  background: rgba(16, 185, 129, 0.08);
  color: var(--accent);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.12), transparent);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 700;
}

.nav-icon {
  font-size: 18px;
}

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
  display: none;
  animation: fadeIn 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.show {
  display: block;
}

/* ================= SIDEBAR TOGGLE ================= */

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text);
  cursor: pointer;
  /* Increased padding for iPad touch target */
  padding: 10px;
  min-width: 44px;
  min-height: 44px;
  transition: all 0.2s ease;
  margin-right: 8px;
  border-radius: 8px;
  /* iOS touch optimization */
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.sidebar-toggle:active {
  background: rgba(0,0,0,0.05);
}

.hamburger-icon {
  display: block;
  font-size: 22px;
  line-height: 1;
}

@media (max-width: 1180px) and (pointer: coarse), (max-width: 768px) {
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
}

/* ================= STATUS BADGE ================= */

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  color: #065f46;
  animation: slideInRight 0.4s ease-out backwards;
}

/* Hide status badge on small phones to save space */
@media (max-width: 640px) {
  .status-badge {
    display: none;
  }
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.status-indicator.active {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.status-indicator.idle {
  background: #f59e0b;
  animation: fadeInOut 1.5s ease-in-out infinite;
}

.status-indicator.complete {
  background: #3b82f6;
}

@keyframes fadeInOut {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ================= LAYOUT ================= */

.wrap{
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 20px 48px;
  display:grid;
  gap:24px;
  animation: fadeInUp 0.6s ease-out 0.2s both;
}

@media (max-width: 768px) {
  .wrap {
    margin: 20px auto;
    padding: 0 16px 40px;
    gap: 20px;
  }
}

@media (max-width: 640px) {
  .wrap {
    margin: 16px auto;
    padding: 0 12px 32px;
    gap: 16px;
  }
}

.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: fadeInUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Reduce padding on mobile */
@media (max-width: 640px) {
  .card {
    padding: 20px 16px;
    border-radius: 16px;
  }
}

@media (max-width: 375px) {
  .card {
    padding: 16px 12px;
  }
}

.card:hover{
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.row{
  display:grid;
  grid-template-columns: 280px 1fr;
  gap:20px;
}

/* Tablet and below */
@media (max-width: 820px){
  .row{ 
    grid-template-columns: 1fr; 
    gap: 16px;
  }
}

/* Mobile phones */
@media (max-width: 640px){
  .row{ 
    gap: 12px;
  }
}

.field{
  display:flex;
  flex-direction:column;
  gap:10px;
  animation: slideInLeft 0.5s ease-out backwards;
}

.field:nth-child(1) { animation-delay: 0.1s; }
.field:nth-child(2) { animation-delay: 0.15s; }
.field:nth-child(3) { animation-delay: 0.2s; }
.field:nth-child(4) { animation-delay: 0.25s; }
.field:nth-child(5) { animation-delay: 0.3s; }
.field:nth-child(n+6) { animation-delay: 0.35s; }

.label{
  font-size:13px;
  font-weight:700;
  color: var(--text);
  letter-spacing: 0.3px;
}

.hint{
  font-size:12px;
  color: var(--muted);
  font-weight: 500;
}

/* ================= INPUTS ================= */

.input{
  width:100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: #ffffff;
  color: var(--text);
  /* 16px minimum prevents iOS auto-zoom */
  font-size: 16px;
  min-height: 44px;
  outline:none;
  transition: all 0.25s ease;
  font-family: inherit;
  animation: slideInLeft 0.4s ease-out backwards;
  /* iOS-specific input optimizations */
  -webkit-appearance: none;
  appearance: none;
}

.input:focus{
  border-color: var(--accent2);
  box-shadow: 0 0 0 4px rgba(14,165,233,0.15), inset 0 1px 2px rgba(0,0,0,0.05);
  transform: translateY(-1px);
}

.input:disabled{
  background: #f1f5f9;
  opacity: 0.6;
  cursor: not-allowed;
}

.input::placeholder{
  color: #a0aec0;
}

/* ================= BUTTONS ================= */

.btn{
  border:none;
  border-radius: 12px;
  /* Increased padding for iPad/iOS touch targets (min 44x44px) */
  padding: 12px 20px;
  min-height: 44px;
  font-weight:700;
  cursor:pointer;
  font-size:14px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 0.3px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  /* iOS: Prevent callout menu on long-press */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  /* Optimize touch response */
  touch-action: manipulation;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.btn:active::before {
  animation: ripple 0.6s ease-out;
}

@keyframes ripple {
  to {
    width: 500px;
    height: 500px;
    opacity: 0;
  }
}

.btn.primary{
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 4px 15px rgba(16,185,129,0.3);
  border: 1px solid transparent;
}

.btn.primary:hover{
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(16,185,129,0.4);
  filter: brightness(1.08);
}

.btn.primary:active{
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

.btn.secondary{
  background: #f0f4f8;
  color: var(--text);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-md);
}

.btn.secondary:hover{
  background: #e8eef6;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  border-color: var(--accent2);
}

.btn.secondary:active{
  transform: translateY(0);
  box-shadow: var(--shadow-md);
}

.btn.big{
  padding: 14px 22px;
  font-size:16px;
}

/* Make big buttons full-width on mobile */
@media (max-width: 640px) {
  .btn.big {
    width: 100%;
    padding: 16px 20px;
  }
}

.btn:disabled{
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ================= PICKER ================= */

.pickerBtn{
  width:100%;
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:14px 16px;
  min-height: 44px;
  border-radius:12px;
  border:1.5px solid var(--border);
  background:#ffffff;
  cursor:pointer;
  font-size:16px;
  font-weight: 600;
  transition: all 0.25s ease;
  animation: slideInLeft 0.4s ease-out backwards;
  /* iOS touch optimizations */
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

.pickerBtn:hover:not(:disabled){
  border-color: var(--accent2);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.pickerBtn:disabled{
  background:#f1f5f9;
  cursor:not-allowed;
  opacity: 0.6;
}

.pickerBtn:focus{
  border-color: var(--accent2);
  box-shadow: 0 0 0 4px rgba(14,165,233,0.15);
  outline: none;
}

.pickerChevron{
  color: var(--muted);
  transition: transform 0.25s ease;
}

.pickerBtn:hover .pickerChevron {
  transform: rotate(180deg) scale(1.1);
}

/* ================= SCAN LIST ================= */

.scanHeader{
  margin-top:20px;
  display:flex;
  gap:12px;
  align-items:center;
  flex-wrap:wrap;
}

@media (max-width: 640px) {
  .scanHeader {
    gap: 8px;
    margin-top: 16px;
  }
}

.pill{
  padding:8px 14px;
  border-radius:999px;
  background:#f0f4f8;
  font-size:13px;
  font-weight:700;
  border: 1px solid var(--border);
  transition: all 0.25s ease;
  animation: scaleIn 0.3s ease-out backwards;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .pill {
    padding: 6px 12px;
    font-size: 12px;
  }
}

.pill:hover{
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.scanList{
  margin-top:16px;
  display:grid;
  gap:12px;
}

@media (max-width: 640px) {
  .scanList {
    gap: 8px;
  }
}

.scanItem{
  padding:14px 16px;
  border-radius:12px;
  border:1px solid var(--border);
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.4s ease-out backwards;
}

@media (max-width: 640px) {
  .scanItem {
    padding: 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .scanItem button {
    align-self: flex-end;
    width: auto;
  }
}

.scanItem:nth-child(1) { animation-delay: 0.05s; }
.scanItem:nth-child(2) { animation-delay: 0.1s; }
.scanItem:nth-child(3) { animation-delay: 0.15s; }
.scanItem:nth-child(4) { animation-delay: 0.2s; }
.scanItem:nth-child(5) { animation-delay: 0.25s; }
.scanItem:nth-child(n+6) { animation-delay: 0.3s; }

.scanItem:hover{
  box-shadow: var(--shadow);
  transform: translateX(2px);
  border-color: var(--accent2);
}

.scanCode{
  font-weight:800;
  font-size: 16px;
  color: var(--text);
  word-break: break-all;
}

@media (max-width: 640px) {
  .scanCode {
    font-size: 14px;
  }
}

.scanTime{
  font-size:12px;
  color: var(--muted);
  margin-top: 2px;
}

@media (max-width: 640px) {
  .scanTime {
    font-size: 11px;
  }
}

.smallBtn{
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  border:1.5px solid rgba(239,68,68,0.3);
  border-radius:10px;
  /* Increased padding for better touch targets on iPad */
  padding:10px 16px;
  min-height: 44px;
  font-weight:700;
  color: var(--danger);
  cursor:pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  /* iOS touch optimization */
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.smallBtn:hover{
  background: #fca5a5;
  box-shadow: 0 4px 12px rgba(239,68,68,0.2);
  transform: translateY(-1px);
}

/* ================= PHOTO ================= */

.photoPreviewWrap{
  margin-top:14px;
  border-radius:14px;
  border:2px dashed var(--border);
  padding:16px;
  min-height:160px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: linear-gradient(135deg, #fafbfc 0%, #f0f4f8 100%);
  transition: all 0.25s ease;
  animation: slideInLeft 0.4s ease-out backwards;
}

.photoPreviewWrap:hover{
  border-color: var(--accent2);
  box-shadow: inset 0 4px 12px rgba(14,165,233,0.08);
  transform: scale(1.01);
}

.photoPreview{
  width:100%;
  border-radius:12px;
  display:none;
  box-shadow: var(--shadow);
}

.photoEmpty{
  color: var(--muted);
  font-weight:700;
  text-align: center;
}

.photoActions{
  display:flex;
  gap:14px;
  flex-wrap:wrap;
  margin-top:14px;
}

/* Stack photo buttons vertically on mobile */
@media (max-width: 640px) {
  .photoActions {
    flex-direction: column;
    gap: 10px;
  }
  
  .photoActions .btn {
    width: 100%;
  }
}

/* ================= SAVE ================= */

.saveRow{
  margin-top:20px;
  display:flex;
  gap:14px;
  flex-wrap:wrap;
}

/* Stack save buttons on mobile */
@media (max-width: 640px) {
  .saveRow {
    flex-direction: column;
    gap: 10px;
  }
}

.status{
  margin-top:14px;
  font-size:13px;
  font-weight:700;
  color: var(--muted);
}

/* ================= RECENT ================= */

.recentList{
  margin-top:14px;
  display:grid;
  gap:14px;
}

.recentItem{
  padding:16px;
  border-radius:12px;
  border:1px solid var(--border);
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  transition: all 0.25s ease;
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.4s ease-out backwards;
}

.recentItem:nth-child(1) { animation-delay: 0.1s; }
.recentItem:nth-child(2) { animation-delay: 0.15s; }
.recentItem:nth-child(3) { animation-delay: 0.2s; }
.recentItem:nth-child(4) { animation-delay: 0.25s; }
.recentItem:nth-child(n+5) { animation-delay: 0.3s; }

.recentItem:hover{
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  border-color: var(--accent2);
}

.recentCarrier{
  font-weight:800;
  font-size: 15px;
  color: var(--text);
}

.recentMeta{
  font-size:12px;
  color: var(--muted);
  margin-top: 6px;
}

.barcode-list{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.barcode-item{
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
}

.recentLink{
  margin-top:10px;
  display:inline-block;
  color: var(--accent2);
  font-weight:700;
  text-decoration:none;
  transition: all 0.25s ease;
  padding: 4px 8px;
  border-radius: 6px;
}

.recentLink:hover{
  text-decoration:none;
  background: rgba(14,165,233,0.1);
  transform: translateX(2px);
}

/* ================= EXTRAS (COUNT / PROGRESS / VERIFIED) ================= */

.pill.subtle{
  background:#f0f4f8;
  color: var(--muted);
  border-color: var(--border);
}

.pill.ok{
  background: rgba(16,185,129,0.12);
  color: #065f46;
  border-color: rgba(16,185,129,0.3);
}

.pill.danger{
  background: rgba(239,68,68,0.12);
  color: #7f1d1d;
  border-color: rgba(239,68,68,0.3);
}

.divider{
  height:1px;
  background: var(--border);
  margin: 20px 0;
}

.countAlert{
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: #f8fafc;
  color: var(--muted);
  font-weight:700;
  font-size: 13px;
  transition: all 0.25s ease;
  animation: slideInLeft 0.4s ease-out backwards;
}

.countAlert.ok{
  border-color: rgba(16,185,129,0.4);
  background: rgba(16,185,129,0.08);
  color: #065f46;
  box-shadow: inset 0 1px 2px rgba(16,185,129,0.1);
  animation: slideInLeft 0.4s ease-out, glow 2s ease-in-out infinite alternate;
}

.countAlert.error{
  border-color: rgba(239,68,68,0.4);
  background: rgba(239,68,68,0.08);
  color: #7f1d1d;
  box-shadow: inset 0 1px 2px rgba(239,68,68,0.1);
}

/* ================= MODAL ================= */

.modal{
  position:fixed;
  inset:0;
  display:none;
  z-index:9999;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal.show{
  display:block;
}

.modalBackdrop{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
}

.modalSheet{
  position:absolute;
  left:50%;
  transform:translateX(-50%) translateY(0);
  bottom:20px;
  width:min(700px, 95%);
  /* Safe bottom padding for iPads with home indicator */
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  background:white;
  border-radius:20px;
  padding:24px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.18);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  /* iOS smooth scrolling if modal content is long */
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Better modal on mobile phones */
@media (max-width: 640px) {
  .modalSheet {
    width: calc(100% - 20px);
    bottom: 10px;
    padding: 20px 16px;
    border-radius: 16px;
    max-height: 85vh;
  }
}

@media (max-width: 375px) {
  .modalSheet {
    padding: 16px 12px;
  }
}

@keyframes slideUp {
  from {
    transform: translateX(-50%) translateY(40px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

.modalTitle{
  font-weight:800;
  font-size: 18px;
  color: var(--text);
}

.carrierGrid{
  margin-top:16px;
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:12px;
}

/* Single column on very small phones */
@media (max-width: 400px) {
  .carrierGrid {
    grid-template-columns: 1fr;
  }
}

.carrierOption{
  /* Increased padding for iPad touch targets */
  padding:16px 14px;
  min-height: 110px;
  border-radius:12px;
  border:1.5px solid var(--border);
  background:#f8fafc;
  cursor:pointer;
  font-weight:700;
  text-align:center;
  transition: all 0.25s ease;
  color: var(--text);
  animation: scaleIn 0.3s ease-out backwards;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  /* iOS touch optimization */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.carrierOption:nth-child(1) { animation-delay: 0.1s; }
.carrierOption:nth-child(2) { animation-delay: 0.15s; }
.carrierOption:nth-child(3) { animation-delay: 0.2s; }
.carrierOption:nth-child(4) { animation-delay: 0.25s; }
.carrierOption:nth-child(5) { animation-delay: 0.3s; }
.carrierOption:nth-child(6) { animation-delay: 0.35s; }
.carrierOption:nth-child(7) { animation-delay: 0.4s; }

.carrierOption:hover{
  border-color: var(--accent2);
  transform: translateY(-2px) scale(1.03);
  box-shadow: var(--shadow-md);
}

.carrierOption.selected{
  background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(14,165,233,0.1));
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(16,185,129,0.2);
  animation: bounce 0.6s ease-out;
}

/* ================= EXTRAS (COUNT / PROGRESS / VERIFIED) ================= */

.pill.subtle{
  background:#f1f5f9;
  color: var(--muted);
}

.pill.ok{
  background: rgba(22,163,74,0.14);
  color: #166534;
}

.pill.danger{
  background: rgba(220,38,38,0.14);
  color: var(--danger);
}

.divider{
  height:1px;
  background: var(--border);
  margin: 18px 0;
}

.countAlert{
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--muted);
  font-weight:700;
  font-size: 13px;
}

.countAlert.ok{
  border-color: rgba(22,163,74,0.35);
  background: rgba(22,163,74,0.10);
  color: #166534;
}

.countAlert.error{
  border-color: rgba(220,38,38,0.35);
  background: rgba(220,38,38,0.10);
  color: var(--danger);
}

.progressWrap{
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  display:none;
  box-shadow: var(--shadow-md);
  transition: all 0.25s ease;
}

.progressTop{
  display:flex;
  justify-content:space-between;
  align-items:center;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: 0.3px;
}

.progressBarOuter{
  width:100%;
  height: 16px;
  border-radius: 999px;
  background:#e5e7eb;
  border: 1px solid var(--border);
  overflow:hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

.progressBarInner{
  height:100%;
  width:0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #10b981 0%, #0ea5e9 100%);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px rgba(16,185,129,0.4);
  animation: shimmer 2s infinite;
  background-size: 200% 100%;
}

.verifiedBadge{
  display:none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(14,165,233,0.1));
  color: #065f46;
  border: 1px solid rgba(16,185,129,0.3);
  letter-spacing: 0.3px;
}

.verifiedBadge.show{
  display:inline-flex;
  animation: slideInScale 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ================= SCAN STATE BANNER ================= */

.scanStateBanner{
  position: sticky;
  top: 72px;
  z-index: 9;
  width: 100%;
  padding: 12px 20px;
  text-align: center;
  font-weight: 900;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  user-select: none;
  font-size: 14px;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    transform: translateY(-10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.scanStateBanner.on{
  background: linear-gradient(135deg, rgba(16,185,129,0.12), rgba(16,185,129,0.08));
  color: #065f46;
  border-bottom-color: rgba(16,185,129,0.3);
}

.scanStateBanner.off{
  background: linear-gradient(135deg, rgba(239,68,68,0.12), rgba(239,68,68,0.08));
  color: #7f1d1d;
  border-bottom-color: rgba(239,68,68,0.3);
}

@media (max-width: 420px){
  .scanStateBanner{ font-size: 13px; padding: 10px 16px; }
}

/* ================= TABS ================= */

.tabRow{
  margin-top:0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.btn.tabActive{
  background: linear-gradient(135deg, #10b981, #059669);
  color:#ffffff;
  box-shadow: 0 4px 12px rgba(16,185,129,0.3);
  border: 1px solid transparent;
}

.btn.tabActive:hover{
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.tabWithBeta{
  display:flex;
  flex-direction:column;
  gap:4px;
  align-items:center;
  position: relative;
}

.betaBadge{
  font-size:10px;
  font-weight:800;
  color:#ef4444;
  text-transform:uppercase;
  letter-spacing:0.8px;
  background: rgba(239,68,68,0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ================= DASHBOARD ================= */

.dashHeader{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  flex-wrap:wrap;
}

.dashTitle{
  font-weight:900;
  font-size:24px;
  margin:0;
}

.dashSub{
  margin-top:4px;
  font-size:13px;
  color: var(--muted);
  font-weight:700;
}

.dashControls{
  margin-top:14px;
  display:grid;
  grid-template-columns: 220px 220px;
  gap:14px;
  align-items:end;
}

/* Single column on tablets and below */
@media (max-width: 620px){
  .dashControls{ 
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

.dashBtns{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

/* Stack dashboard buttons on mobile */
@media (max-width: 640px) {
  .dashBtns {
    flex-direction: column;
    gap: 8px;
  }
  
  .dashBtns .btn {
    width: 100%;
  }
}

.dashStats{
  margin-top:16px;
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap:12px;
}

/* Tablet - 2 columns */
@media (max-width: 980px){
  .dashStats{ grid-template-columns: repeat(2, 1fr); }
}

/* Mobile phones - 1 column */
@media (max-width: 640px){
  .dashStats{ 
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

.statCard{
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: fadeInUp 0.5s ease-out backwards;
}

.statCard:nth-child(1) { animation-delay: 0.1s; }
.statCard:nth-child(2) { animation-delay: 0.15s; }
.statCard:nth-child(3) { animation-delay: 0.2s; }
.statCard:nth-child(4) { animation-delay: 0.25s; }

.statCard:hover{
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--accent2);
}

.statLabel{
  font-size:11px;
  color: var(--muted);
  font-weight:900;
  letter-spacing:0.6px;
  text-transform:uppercase;
}

.statValue{
  margin-top:8px;
  font-size:38px;
  font-weight:900;
  line-height:1;
  background: linear-gradient(135deg, var(--text), #5a6c7d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.statHint{
  margin-top:10px;
  font-size:12px;
  color: var(--muted);
  font-weight:700;
}

.statValue.danger{
  color: var(--danger);
  background: none;
  -webkit-text-fill-color: var(--danger);
}

.dashBreakdowns{
  margin-top:20px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:16px;
}

@media (max-width: 860px){
  .dashBreakdowns{ grid-template-columns: 1fr; }
}

.dashPanel{
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow-md);
  transition: all 0.25s ease;
  animation: fadeInUp 0.5s ease-out backwards;
}

.dashPanel:nth-child(1) { animation-delay: 0.2s; }
.dashPanel:nth-child(2) { animation-delay: 0.25s; }

.dashPanel:hover{
  box-shadow: var(--shadow);
}

.dashPanelTitle{
  font-weight:900;
  font-size:15px;
  margin:0 0 14px 0;
  color: var(--text);
  letter-spacing: 0.3px;
}

.dashList{
  display:grid;
  gap:12px;
}

.dashRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  transition: all 0.25s ease;
  animation: fadeInUp 0.4s ease-out backwards;
}

.dashRow:nth-child(1) { animation-delay: 0.05s; }
.dashRow:nth-child(2) { animation-delay: 0.1s; }
.dashRow:nth-child(3) { animation-delay: 0.15s; }
.dashRow:nth-child(4) { animation-delay: 0.2s; }
.dashRow:nth-child(5) { animation-delay: 0.25s; }
.dashRow:nth-child(n+6) { animation-delay: 0.3s; }

.dashRow:hover{
  box-shadow: var(--shadow-md);
  transform: translateX(2px);
  border-color: var(--accent2);
}

.dashRowName{
  font-weight:900;
  font-size:15px;
  color: var(--text);
}

.dashRowStats{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.dashChip{
  padding:6px 12px;
  border-radius:999px;
  background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(14,165,233,0.08));
  border:1px solid rgba(99,102,241,0.3);
  font-size:12px;
  font-weight:900;
  color:#4f46e5;
  transition: all 0.25s ease;
  animation: scaleIn 0.3s ease-out backwards;
}

.dashChip:hover{
  transform: scale(1.05);
}

.dashChip.danger{
  background: linear-gradient(135deg, rgba(239,68,68,0.12), rgba(239,68,68,0.08));
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger);
}

.dashEmpty{
  padding: 16px;
  border-radius: 12px;
  border: 2px dashed var(--border);
  background: linear-gradient(135deg, #f8fafc 0%, #f0f4f8 100%);
  color: var(--muted);
  font-weight:800;
  transition: all 0.25s ease;
  text-align: center;
}

.dashNotice{
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(14,165,233,0.3);
  background: linear-gradient(135deg, rgba(14,165,233,0.1), rgba(14,165,233,0.05));
  color: #075985;
  font-weight:800;
  font-size:13px;
  transition: all 0.25s ease;
}

.dashNotice.warn{
  border-color: rgba(239,68,68,0.3);
  background: linear-gradient(135deg, rgba(239,68,68,0.1), rgba(239,68,68,0.05));
  color: #991b1b;
}

/* ================= MULTI GROUP PHOTOS ================= */
.photoList{
  margin-top: 16px;
  display:flex;
  gap:14px;
  flex-wrap:wrap;
}

.photoThumb{
  width: 160px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:12px;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.4s ease-out backwards;
}

.photoThumb:nth-child(1) { animation-delay: 0.1s; }
.photoThumb:nth-child(2) { animation-delay: 0.15s; }
.photoThumb:nth-child(3) { animation-delay: 0.2s; }
.photoThumb:nth-child(n+4) { animation-delay: 0.25s; }

.photoThumb:hover{
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow);
  border-color: var(--accent2);
}

.photoThumbImg{
  width:100%;
  height:120px;
  object-fit:cover;
  border-radius:10px;
  border:1px solid var(--border);
  background:#ffffff;
  transition: all 0.25s ease;
  animation: scaleIn 0.4s ease-out backwards;
}

.photoThumbImg:hover{
  transform: scale(1.05);
}

.photoThumbRemove{
  border:1.5px solid rgba(239,68,68,0.3);
  border-radius:10px;
  padding:10px 12px;
  font-weight:800;
  cursor:pointer;
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: var(--danger);
  transition: all 0.2s ease;
  font-size: 13px;
}

.photoThumbRemove:hover{
  background: #fca5a5;
  box-shadow: 0 4px 12px rgba(239,68,68,0.2);
  transform: translateY(-1px);
}

/* ================= CUSTOMER FILES ================= */

.fileInputWrapper{
  display:flex;
  gap:14px;
  align-items:center;
  padding:14px 16px;
  background: linear-gradient(135deg, #f8fafc 0%, #f0f4f8 100%);
  border:1.5px solid var(--border);
  border-radius:12px;
  transition: all 0.25s ease;
}

.fileInputWrapper:hover{
  border-color: var(--accent2);
  box-shadow: var(--shadow-md);
}

.hidden{
  display:none !important;
}

.fileCount{
  font-size:14px;
  color:var(--muted);
  font-weight: 600;
}

.filesListContainer{
  margin:0;
}

/* ================= iOS/iPadOS OPTIMIZATIONS ================= */

/* Textarea specific iOS styling */
textarea.input {
  resize: vertical;
  min-height: 80px;
  /* Prevent iOS from adding unwanted styles */
  -webkit-appearance: none;
  appearance: none;
}

/* Better focus indicators for iPad keyboard navigation */
.input:focus,
.btn:focus,
.pickerBtn:focus,
.nav-item:focus,
button:focus {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

/* Active states for touch feedback on iOS */
.btn:active {
  transform: scale(0.97);
}

.carrierOption:active,
.nav-item:active {
  transform: scale(0.98);
  opacity: 0.8;
}

/* Prevent iOS from styling buttons and inputs */
input[type="submit"],
input[type="button"],
button {
  -webkit-appearance: none;
  appearance: none;
}

/* Optimize file input for iOS camera access */
input[type="file"] {
  /* Ensure camera opens properly on iOS */
  -webkit-appearance: none;
  appearance: none;
}

/* Prevent iOS text inflation */
@supports (-webkit-touch-callout: none) {
  /* iOS-specific rules */
  body {
    /* Prevent text size adjustment when orientation changes */
    -webkit-text-size-adjust: 100%;
  }
  
  /* Disable webkit tap highlight on all interactive elements */
  button, a, input, select, textarea {
    -webkit-tap-highlight-color: transparent;
  }
}

/* iPad-specific media queries */
@media only screen 
  and (min-device-width: 768px) 
  and (max-device-width: 1024px) 
  and (-webkit-min-device-pixel-ratio: 2) {
  /* iPad-specific optimizations */
  
  .btn, .smallBtn {
    /* Slightly larger touch targets for iPad */
    min-height: 48px;
  }
  
  .nav-item {
    min-height: 48px;
    font-size: 16px;
  }
}

/* Landscape orientation optimizations for iPad */
@media only screen 
  and (orientation: landscape) 
  and (max-device-height: 1024px) {
  .modalSheet {
    max-height: 85vh;
  }
  
  .sidebar {
    /* Better sidebar width in landscape */
    width: 320px;
  }
}

/* Support for split-screen multitasking on iPad */
@media (max-width: 678px) {
  .dashStats {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .carrierGrid {
    grid-template-columns: 1fr;
  }
}

/* Accessibility: Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.filesBatchesContainer{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.fileBatchCard{
  border:1px solid var(--border);
  border-radius:12px;
  overflow:hidden;
  background: #ffffff;
  box-shadow: var(--shadow-md);
  transition: all 0.25s ease;
  animation: fadeInUp 0.4s ease-out backwards;
}

.fileBatchCard:nth-child(1) { animation-delay: 0.1s; }
.fileBatchCard:nth-child(2) { animation-delay: 0.15s; }
.fileBatchCard:nth-child(3) { animation-delay: 0.2s; }
.fileBatchCard:nth-child(n+4) { animation-delay: 0.25s; }

.fileBatchCard:hover{
  box-shadow: var(--shadow);
  border-color: var(--accent2);
  transform: translateY(-2px);
}

.batchHeader{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:16px 18px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-bottom:1px solid var(--border);
  font-weight:700;
}

.batchCustomer{
  font-size:16px;
  color:var(--text);
  font-weight: 800;
}

.batchMeta{
  display:flex;
  gap:24px;
  align-items:center;
}

.batchDate{
  font-size:13px;
  color:var(--muted);
  font-weight: 600;
}

.batchExpiration{
  font-size:13px;
  color:var(--accent);
  font-weight:700;
  background: rgba(16,185,129,0.1);
  padding: 4px 10px;
  border-radius: 6px;
}

.batchNotes{
  padding:14px 18px;
  background:#ffffff;
  border-bottom:1px solid var(--border);
  font-size:14px;
  color:var(--text);
  line-height:1.5;
  word-break:break-word;
  font-weight: 500;
}

.batchFiles{
  display:flex;
  flex-direction:column;
  gap:0;
  padding:0;
}

.batchFileItem{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:14px 18px;
  border-bottom:1px solid var(--border);
  background:#ffffff;
  transition: all 0.2s ease;
}

.batchFileItem:hover{
  background: #f8fafc;
}

.batchFileItem:last-child{
  border-bottom:none;
}

.fileInfo{
  flex:1;
}

.fileName{
  color:var(--accent2);
  text-decoration:none;
  font-weight:600;
  font-size:15px;
  word-break:break-word;
  transition: all 0.2s ease;
}

.fileName:hover{
  text-decoration:underline;
  color: var(--accent);
}

.fileSize{
  font-size:12px;
  color:var(--muted);
  margin-top:4px;
}

.batchActions{
  padding:14px 18px;
  background: linear-gradient(135deg, #f8fafc 0%, #f0f4f8 100%);
  text-align:right;
  border-top:1px solid var(--border);
}

.filesTable{
  display:flex;
  flex-direction:column;
  gap:0;
  border:1px solid var(--border);
  border-radius:12px;
  overflow:hidden;
  box-shadow: var(--shadow-md);
  background: #ffffff;
}

.filesTableHeader{
  display:grid;
  grid-template-columns: 1fr 100px 150px 120px;
  gap:12px;
  padding:14px 16px;
  background: linear-gradient(135deg, #f8fafc 0%, #f0f4f8 100%);
  font-weight:800;
  font-size:13px;
  border-bottom:1px solid var(--border);
  letter-spacing: 0.3px;
  color: var(--muted);
  text-transform: uppercase;
}

.filesTableRow{
  display:grid;
  grid-template-columns: 1fr 100px 150px 120px;
  gap:12px;
  padding:14px 16px;
  border-bottom:1px solid var(--border);
  align-items:center;
  transition: all 0.2s ease;
  background: #ffffff;
  animation: fadeInUp 0.3s ease-out backwards;
}

.filesTableRow:nth-child(1) { animation-delay: 0.05s; }
.filesTableRow:nth-child(2) { animation-delay: 0.1s; }
.filesTableRow:nth-child(3) { animation-delay: 0.15s; }
.filesTableRow:nth-child(4) { animation-delay: 0.2s; }
.filesTableRow:nth-child(n+5) { animation-delay: 0.25s; }

.filesTableRow:hover{
  background: #f8fafc;
}

.filesTableRow:last-child{
  border-bottom:none;
}

.filesTableName{
  word-break:break-word;
  font-size:15px;
  font-weight: 600;
}

.filesTableName a{
  color:var(--accent2);
  text-decoration:none;
  font-weight:600;
  transition: all 0.2s ease;
}

.filesTableName a:hover{
  text-decoration:underline;
  color: var(--accent);
}

.filesTableSize{
  font-size:13px;
  color:var(--muted);
  text-align:right;
  font-weight: 600;
}

.filesTableDate{
  font-size:13px;
  color:var(--muted);
  text-align:right;
  font-weight: 600;
}

.filesTableActions{
  display:flex;
  gap:8px;
  justify-content:flex-end;
}

.btn.small{
  padding:6px 14px;
  font-size:13px;
  font-weight:600;
}

/* ================= AUTO-REFRESH INDICATOR ================= */

.auto-refresh-indicator {
  display: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.auto-refresh-indicator.active {
  display: flex;
}

.refresh-dot {
  width: 6px;
  height: 6px;
  background: #10b981;
  border-radius: 50%;
  animation: refreshPulse 2s ease-in-out infinite;
}

@keyframes refreshPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ================= MOBILE & IPHONE SPECIFIC OPTIMIZATIONS ================= */

/* iPhone-specific safe area adjustments */
@supports (padding: max(0px)) {
  body {
    padding-top: env(safe-area-inset-top);
  }
  
  .wrap {
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-bottom: max(48px, env(safe-area-inset-bottom));
  }
  
  @media (max-width: 640px) {
    .wrap {
      padding-left: max(16px, env(safe-area-inset-left));
      padding-right: max(16px, env(safe-area-inset-right));
      padding-bottom: max(32px, env(safe-area-inset-bottom));
    }
  }
}

/* iPhone 16 Pro Max and similar (430px wide) */
@media only screen and (max-width: 430px) {
  body {
    font-size: 16px;
  }
  
  .input, textarea.input {
    font-size: 16px !important; /* Prevent zoom */
  }
  
  .modalTitle {
    font-size: 16px;
  }
  
  .recentCarrier {
    font-size: 14px;
  }
}

/* iPhone SE and very small phones (375px and below) */
@media only screen and (max-width: 375px) {
  body {
    font-size: 15px;
  }
  
  .wrap {
    margin: 16px auto;
  }
  
  .field {
    gap: 8px;
  }
  
  .label {
    font-size: 12px;
  }
  
  .hint {
    font-size: 11px;
  }
  
  .btn {
    font-size: 13px;
    padding: 10px 16px;
  }
}

/* Landscape orientation on phones */
@media only screen 
  and (max-height: 500px) 
  and (orientation: landscape) {
  .topbar {
    position: relative; /* Don't stick in landscape */
  }
  
  .modal {
    align-items: center;
    display: flex !important;
    justify-content: center;
  }
  
  .modalSheet {
    position: relative;
    transform: none;
    left: auto;
    bottom: auto;
    max-height: 90vh;
  }
  
  .sidebar {
    width: 260px;
  }
}

/* Better touch targets for all interactive elements on mobile */
@media (max-width: 640px) {
  button, 
  a.btn,
  .btn,
  .nav-item,
  .pickerBtn,
  input[type="submit"],
  input[type="button"] {
    min-height: 44px;
  }
  
  /* Prevent text selection on buttons for better UX */
  button, .btn {
    -webkit-user-select: none;
    user-select: none;
  }
  
  /* Better spacing in recent items */
  .recentItem {
    padding: 14px 12px;
  }
  
  .recentMeta {
    font-size: 11px;
  }
  
  /* Make barcode items wrap better */
  .barcode-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
  }
  
  .barcode-item {
    font-size: 10px;
    padding: 3px 6px;
  }
}

/* Prevent horizontal scrolling on all devices */
body, html {
  overflow-x: hidden;
  max-width: 100vw;
}

.wrap, .card, .row {
  max-width: 100%;
}

/* Better focus states for keyboard navigation on all devices */
@media (hover: none) and (pointer: coarse) {
  /* Touch devices - enhance active states */
  .btn:active,
  .nav-item:active,
  .carrierOption:active {
    transform: scale(0.96);
  }
  
  /* Remove hover effects on touch devices */
  .card:hover {
    transform: none;
  }
  
  .btn.primary:hover,
  .btn.secondary:hover {
    transform: none;
  }
}

/* Progressive Web App - Full screen support */
@media all and (display-mode: standalone) {
  body {
    /* Extra padding for full screen mode */
    padding-top: max(20px, env(safe-area-inset-top));
  }
  
  .topbar {
    padding-top: max(16px, env(safe-area-inset-top));
  }
}

/* Dark mode support (optional - activates if user has dark mode enabled) */
@media (prefers-color-scheme: dark) {
  /* Users can add dark mode styles here if needed in the future */
}

/* High contrast mode for accessibility */
@media (prefers-contrast: high) {
  .input,
  .btn,
  .card {
    border-width: 2px;
  }
}

/* Optimize animations for low-end devices */
@media (prefers-reduced-motion: no-preference) {
  /* Animations are already defined, no change needed */
}

/* Print styles to prevent issues when printing */
@media print {
  .topbar,
  .sidebar,
  .sidebar-overlay,
  .btn,
  .actions {
    display: none !important;
  }
  
  .wrap {
    margin: 0;
    padding: 0;
  }
  
  .card {
    box-shadow: none;
    border: 1px solid #000;
    page-break-inside: avoid;
  }
}