/* ============================================
   PostPro Nexus - Benchmarking Mobile Styles v5
   FIXES: Header, forced list view, consistent heights, modal scrolling
   ============================================ */

/* ============ BULK SELECT STYLES ============ */

.select-checkbox {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: 2px solid #CBD5E1;
  border-radius: 4px;
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  z-index: 5;
}

.select-checkbox svg {
  width: 16px;
  height: 16px;
  opacity: 0;
  stroke: white;
  transition: opacity 0.15s;
}

.select-checkbox.checked {
  background: #3B82F6;
  border-color: #3B82F6;
}

.select-checkbox.checked svg {
  opacity: 1;
}

body.select-mode .benchmark-card {
  padding-left: 48px;
}

body.select-mode .benchmark-card.selected {
  background: rgba(59, 130, 246, 0.05);
  border-color: #3B82F6;
}

body.select-mode .benchmark-list-item {
  padding-left: 48px;
}

body.select-mode .benchmark-list-item.selected {
  background: rgba(59, 130, 246, 0.05);
}

/* Bulk actions bar */
.bulk-actions-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1E293B;
  color: white;
  padding: 12px 20px;
  z-index: 1000;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bulk-actions-bar.visible {
  display: flex;
}

.bulk-actions-bar .selected-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.bulk-actions-bar .selected-count {
  font-weight: 700;
  font-size: 18px;
  color: #60A5FA;
}

.bulk-actions-bar .bulk-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.bulk-actions-bar button {
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.bulk-actions-bar .btn-select-all {
  background: transparent;
  color: white;
  border: 1px solid #475569;
}

.bulk-actions-bar .btn-delete {
  background: #EF4444;
  color: white;
}

.bulk-actions-bar .btn-cancel {
  background: transparent;
  color: #94A3B8;
}

#selectModeBtn.active {
  background: #3B82F6 !important;
  color: white !important;
  border-color: #3B82F6 !important;
}

/* ============ VIEW TOGGLE ============ */

.view-toggle {
  display: flex;
  gap: 2px;
  background: #E5E7EB;
  padding: 3px;
  border-radius: 6px;
}

.view-toggle button {
  padding: 8px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-toggle button svg {
  width: 18px;
  height: 18px;
  stroke: #6B7280;
  transition: stroke 0.2s;
}

.view-toggle button.active {
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.view-toggle button.active svg {
  stroke: var(--text-main);
}

/* ============ LIST VIEW STYLES (DESKTOP) ============ */

.items-list {
  display: none;
  flex-direction: column;
}

.items-list.active {
  display: flex;
}

.items-grid.active {
  display: grid;
}

.items-grid:not(.active) {
  display: none;
}

.list-header {
  display: grid;
  grid-template-columns: 130px 1.5fr 1fr 110px 90px 90px;
  gap: 12px;
  padding: 10px 16px;
  background: #F1F5F9;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748B;
  border-bottom: 2px solid var(--border-color);
}

.benchmark-list-item {
  display: grid;
  grid-template-columns: 130px 1.5fr 1fr 110px 90px 90px;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card-bg);
  cursor: pointer;
  align-items: center;
  transition: background 0.15s;
  border-left: 4px solid transparent;
  border-bottom: 1px solid var(--border-color);
}

.benchmark-list-item:hover {
  background: #F8FAFC;
}

.benchmark-list-item:last-child {
  border-bottom: none;
}

.benchmark-list-item.status-form_submitted { border-left-color: #3B82F6; }
.benchmark-list-item.status-parts_received { border-left-color: #8B5CF6; }
.benchmark-list-item.status-processing { border-left-color: #F97316; }
.benchmark-list-item.status-processed { border-left-color: #06B6D4; }
.benchmark-list-item.status-shipped { border-left-color: #22C55E; }
.benchmark-list-item.status-completed { border-left-color: #10B981; }
.benchmark-list-item.status-cancelled { border-left-color: #EF4444; }

.list-item-id {
  font-family: 'Share Tech Mono', monospace;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-main);
}

.list-item-company {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-contact {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ============ CONTACT AVATAR STYLES ============ */

/* Inline contact for list view (hidden in grid view) */
.benchmark-contact-inline {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.benchmark-contact-inline img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.benchmark-contact-inline .contact-avatar-fallback {
  width: 24px;
  height: 24px;
  font-size: 10px;
}

.benchmark-contact-inline span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

/* Show inline contact in list mode */
.items-list .benchmark-contact-inline {
  display: flex;
}

/* Avatar for card view */
.contact-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.contact-avatar-fallback {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);
  color: white;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Avatar for list view (smaller) */
.contact-avatar-small {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.contact-avatar-fallback-small {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);
  color: white;
  font-size: 8px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Contact meta item in card view */
.contact-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.contact-meta-item .icon {
  display: none; /* Hide the emoji icon when using avatar */
}

.list-item-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  border-radius: 3px;
  white-space: nowrap;
}

.list-item-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.list-item-status.form_submitted { background: rgba(59, 130, 246, 0.12); color: #3B82F6; }
.list-item-status.parts_received { background: rgba(139, 92, 246, 0.12); color: #8B5CF6; }
.list-item-status.processing { background: rgba(249, 115, 22, 0.12); color: #F97316; }
.list-item-status.processed { background: rgba(6, 182, 212, 0.12); color: #06B6D4; }
.list-item-status.shipped { background: rgba(34, 197, 94, 0.12); color: #22C55E; }
.list-item-status.completed { background: rgba(16, 185, 129, 0.12); color: #10B981; }
.list-item-status.cancelled { background: rgba(239, 68, 68, 0.12); color: #EF4444; }

.list-item-parts {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.list-item-time {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

.list-item-meta {
  display: none;
}


/* ============================================================
   MOBILE STYLES
   ============================================================ */

@media (max-width: 768px) {
  
  /* ============ BODY & SCROLL ============ */
  body {
    overflow: auto !important;
    height: auto !important;
    position: static !important;
  }
  
  body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
  }
  
  /* ============ HEADER - FIXED NO OVERLAP ============ */
  .header {
    padding: 8px 12px !important;
    height: 52px !important;
    min-height: 52px !important;
    max-height: 52px !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
    overflow: hidden !important;
  }
  
  .header-left {
    flex: 0 1 auto !important;
    gap: 6px !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }
  
  .header-left img {
    height: 26px !important;
    width: auto !important;
    flex-shrink: 0 !important;
  }
  
  .header .logo-text {
    font-size: 14px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }
  
  /* Hide these on mobile header */
  .header .logo-divider,
  .header .badge-cyan {
    display: none !important;
  }
  
  /* Back link - just show arrow */
  .header .back-link {
    font-size: 0 !important;
    padding: 6px 10px !important;
    min-width: 36px !important;
  }
  
  .header .back-link::before {
    content: '← HOME';
    font-size: 10px;
    font-family: 'Share Tech Mono', monospace;
  }
  
  .header-right {
    flex: 0 0 auto !important;
    gap: 4px !important;
  }
  
  .header #userInfo {
    display: none !important;
  }
  
  .header #adminBtn,
  .header #logoutBtn {
    font-size: 9px !important;
    padding: 6px 8px !important;
    white-space: nowrap !important;
  }
  
  /* ============ MAIN CONTAINER ============ */
  .main-container {
    padding: 12px !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    display: block !important;
  }
  
  /* ============ PAGE HEADER ============ */
  .page-header {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    margin-bottom: 12px !important;
    align-items: stretch !important;
  }
  
  .page-title {
    font-size: 16px !important;
    text-align: left !important;
    margin: 0 !important;
  }
  
  /* Header actions row */
  .page-header > div:last-child {
    display: flex !important;
    gap: 8px !important;
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
  }
  
  .page-header .btn,
  .page-header .btn-secondary {
    padding: 10px 12px !important;
    font-size: 11px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }
  
  /* HIDE VIEW TOGGLE ON MOBILE - Force list view */
  .view-toggle,
  #viewToggleBtn,
  [onclick*="toggleViewMode"],
  button:has(svg[class*="grid"]) {
    display: none !important;
  }
  
  /* Hide export on mobile */
  #exportCsvBtn {
    display: none !important;
  }
  
  /* ============ FILTERS - COLLAPSIBLE ============ */
  .filters-section {
    padding: 0 !important;
    margin-bottom: 12px !important;
    background: transparent !important;
    border: none !important;
  }
  
  .filters-grid {
    display: none !important;
  }
  
  .filters-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 14px 16px !important;
    background: white !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: 600 !important;
  }
  
  .filters-toggle .filter-info {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
  }
  
  .filters-toggle .filter-icon {
    font-size: 18px !important;
  }
  
  .filters-toggle .filter-count {
    background: var(--tech-blue) !important;
    color: white !important;
    padding: 2px 8px !important;
    border-radius: 12px !important;
    font-size: 11px !important;
  }
  
  .filters-toggle .chevron-icon {
    width: 20px !important;
    height: 20px !important;
    transition: transform 0.25s ease !important;
    color: #9CA3AF !important;
  }
  
  .filters-section.expanded .filters-toggle {
    border-radius: 8px 8px 0 0 !important;
    border-bottom: none !important;
  }
  
  .filters-section.expanded .filters-toggle .chevron-icon {
    transform: rotate(180deg) !important;
  }
  
  .filters-content {
    display: none !important;
    padding: 16px !important;
    background: white !important;
    border: 1px solid var(--border-color) !important;
    border-top: none !important;
    border-radius: 0 0 8px 8px !important;
  }
  
  .filters-section.expanded .filters-content {
    display: block !important;
  }
  
  .mobile-filters {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
  }
  
  .mobile-filters .filter-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
  }
  
  .mobile-filters .detail-label {
    font-size: 11px !important;
    font-weight: 600 !important;
    color: #64748B !important;
    text-transform: uppercase !important;
  }
  
  .mobile-filters .input,
  .mobile-filters select {
    padding: 14px 12px !important;
    font-size: 16px !important;
    border-radius: 6px !important;
    border: 1px solid #E2E8F0 !important;
    background: #F8FAFC !important;
  }
  
  .mobile-filters .filter-actions {
    display: flex !important;
    gap: 10px !important;
    padding-top: 12px !important;
    border-top: 1px solid #E2E8F0 !important;
    margin-top: 6px !important;
  }
  
  .mobile-filters .filter-actions button {
    flex: 1 !important;
    padding: 14px !important;
    font-size: 13px !important;
    border-radius: 6px !important;
  }
  
  /* ============ STATS - HIDDEN ============ */
  .stats-row {
    display: none !important;
  }
  
  /* Mini stats bar */
  .stats-mini {
    display: flex !important;
    justify-content: space-around !important;
    padding: 10px 12px !important;
    background: #F8FAFC !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 6px !important;
    margin-bottom: 12px !important;
  }
  
  .stats-mini .stat-item {
    text-align: center !important;
  }
  
  .stats-mini .stat-num {
    font-weight: 700 !important;
    font-size: 18px !important;
    font-family: 'Share Tech Mono', monospace !important;
  }
  
  .stats-mini .stat-label {
    color: #64748B !important;
    font-size: 9px !important;
    text-transform: uppercase !important;
  }
  
  /* ============ CONTENT SECTION ============ */
  .content-section {
    overflow: visible !important;
    height: auto !important;
    flex: none !important;
  }
  
  .items-container {
    overflow: visible !important;
    height: auto !important;
    padding-right: 0 !important;
  }
  
  /* ============ FORCE LIST VIEW - HIDE GRID ============ */
  .items-grid {
    display: none !important;
  }
  
  .benchmark-card {
    display: none !important;
  }
  
  #benchmarksList {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    background: white !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    border: 1px solid var(--border-color) !important;
  }
  
  /* ============ LIST ITEMS - CONSISTENT HEIGHT ============ */
  .list-header {
    display: none !important;
  }
  
  .benchmark-list-item {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    padding: 14px 16px !important;
    min-height: 70px !important;
    max-height: 70px !important;
    height: 70px !important;
    border-bottom: 1px solid #E2E8F0 !important;
    position: relative !important;
    background: white !important;
    border-left: 4px solid !important;
    gap: 12px !important;
    overflow: hidden !important;
  }
  
  .benchmark-list-item:last-child {
    border-bottom: none !important;
  }
  
  .benchmark-list-item:active {
    background: #F8FAFC !important;
  }
  
  /* Left content - ID and Company */
  .benchmark-list-item .list-item-id {
    position: absolute !important;
    top: 10px !important;
    left: 20px !important;
    font-size: 9px !important;
    color: #94A3B8 !important;
  }
  
  .benchmark-list-item .list-item-company {
    flex: 1 !important;
    min-width: 0 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    padding-top: 12px !important;
    padding-right: 10px !important;
  }
  
  .benchmark-list-item .list-item-contact {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    flex-shrink: 0 !important;
    font-size: 11px !important;
    color: var(--text-muted) !important;
    max-width: 100px !important;
    overflow: hidden !important;
  }
  
  .benchmark-list-item .list-item-contact span {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  
  .benchmark-list-item .list-item-contact .contact-avatar-small,
  .benchmark-list-item .list-item-contact .contact-avatar-fallback-small {
    width: 16px !important;
    height: 16px !important;
    font-size: 7px !important;
  }
  
  /* Right side - Status and photos */
  .benchmark-list-item .list-item-status {
    flex-shrink: 0 !important;
    font-size: 8px !important;
    padding: 4px 6px !important;
    position: static !important;
  }
  
  .benchmark-list-item .list-item-parts,
  .benchmark-list-item .list-item-time {
    display: none !important;
  }
  
  .benchmark-list-item .list-item-photos {
    flex-shrink: 0 !important;
    font-size: 10px !important;
    color: #9CA3AF !important;
  }
  
  .list-item-meta {
    display: none !important;
  }
  
  /* ============ SELECT MODE ============ */
  body.select-mode .benchmark-list-item {
    padding-left: 52px !important;
  }
  
  body.select-mode .benchmark-list-item .select-checkbox {
    left: 14px !important;
  }
  
  body.select-mode .benchmark-list-item .list-item-id {
    left: 56px !important;
  }
  
  /* Bulk actions bar - mobile */
  .bulk-actions-bar {
    flex-direction: column !important;
    padding: 16px !important;
    gap: 12px !important;
    padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
  }
  
  .bulk-actions-bar .selected-info {
    width: 100% !important;
    justify-content: center !important;
  }
  
  .bulk-actions-bar .bulk-buttons {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 10px !important;
  }
  
  .bulk-actions-bar button {
    padding: 14px 10px !important;
    font-size: 11px !important;
  }
  
  body.select-mode .main-container {
    padding-bottom: 130px !important;
  }

  /* ============================================================
     MODALS - FULL SCREEN WITH SCROLLING
     ============================================================ */
  
  /* Critical: allow overflow on dialog */
  dialog {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    transform: none !important;
    overflow: visible !important;
  }
  
  dialog[open] {
    display: flex !important;
    flex-direction: column !important;
  }
  
  dialog::backdrop {
    background: rgba(0, 0, 0, 0.5) !important;
  }
  
  /* Modal Header */
  dialog .modal-header {
    flex: 0 0 auto !important;
    padding: 12px 16px !important;
    background: #F8FAFC !important;
    border-bottom: 2px solid var(--text-main) !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    min-height: 54px !important;
    z-index: 10 !important;
  }
  
  dialog .modal-header h3 {
    font-size: 13px !important;
    font-weight: 700 !important;
    margin: 0 !important;
    flex: 1 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    padding-right: 10px !important;
  }
  
  dialog .modal-header .btn-secondary,
  dialog .modal-header button {
    padding: 8px 12px !important;
    font-size: 18px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    background: #E2E8F0 !important;
    border: none !important;
    border-radius: 6px !important;
  }
  
  /* Modal Body - THIS IS THE KEY SCROLL FIX */
  dialog .modal-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    padding: 16px !important;
    padding-bottom: 100px !important;
    width: 100% !important;
  }
  
  /* Override inline styles on modal body */
  dialog .modal-body[style*="width"],
  dialog .modal-body[style*="max-height"],
  dialog .modal-body[style*="overflow"] {
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    overflow-y: auto !important;
  }
  
  /* Form sections */
  dialog .form-section {
    margin-bottom: 16px !important;
    padding: 14px !important;
    background: #F8FAFC !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
  }
  
  dialog .form-section h4 {
    font-size: 11px !important;
    margin-bottom: 12px !important;
    padding-bottom: 8px !important;
    border-bottom: 1px solid var(--border-color) !important;
  }
  
  /* Grid layouts - stack */
  dialog .grid-2,
  dialog .grid-3,
  dialog .grid-4 {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }
  
  dialog [style*="grid-column: span"],
  dialog [style*="grid-column:span"] {
    width: 100% !important;
  }
  
  dialog [style*="display: grid"],
  dialog [style*="display:grid"] {
    display: flex !important;
    flex-direction: column !important;
  }
  
  /* Inputs */
  dialog .input,
  dialog select,
  dialog textarea {
    padding: 14px 12px !important;
    font-size: 16px !important;
    min-height: 48px !important;
    border-radius: 6px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  
  dialog textarea {
    min-height: 80px !important;
  }
  
  /* Labels */
  dialog .detail-label {
    font-size: 10px !important;
    margin-bottom: 4px !important;
    color: #64748B !important;
    display: block !important;
  }
  
  /* Buttons */
  dialog .btn,
  dialog .btn-secondary,
  dialog .btn-danger {
    padding: 14px 16px !important;
    font-size: 13px !important;
    min-height: 48px !important;
    border-radius: 6px !important;
  }
  
  /* ============ BENCHMARK DETAIL MODAL ============ */
  #benchmarkModal .modal-body > div {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
  }
  
  /* Status bar */
  #benchmarkModal .modal-body > div > div[style*="display: flex"][style*="justify-content: space-between"]:first-child {
    flex-direction: column !important;
    gap: 12px !important;
  }
  
  #benchmarkModal .modal-body > div > div:first-child > div:last-child {
    display: flex !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
  }
  
  #benchmarkModal .modal-body > div > div:first-child > div:last-child button,
  #benchmarkModal .modal-body > div > div:first-child > div:last-child .btn-secondary {
    flex: 1 !important;
    min-width: 100px !important;
  }
  
  /* Footer actions */
  #benchmarkModal .modal-body > div > div:last-child[style*="display: flex"][style*="justify-content"] {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 14px 16px !important;
    padding-bottom: max(14px, env(safe-area-inset-bottom)) !important;
    background: white !important;
    border-top: 1px solid var(--border-color) !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08) !important;
    z-index: 100 !important;
    margin: 0 !important;
    gap: 10px !important;
  }
  
  #benchmarkModal .modal-body > div > div:last-child button {
    flex: 1 !important;
  }
  
  /* ============ STATUS MODAL ============ */
  #statusModal .modal-body {
    padding-bottom: 130px !important;
  }
  
  #statusModal .modal-body > div[style*="display: flex"][style*="justify-content"]:last-child {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 14px 16px !important;
    padding-bottom: max(14px, env(safe-area-inset-bottom)) !important;
    background: white !important;
    border-top: 1px solid var(--border-color) !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08) !important;
    z-index: 100 !important;
    margin: 0 !important;
    gap: 10px !important;
  }
  
  #statusModal .modal-body > div:last-child button {
    flex: 1 !important;
    min-height: 48px !important;
  }
  
  /* ============ NEW BENCHMARK MODAL ============ */
  #newBenchmarkModal .modal-body {
    padding-bottom: 100px !important;
  }
  
  #newBenchmarkModal form {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
  }
  
  .batch-row {
    padding: 14px !important;
    border-radius: 8px !important;
    position: relative !important;
  }
  
  .batch-row .remove-batch-btn {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    font-size: 18px !important;
    background: #FEE2E2 !important;
    color: #DC2626 !important;
    border: none !important;
    border-radius: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  #newBenchmarkModal .modal-body > div[style*="margin-top"]:last-child {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 14px 16px !important;
    padding-bottom: max(14px, env(safe-area-inset-bottom)) !important;
    background: white !important;
    border-top: 1px solid var(--border-color) !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08) !important;
    z-index: 100 !important;
    margin: 0 !important;
  }
  
  #newBenchmarkModal #saveBenchmarkBtn {
    width: 100% !important;
    min-height: 52px !important;
  }
  
  /* ============ PHOTO MODAL ============ */
  #photoModal .modal-body {
    padding-bottom: 130px !important;
  }
  
  #photoModal .modal-body > div[style*="display: flex"]:last-child {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 14px 16px !important;
    padding-bottom: max(14px, env(safe-area-inset-bottom)) !important;
    background: white !important;
    border-top: 1px solid var(--border-color) !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08) !important;
    z-index: 100 !important;
    margin: 0 !important;
    gap: 10px !important;
  }
  
  #photoModal .modal-body > div:last-child button {
    flex: 1 !important;
  }
  
  #photoFiles {
    padding: 16px !important;
    border: 2px dashed #CBD5E1 !important;
    border-radius: 8px !important;
    background: #F8FAFC !important;
  }
  
  /* ============ SPLIT BATCH MODAL ============ */
  #splitBatchModal {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  #splitBatchModal .modal-body,
  #splitBatchModal > div:nth-child(2),
  #splitBatchModal > div[style*="padding: 24px"],
  #splitBatchModal > div[style*="width: 500px"] {
    width: 100% !important;
    max-width: 100% !important;
    padding: 16px !important;
    padding-bottom: 120px !important;
    box-sizing: border-box !important;
  }
  
  /* Split modal header */
  #splitBatchModal > div:first-child,
  #splitBatchModal > div[style*="border-bottom"] {
    padding: 14px 16px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
  }
  
  #splitBatchModal > div:first-child h3 {
    font-size: 14px !important;
  }
  
  #splitBatchModal > div:first-child button,
  #splitBatchModal > div:first-child .btn-secondary {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  /* Split rows container */
  #splitRows {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
  }
  
  /* Individual split row - OVERRIDE INLINE GRID */
  .split-row,
  .split-row[style],
  #splitRows > .split-row,
  #splitRows > div.split-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    padding: 16px !important;
    padding-top: 40px !important;
    background: #F8FAFC !important;
    border: 1px solid #E2E8F0 !important;
    border-radius: 8px !important;
    position: relative !important;
    grid-template-columns: none !important;
  }
  
  /* All divs inside split row should be full width */
  .split-row > div,
  .split-row[style] > div {
    width: 100% !important;
    flex: none !important;
  }
  
  /* Labels in split row */
  .split-row .detail-label,
  .split-row label {
    font-size: 10px !important;
    text-transform: uppercase !important;
    color: #64748B !important;
    margin-bottom: 6px !important;
    display: block !important;
  }
  
  /* Inputs in split row */
  .split-row input,
  .split-row .input,
  .split-row input.split-qty,
  .split-row input.split-desc {
    width: 100% !important;
    padding: 14px 12px !important;
    font-size: 16px !important;
    border: 1px solid #E2E8F0 !important;
    border-radius: 6px !important;
    box-sizing: border-box !important;
    min-height: 48px !important;
  }
  
  /* Remove button - absolute positioned */
  .split-row > button,
  .split-row > button.btn-secondary,
  .split-row > button[onclick*="remove"],
  .split-row > button[title="Remove"] {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 18px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #FEE2E2 !important;
    color: #DC2626 !important;
    border: none !important;
    border-radius: 6px !important;
  }
  
  /* Add split button row */
  #splitBatchContent > div[style*="display: flex"][style*="justify-content: space-between"] {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: stretch !important;
  }
  
  #splitBatchContent > div[style*="display: flex"][style*="justify-content: space-between"] button {
    width: 100% !important;
  }
  
  #splitBatchContent > div[style*="display: flex"][style*="justify-content: space-between"] #splitTotalDisplay {
    text-align: center !important;
    padding: 8px !important;
    background: #F1F5F9 !important;
    border-radius: 6px !important;
  }
  
  /* Bottom buttons - fixed */
  #splitBatchContent > div:last-child[style*="display: flex"][style*="justify-content: flex-end"],
  #splitBatchContent > div[style*="border-top"][style*="padding-top"] {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 14px 16px !important;
    padding-bottom: max(14px, env(safe-area-inset-bottom)) !important;
    background: white !important;
    border-top: 1px solid var(--border-color) !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08) !important;
    z-index: 100 !important;
    margin: 0 !important;
    gap: 10px !important;
    justify-content: stretch !important;
  }
  
  #splitBatchContent > div:last-child button {
    flex: 1 !important;
    min-height: 48px !important;
  }
  
  /* ============ BATCH CARDS IN DETAIL ============ */
  .batch-card {
    border-radius: 8px !important;
    overflow: hidden !important;
  }
  
  .batch-card > div:nth-child(2) {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  
  .batch-card > div:nth-child(2) > div {
    flex: 1 1 45% !important;
    min-width: 80px !important;
  }
  
  /* ============ LOADING OVERLAY ============ */
  #loadingOverlay[open] {
    background: rgba(255, 255, 255, 0.95) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  /* ============ REPORT SECTION ============ */
  .report-section > div:last-child {
    flex-direction: column !important;
  }
  
  .report-section > div:last-child a,
  .report-section > div:last-child button {
    width: 100% !important;
    text-align: center !important;
  }
  
  /* ============ TOAST ============ */
  div[style*="position: fixed"][style*="bottom: 20px"][style*="right: 20px"] {
    left: 16px !important;
    right: 16px !important;
    bottom: 100px !important;
    max-width: none !important;
  }
}

/* ============ SMALL PHONES ============ */
@media (max-width: 375px) {
  .main-container {
    padding: 10px !important;
  }
  
  .page-title {
    font-size: 14px !important;
  }
  
  .benchmark-list-item {
    min-height: 65px !important;
    max-height: 65px !important;
    height: 65px !important;
    padding: 12px 14px !important;
  }
  
  .benchmark-list-item .list-item-company {
    font-size: 13px !important;
  }
  
  dialog .modal-body {
    padding: 12px !important;
    padding-bottom: 110px !important;
  }
}

/* ============ SAFE AREA ============ */
@supports (padding: max(0px)) {
  @media (max-width: 768px) {
    .header {
      padding-top: max(8px, env(safe-area-inset-top)) !important;
    }
  }
}

/* ============ TABLETS ============ */
@media (min-width: 769px) and (max-width: 1024px) {
  .filters-grid {
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
  }
  
  .items-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
  
  .benchmark-list-item {
    grid-template-columns: 120px 1.5fr 1fr 100px 80px 80px;
  }
}

/* ============ DESKTOP ============ */
@media (min-width: 769px) {
  .filters-toggle,
  .filters-content,
  .mobile-filters,
  .stats-mini {
    display: none !important;
  }
  
  .filters-grid {
    display: grid !important;
  }
  
  .filters-section {
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
    padding: 16px !important;
  }
  
  .stats-row {
    display: flex !important;
  }
  
  .list-item-meta {
    display: none !important;
  }
  
  .items-grid {
    display: grid !important;
  }
  
  .benchmark-card {
    display: block !important;
  }
  
  /* HIDE LIST ITEMS ON DESKTOP - only show cards */
  .benchmark-list-item {
    display: none !important;
  }
}
