/* ============================================
   THEME VARIABLES
   ============================================ */

:root {
  /* Light Theme (Default) */
  --color-bg-primary: #f5f7fa;
  --color-bg-secondary: #ffffff;
  --color-bg-tertiary: #f9f9f9;
  --color-bg-hover: #f0f0f0;
  
  --color-text-primary: #333333;
  --color-text-secondary: #666666;
  --color-text-tertiary: #999999;
  --color-text-inverse: #ffffff;
  
  --color-border: #e0e0e0;
  --color-border-light: #ddd;
  --color-border-hover: #d32f2f;
  
  --color-brand-primary: #d32f2f;
  --color-brand-secondary: #b71c1c;
  --color-brand-dark: #8b0000;
  --color-brand-light: #f44336;
  --color-brand-lighter: #ffebee;
  
  --color-success: #4caf50;
  --color-success-light: #e8f5e9;
  --color-success-dark: #2e7d32;
  --color-warning: #ff9800;
  --color-warning-bg: #fff3cd;
  --color-warning-light: #fff3e0;
  --color-warning-dark: #e65100;
  --color-error: #f44336;
  --color-error-light: #ffebee;
  --color-error-dark: #c62828;
  --color-info: #2196f3;
  
  --color-shadow: rgba(0, 0, 0, 0.1);
  --color-shadow-medium: rgba(0, 0, 0, 0.2);
  --color-shadow-strong: rgba(0, 0, 0, 0.5);
  --color-shadow-hover: rgba(211, 47, 47, 0.1);
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%);
  --gradient-bg: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.dark-theme {
  /* Dark Theme */
  --color-bg-primary: #121212;
  --color-bg-secondary: #1e1e1e;
  --color-bg-tertiary: #2a2a2a;
  --color-bg-hover: #333333;
  
  --color-text-primary: #e0e0e0;
  --color-text-secondary: #b0b0b0;
  --color-text-tertiary: #808080;
  --color-text-inverse: #121212;
  
  --color-border: #404040;
  --color-border-light: #505050;
  --color-border-hover: #ff5252;
  
  --color-brand-primary: #ff5252;
  --color-brand-secondary: #ff1744;
  --color-brand-dark: #ff6e6e;
  --color-brand-light: #ff6e6e;
  --color-brand-lighter: #3d1f1f;
  
  --color-success: #66bb6a;
  --color-success-light: #1b3a1c;
  --color-success-dark: #81c784;
  --color-warning: #ffa726;
  --color-warning-bg: #3d3500;
  --color-warning-light: #3d2e1a;
  --color-warning-dark: #ffb74d;
  --color-error: #ef5350;
  --color-error-light: #3d1f1f;
  --color-error-dark: #f44336;
  --color-info: #42a5f5;
  
  --color-shadow: rgba(0, 0, 0, 0.3);
  --color-shadow-medium: rgba(0, 0, 0, 0.5);
  --color-shadow-strong: rgba(0, 0, 0, 0.8);
  --color-shadow-hover: rgba(255, 82, 82, 0.2);
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #ff5252 0%, #ff1744 100%);
  --gradient-bg: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============================================
   OFFLINE PAGE SPECIFIC STYLES
   ============================================ */

.offline-page {
  background: var(--gradient-bg);
  color: var(--color-text-primary);
}

.offline-page .offline-container {
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  border-radius: 16px;
  box-shadow: 0 15px 35px var(--color-shadow);
}

/* Performance: Optimize animations and smooth theme transitions */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Smooth theme transitions - exclude transform and other performance-critical properties */
*:not(.no-transition) {
  transition: background-color 0.3s ease, 
              color 0.3s ease, 
              border-color 0.3s ease,
              box-shadow 0.3s ease,
              fill 0.3s ease,
              stroke 0.3s ease;
}

/* Disable transitions for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* Theme Toggle Button */
.theme-toggle {
  background: var(--color-bg-secondary);
  border: 2px solid var(--color-border);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-left: 12px;
  position: relative;
}

.theme-toggle:hover {
  border-color: var(--color-brand-primary);
  transform: scale(1.1);
  box-shadow: 0 4px 12px var(--color-shadow-hover);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-icon {
  font-size: 20px;
  position: absolute;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.theme-icon-light {
  opacity: 1;
  transform: rotate(0deg);
}

.theme-icon-dark {
  opacity: 0;
  transform: rotate(180deg);
}

.dark-theme .theme-icon-light {
  opacity: 0;
  transform: rotate(180deg);
}

.dark-theme .theme-icon-dark {
  opacity: 1;
  transform: rotate(0deg);
}

/* Mobile responsiveness for theme toggle - WCAG 2.1 compliance */
@media (max-width: 480px) {
  .theme-toggle {
    width: 44px;
    height: 44px;
  }
  
  .theme-icon {
    font-size: 18px;
  }
}

/* Skip Navigation Link for Accessibility */
.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    background: var(--color-brand-primary);
    color: var(--color-text-inverse);
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 8px 0;
    font-weight: 600;
}

.skip-link:focus {
    position: absolute;
    left: 0;
    top: 0;
    width: auto;
    height: auto;
    overflow: visible;
    min-height: 44px;
    display: flex;
    align-items: center;
}

/* ============================================
   TOUCH TARGET UTILITIES - WCAG 2.1 Level AA (44x44px minimum)
   ============================================ */

/* Base touch target class */
.touch-target {
    min-height: 44px;
    min-width: 44px;
}

/* Button touch targets */
.touch-target-btn {
    min-height: 44px;
    padding: 12px 20px;
}

/* Input field touch targets */
.touch-target-input {
    min-height: 44px;
    padding: 10px 12px;
}

/* Icon button touch targets */
.touch-target-icon {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Checkbox and radio touch targets */
.touch-target-checkbox,
.touch-target-radio {
    min-height: 44px;
    min-width: 44px;
    cursor: pointer;
}

/* Link touch targets */
.touch-target-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 10px 12px;
}

/* ============================================
   GLOBAL INTERACTIVE ELEMENT TOUCH TARGETS
   ============================================ */

/* All buttons */
button,
.btn,
input[type="submit"],
input[type="button"],
input[type="reset"] {
    min-height: 44px;
    min-width: 44px;
}

/* All form inputs */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
select,
textarea {
    min-height: 44px;
}

/* Radio and checkbox inputs */
input[type="checkbox"],
input[type="radio"] {
    min-height: 20px;
    min-width: 20px;
    cursor: pointer;
}

/* Radio and checkbox wrappers for larger touch area */
.radio-wrapper,
.checkbox-wrapper,
.par-option {
    min-height: 44px;
    padding: 12px;
    display: inline-flex;
    align-items: center;
}

/* ============================================
   CHIP, TAG, BADGE TOUCH TARGETS - WCAG 2.1 AA
   ============================================ */

/* Base chip styles - ensure WCAG 2.1 AA 44px touch target */
.chip,
.filter-chip,
.tag,
.badge,
.status-chip {
    min-height: 44px;
    padding: 10px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 22px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

/* Chip container styles - prevent horizontal overflow */
.filter-chips,
.chips-container,
.stats-cards,
.stats-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 100%;
    box-sizing: border-box;
}

/* Stats card base styles */
.stats-card {
    min-height: 44px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    border-radius: 10px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    box-sizing: border-box;
}

/* Touch targets for navigation and button-style links only */
nav a,
.nav-link,
.btn-link,
a.btn,
a.button,
.navigation a,
.menu a,
.tab-link,
a[role="button"],
a.action-link,
.btn-nav {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 10px 12px;
}

/* Icon links - square touch target */
a.icon-link,
a.icon-btn,
a[aria-label*="delete"],
a[aria-label*="edit"],
a[aria-label*="view"] {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Inline content links - NO touch target enforcement */
p a,
li a:not(.nav-link):not(.btn-link),
.content a,
.text a,
span a {
    /* Normal inline link behavior */
    min-height: auto;
    display: inline;
    padding: 0;
}

/* Icon-only buttons */
.icon-button,
.icon-btn,
.btn-icon {
    min-height: 44px;
    min-width: 44px;
    padding: 10px;
}

/* Close buttons */
.close,
.close-btn,
.modal-close,
button[aria-label*="close"],
button[aria-label*="Close"] {
    min-height: 44px;
    min-width: 44px;
}

/* Action buttons in tables */
.action-btn,
.delete-btn,
.edit-btn,
.view-btn,
.btn-action {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 12px;
}

/* Tab navigation */
.tab,
.tab-button,
.tab-link,
[role="tab"] {
    min-height: 44px;
    padding: 12px 20px;
}

/* Dropdown toggle buttons */
.dropdown-toggle,
select {
    min-height: 44px;
}

/* File upload buttons */
input[type="file"] {
    min-height: 44px;
}

.file-upload-btn,
.upload-btn {
    min-height: 44px;
    padding: 12px 20px;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

.spinner-dark {
    border: 3px solid rgba(0,0,0,0.1);
    border-top-color: var(--color-brand-primary);
}

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

/* Loading State for Buttons */
.btn.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.btn.loading::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.loading-spinner-large {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s linear infinite;
}

/* Offline Banner - Network Status Indicator */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--color-brand-primary);
    color: var(--color-text-inverse);
    padding: 12px 20px;
    text-align: center;
    font-weight: 600;
    box-shadow: 0 2px 8px var(--color-shadow-medium);
    z-index: 1050;
    transform: translateY(-100%);
    transition: transform 0.3s ease, background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 14px;
}

.offline-banner.show {
    transform: translateY(0);
}

.offline-banner.online {
    background: var(--color-success);
}

.offline-banner.slow {
    background: var(--color-warning);
}

.offline-banner .banner-icon {
    font-size: 18px;
    line-height: 1;
}

.offline-banner .banner-message {
    flex: 1;
    max-width: 600px;
}

.offline-banner .banner-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

/* Offline state indicators for disabled elements */
.offline-disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
    position: relative;
}

.offline-disabled::after {
    content: attr(data-offline-message);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    margin-bottom: 5px;
    z-index: 1000;
}

.offline-disabled:hover::after {
    opacity: 1;
}

/* Read-only mode indicator */
.readonly-mode {
    position: relative;
    opacity: 0.7;
}

.readonly-indicator {
    display: inline-block;
    background: var(--color-warning);
    color: var(--color-text-inverse);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
}

/* Connection status badge */
.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.connection-status.online {
    background: var(--color-success-light);
    color: var(--color-success-dark);
}

.connection-status.offline {
    background: var(--color-error-light);
    color: var(--color-error-dark);
}

.connection-status.slow {
    background: var(--color-warning-light);
    color: var(--color-warning-dark);
}

.connection-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

/* Accessibility: Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border-width: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--gradient-bg);
    color: var(--color-text-primary);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

.header {
    background: var(--color-brand-primary);
    color: var(--color-text-inverse);
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px var(--color-shadow);
    margin-bottom: 2rem;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo {
    height: 50px;
    width: auto;
    border-radius: 12px;
}

.header h1 {
    font-size: 24px;
    margin: 0;
}

.btn {
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-secondary {
    background: rgba(255,255,255,0.2);
    color: var(--color-text-inverse);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.3);
}

#storeUserInfo {
    color: var(--color-text-inverse);
    font-weight: 600;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 20px 20px;
}

.logo-container {
    text-align: center;
    padding: 30px 0 20px 0;
    position: relative;
    z-index: 10;
    background: var(--gradient-primary);
    box-shadow: 0 4px 8px var(--color-shadow);
}

.logo {
    max-width: 200px;
    height: auto;
    display: block;
    margin: 0 auto;
}

header {
    text-align: center;
    background: var(--gradient-primary);
    color: var(--color-text-inverse);
    padding: 20px 30px 30px 30px;
    margin-bottom: 30px;
    position: relative;
    z-index: 1100;
    box-shadow: 0 4px 8px var(--color-shadow);
}

.admin-login-btn {
    position: fixed;
    top: 30px;
    right: 15px;
    background: var(--color-brand-primary);
    color: var(--color-text-inverse);
    border: 2px solid var(--color-brand-secondary);
    padding: 8px 16px;
    border-radius: 12px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-block;
    z-index: 1000;
    box-shadow: 0 2px 8px var(--color-shadow-medium);
}

.admin-login-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    font-size: 1.2em;
    opacity: 0.9;
}

.store-selection {
    background: var(--color-bg-secondary);
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 4px 20px var(--color-shadow);
    margin-bottom: 30px;
    border: 1px solid var(--color-border);
}

.store-selection label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    font-size: 1.1em;
}

.store-selection input {
    width: 100%;
    max-width: 300px;
    padding: 12px;
    border: 2px solid var(--color-border-light);
    border-radius: 10px;
    font-size: 16px;
    margin-right: 15px;
    min-height: 44px;
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
}

.store-selection input:focus {
    outline: none;
    border-color: var(--color-brand-primary);
}

.store-selection button, .submit-btn {
    background: var(--color-brand-primary);
    color: var(--color-text-inverse);
    border: none;
    padding: 12px 25px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background 0.3s;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.store-selection button:hover, .submit-btn:hover {
    background: var(--color-brand-secondary);
}

.store-selection button:active, .submit-btn:active {
    background: var(--color-brand-dark);
    transform: scale(0.98);
}

.store-selection button:disabled, .submit-btn:disabled,
.acknowledge-btn:disabled {
    background: var(--color-border);
    color: var(--color-text-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

.store-selection button:focus, .submit-btn:focus,
.acknowledge-btn:focus {
    outline: 3px solid var(--color-brand-primary);
    outline-offset: 2px;
}

.store-info, .order-form {
    background: var(--color-bg-secondary);
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 4px 20px var(--color-shadow);
    margin-bottom: 30px;
    border: 1px solid var(--color-border);
}

.hidden {
    display: none;
}

.manager-acknowledgement {
    background: var(--color-bg-secondary);
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 2px 10px var(--color-shadow);
    margin-bottom: 30px;
    border: 2px solid var(--color-brand-primary);
}

.manager-acknowledgement h2 {
    font-size: 1.8em;
    color: var(--color-brand-primary);
    margin-bottom: 20px;
    text-align: center;
}

.acknowledgement-content {
    text-align: center;
}

.acknowledgement-content p {
    font-size: 1em;
    margin-bottom: 10px;
    line-height: 1.4;
    color: var(--color-text-primary);
}

.name-input-section {
    margin: 20px 0;
}

.name-input-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--color-text-primary);
}

.name-input-section input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--color-border-light);
    border-radius: 10px;
    font-size: 16px;
    box-sizing: border-box;
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    min-height: 44px;
}

.name-input-section input:focus {
    outline: none;
    border-color: var(--color-brand-primary);
}

.acknowledge-btn {
    background: var(--color-brand-primary);
    color: var(--color-text-inverse);
    border: none;
    padding: 12px 30px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background 0.3s;
    display: block;
    margin: 20px auto 0;
    min-height: 44px;
}

.acknowledge-btn:hover {
    background: var(--color-brand-secondary);
}

.acknowledge-btn:active {
    background: var(--color-brand-dark);
    transform: scale(0.98);
}

/* Par Type Card Grid Layout - WCAG 2.1 AA Responsive */
.par-type-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(min(140px, 100%), 1fr));
    gap: 20px;
    margin: 20px auto;
    max-width: min(900px, 100%);
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Individual Par Type Card */
.par-type-card {
    background: var(--color-bg-secondary);
    border: 3px solid var(--color-border);
    border-radius: 16px;
    padding: 25px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--color-shadow);
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.par-type-card:hover {
    border-color: var(--color-brand-primary);
    box-shadow: 0 4px 12px var(--color-shadow-hover);
    transform: translateY(-3px);
}

.par-type-card.selected {
    border-color: var(--color-brand-primary);
    background: var(--color-brand-lighter);
}

.par-type-card h3 {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--color-text-primary);
    margin: 0 0 10px 0;
}

.par-type-card p {
    font-size: 0.95em;
    color: var(--color-text-secondary);
    margin: 0 0 15px 0;
}

.par-type-icon {
    font-size: 3em;
    margin-top: auto;
}

/* Legacy radio button styles (kept for backward compatibility) */
.par-options {
    margin: 20px 0;
}

.par-option {
    margin: 15px 0;
    display: flex;
    align-items: center;
}

.par-option input[type="radio"] {
    margin-right: 10px;
    transform: scale(1.5);
    min-width: 24px;
    min-height: 24px;
    cursor: pointer;
}

.par-option label {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--color-text-primary);
    cursor: pointer;
}

.vendor-credit-buttons {
    display: inline-flex;
    gap: 10px;
    margin: 20px auto;
    flex-wrap: wrap;
    justify-content: center;
    width: auto;
}

.vendor-credit-buttons .acknowledge-btn {
    flex: 0 0 auto;
    min-width: 160px;
    max-width: 200px;
    padding: 12px 16px;
    font-size: 0.95em;
    text-align: center;
    white-space: normal;
    line-height: 1.3;
}

@media (max-width: 768px) {
    .vendor-credit-buttons {
        flex-direction: column;
    }
    
    .vendor-credit-buttons .acknowledge-btn {
        width: 100%;
    }
    
    /* Par type cards responsive - stack on mobile */
    .par-type-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        max-width: 100%;
    }
    
    .par-type-card {
        min-height: 160px;
        padding: 20px;
    }
    
    .par-type-card h3 {
        font-size: 1.1em;
    }
    
    .par-type-icon {
        font-size: 2.5em;
    }
}

.filter-controls {
    background: #f9f9f9;
    background: var(--color-bg-tertiary, #f9f9f9);
    padding: 20px;
    border-radius: 14px;
    margin: 30px 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: 20px;
    width: 100%;
    box-sizing: border-box;
}

.filter-controls label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

.filter-controls select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    min-height: 44px;
}

.order-form h2 {
    font-size: 2em;
    color: #d32f2f;
    margin-bottom: 20px;
    text-align: center;
}

.vendor-sheets-container {
    margin: 30px 0;
}

.vendor-sheet {
    background: white;
    border: 2px solid #d32f2f;
    border-radius: 14px;
    margin-bottom: 35px;
    overflow: hidden;
}

.vendor-header {
    background: #d32f2f;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.vendor-header h5 {
    margin: 0;
    font-size: 1.3em;
}

.delivery-days {
    font-size: 0.9em;
    opacity: 0.9;
}

.vendor-categories {
    padding: 20px;
}

.invoice-section {
    margin-bottom: 40px;
}

.invoice-header {
    background: #d32f2f;
    color: white;
    padding: 15px 20px;
    border-radius: 14px;
    margin-bottom: 30px;
    font-weight: bold;
    font-size: 1.3em;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.subcategories-container {
    padding-left: 15px;
}

.category-section {
    margin-bottom: 25px;
}

.category-header {
    background: #f5f5f5;
    padding: 12px 15px;
    border-radius: 14px;
    margin-bottom: 15px;
    font-weight: bold;
    color: #d32f2f;
    font-size: 1.1em;
    border-left: 4px solid #d32f2f;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    gap: 12px;
    max-width: 100%;
    box-sizing: border-box;
}

.item-card {
    border: 2px solid #ddd;
    border-radius: 16px;
    padding: 15px;
    background: #f9f9f9;
    transition: border-color 0.3s;
    display: flex;
    flex-direction: column;
    position: relative;
}

.item-card:hover {
    border-color: #d32f2f;
}

.item-number {
    position: absolute;
    top: 5px;
    right: 8px;
    background: #d32f2f;
    color: white;
    font-size: 0.7em;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
    min-width: 14px;
    text-align: center;
}

.item-card h5 {
    color: #d32f2f;
    margin-bottom: 8px;
    font-size: 1.1em;
    line-height: 1.3;
}

.item-details {
    margin-bottom: 12px;
    font-size: 0.85em;
    color: #666;
    flex-grow: 1;
}

.item-details p {
    margin-bottom: 4px;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
}

.quantity-controls input {
    width: 100%;
    max-width: 100px;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 10px;
    text-align: center;
    font-size: 16px;
    min-height: 44px;
}

/* ============================================
   QUANTITY WARNING SYSTEM
   ============================================ */

/* Warning indicator for quantity inputs */
.quantity-input.has-warning {
    border-color: #ff9800 !important;
    background-color: var(--color-warning-light);
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.1);
}

.quantity-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-top: 6px;
    background-color: var(--color-warning-bg);
    border: 1px solid var(--color-warning);
    border-radius: 8px;
    font-size: 0.875rem;
    color: #856404;
    animation: slideDown 0.3s ease;
}

.dark-theme .quantity-warning {
    background-color: var(--color-warning-light);
    color: var(--color-warning-dark);
}

.quantity-warning .warning-icon {
    font-size: 1.2em;
    flex-shrink: 0;
}

.quantity-warning .warning-text {
    flex: 1;
    line-height: 1.4;
}

.quantity-warning strong {
    font-weight: 700;
    color: var(--color-warning-dark);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .quantity-warning {
        font-size: 0.8rem;
        padding: 6px 10px;
    }
    
    .quantity-warning .warning-icon {
        font-size: 1.1em;
    }
}

.order-summary {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 14px;
    margin: 30px 0;
}

.summary-content {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.summary-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 15px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #ddd;
}

.item-name {
    font-weight: 500;
    color: #333;
}

.item-quantity {
    font-weight: 600;
    color: #666;
    text-align: center;
    min-width: 80px;
}

.item-total {
    font-weight: 600;
    color: #d32f2f;
    text-align: right;
    min-width: 70px;
}

.total {
    text-align: right;
    font-size: 1.3em;
    color: #d32f2f;
    border-top: 2px solid #d32f2f;
    padding-top: 15px;
}

.submit-btn {
    width: 100%;
    padding: 15px;
    font-size: 1.2em;
    margin-top: 20px;
}

.message {
    padding: 15px;
    border-radius: 10px;
    margin: 20px 0;
    font-weight: bold;
}

.message.success {
    background: #c8e6c9;
    color: #2e7d32;
    border: 1px solid #4caf50;
}

.message.error {
    background: #ffcdd2;
    color: #c62828;
    border: 1px solid #f44336;
}

.date-container {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
}

.order-date, .delivery-date {
    flex: 1;
}

.order-date label, .delivery-date label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

.order-date input, .delivery-date input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    box-sizing: border-box;
    min-height: 44px;
}

/* Mobile-First Responsive Design */

/* Very small phones (320px - 374px) */
@media (max-width: 374px) {
    body {
        font-size: 14px;
    }
    
    .header {
        padding: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .header h1 {
        font-size: 14px;
    }
    
    .header-logo {
        height: 32px;
    }
    
    .container {
        padding: 8px;
    }
    
    .store-selection,
    .manager-acknowledgement,
    .store-info,
    .order-form {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .logo {
        max-width: 100px;
    }
    
    .items-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    
    .item-card {
        padding: 12px;
    }
    
    .quantity-controls {
        flex-direction: column;
        gap: 6px;
    }
    
    .quantity-controls label {
        font-size: 14px;
    }
    
    .quantity-controls input {
        max-width: 100%;
    }
    
    .vendor-credit-buttons {
        gap: 10px;
    }
    
    .vendor-credit-buttons .acknowledge-btn {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    .filter-controls {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 15px;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 12px;
    }
}

/* Small phones (375px - 480px) */
@media (min-width: 375px) and (max-width: 480px) {
    body {
        font-size: 15px;
    }
    
    .header {
        padding: 0.5rem 0.75rem;
    }
    
    .header h1 {
        font-size: 16px;
    }
    
    .header-logo {
        height: 35px;
    }
    
    .container {
        padding: 10px;
    }
    
    .logo {
        max-width: 120px;
    }
    
    .items-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }
    
    .quantity-controls {
        flex-wrap: wrap;
    }
    
    .filter-controls {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* All phones (max-width: 480px) */
@media (max-width: 480px) {
    input, select, textarea, button {
        font-size: 16px !important; /* Prevent zoom on iOS */
    }
    
    .order-summary-item {
        font-size: 13px;
        padding: 8px;
    }
    
    .total-display {
        font-size: 18px;
    }
    
    .store-selection {
        text-align: center;
    }
    
    .store-selection input {
        width: 100%;
        max-width: 100%;
        margin-right: 0;
        margin-bottom: 15px;
    }
    
    .store-selection button {
        width: 100%;
    }
    
    .date-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .vendor-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .vendor-header h5 {
        font-size: 1.1em;
    }
    
    .delivery-days {
        font-size: 0.85em;
    }
    
    .category-header {
        padding: 10px 12px;
        font-size: 1em;
    }
    
    .invoice-header {
        padding: 12px 15px;
        font-size: 1.1em;
    }
    
    .item-card h5 {
        font-size: 1em;
    }
    
    .item-details {
        font-size: 0.8em;
    }
    
    .par-option {
        margin: 12px 0;
        padding: 8px 0;
    }
    
    .par-option label {
        font-size: 1em;
    }
    
    .acknowledge-btn,
    .submit-btn {
        width: 100%;
        padding: 14px 20px;
    }
    
    .message {
        padding: 12px;
        font-size: 14px;
    }
    
    /* Ensure proper spacing between interactive elements */
    .par-option + .par-option {
        margin-top: 15px;
    }
    
    /* Stack vendor credit buttons vertically */
    .vendor-credit-buttons {
        flex-direction: column;
        gap: 12px;
    }
    
    .vendor-credit-buttons .acknowledge-btn {
        width: 100%;
        min-width: auto;
    }
}

/* ============================================
   TABLET PORTRAIT BREAKPOINT (481px - 768px)
   iPad Mini, iPad Air, Android tablets - Portrait
   WCAG 2.1 AA Compliant Touch Targets
   ============================================ */
@media (min-width: 481px) and (max-width: 768px) {
    /* === GLOBAL OVERFLOW PREVENTION === */
    body {
        overflow-x: hidden;
    }
    
    /* === CONTAINER & LAYOUT === */
    .container {
        padding: 16px;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    /* === HEADER CONTROLS - PREVENT OVERFLOW === */
    .header {
        padding: 12px 16px;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .header-top {
        flex-wrap: wrap;
        gap: 12px;
        max-width: 100%;
    }
    
    .header-right {
        flex-wrap: wrap;
        gap: 10px;
        max-width: 100%;
    }
    
    .header h1 {
        font-size: 20px;
    }
    
    .header-logo {
        height: 45px;
    }
    
    .header-nav {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
        max-width: 100%;
    }
    
    /* === GRIDS - RESPONSIVE SIZING WITH OVERFLOW PROTECTION === */
    .items-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr));
        gap: 16px;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .par-type-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
        gap: 16px;
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .filter-controls {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
        gap: 16px;
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .history-controls {
        display: grid;
        grid-template-columns: 1fr;
        gap: 16px;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* === ORDER FORM - PREVENT OVERFLOW === */
    .order-form,
    .vendor-sheet,
    .vendor-sheets-container {
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .vendor-header {
        flex-wrap: wrap;
        gap: 8px;
        max-width: 100%;
    }
    
    .vendor-header h5,
    .delivery-days {
        word-break: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
    }
    
    .vendor-categories {
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    /* === TOUCH TARGETS - WCAG 2.1 AA (44px min) === */
    button,
    .btn,
    a.btn,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    .btn-nav,
    .btn-primary,
    .btn-secondary {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 44px;
    }
    
    input:not([type="radio"]):not([type="checkbox"]),
    select,
    textarea {
        min-height: 44px;
        font-size: 16px;
        padding: 12px;
    }
    
    /* === VENDOR CREDIT BUTTONS === */
    .vendor-credit-buttons,
    .nb-vendor-buttons {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .vendor-credit-buttons .acknowledge-btn,
    .nb-vendor-buttons .nb-btn {
        flex: 1 1 auto;
        min-width: 140px;
        max-width: calc(50% - 8px);
        min-height: 44px;
        word-break: break-word;
        overflow-wrap: break-word;
        text-align: center;
    }
    
    /* === TABLE OPTIMIZATIONS === */
    .history-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .history-table th,
    .history-table td {
        padding: 12px 10px;
        font-size: 14px;
    }
    
    /* === MODAL SIZING === */
    .modal-content {
        width: 90%;
        max-width: 600px;
        max-height: 85vh;
    }
    
    /* === FORM ACTIONS - PREVENT OVERFLOW === */
    .form-actions {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .form-actions button {
        flex: 1 1 auto;
        min-width: 120px;
    }
    
    /* === SIDEBAR MANAGEMENT === */
    .filter-sidebar,
    .submission-sidebar {
        display: none;
    }
    
    .history-container,
    .submission-container {
        display: block;
    }
    
    .history-results,
    .submission-form-wrapper {
        width: 100%;
    }
}

/* Standard tablet and below breakpoint (max-width: 768px) */
@media (max-width: 768px) {
    .header {
        padding: 0.75rem 1rem;
    }
    
    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .header-left {
        width: 100%;
    }
    
    .header-right {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    
    #storeUserInfo {
        font-size: 14px;
        flex: 1;
        min-width: 150px;
    }
    
    .logo {
        max-width: 150px;
        margin-bottom: 20px;
    }
    
    /* Make tables scroll horizontally on small screens */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -10px;
        padding: 0 10px;
    }
    
    table {
        min-width: 600px;
    }
    
    /* Stack form elements vertically */
    .form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    /* Vendor sheets stacking */
    .vendor-sheet {
        margin-bottom: 25px;
    }
    
    .vendor-categories {
        padding: 15px;
    }
    
    /* Order summary adjustments */
    .order-summary {
        padding: 15px;
    }
    
    .summary-content {
        max-height: 250px;
    }
    
    .summary-item {
        grid-template-columns: 1fr auto auto;
        gap: 10px;
        font-size: 14px;
    }
    
    /* Form controls */
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-control,
    .form-control-readonly {
        font-size: 16px;
    }
    
    /* Image previews for credit submission */
    .image-previews {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
    
    /* Ensure all interactive elements are touch-friendly */
    button, 
    a.btn, 
    input[type="submit"], 
    input[type="button"],
    .btn-view-details,
    .btn-back,
    .btn-history {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Admin gear icon - make it bigger on mobile */
    .admin-gear-icon {
        width: 50px;
        height: 50px;
        bottom: 15px;
        right: 15px;
    }
    
    .admin-gear-icon svg {
        width: 24px;
        height: 24px;
    }
}

/* ============================================
   LANDSCAPE MODE OPTIMIZATIONS
   ============================================ */

/* Phone Landscape (max-width: 768px) */
@media (max-width: 768px) and (orientation: landscape) {
    
    /* ===== HEADER & NAVIGATION ===== */
    .header {
        padding: 0.5rem 1rem;
    }
    
    .header h1 {
        font-size: 16px;
    }
    
    .header-logo {
        height: 30px;
        width: auto;
    }
    
    .header-top {
        min-height: auto;
    }
    
    .header-right {
        gap: 0.5rem;
    }
    
    /* Navigation buttons in row */
    .nav-buttons {
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .btn-back,
    .btn-history,
    .btn-settings {
        padding: 0.5rem 1rem;
        font-size: 14px;
        min-height: 44px;
    }
    
    /* ===== FORMS - HORIZONTAL LAYOUTS ===== */
    
    /* Login form - compact */
    .login-container {
        padding: 1.5rem;
        max-width: 600px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .login-form {
        gap: 0.75rem;
    }
    
    .logo {
        margin-bottom: 15px;
    }
    
    .logo img {
        width: 60px;
        height: 60px;
        margin-bottom: 10px;
    }
    
    .logo h1 {
        font-size: 22px;
    }
    
    .logo p {
        font-size: 13px;
    }
    
    /* Form groups - horizontal layout */
    .form-group {
        display: grid;
        grid-template-columns: 120px 1fr;
        align-items: center;
        gap: 1rem;
        margin-bottom: 12px;
    }
    
    .form-group label {
        text-align: right;
        margin-bottom: 0;
    }
    
    /* Credit submission form */
    .submission-content {
        padding: 1rem;
    }
    
    .acknowledgement-content {
        padding: 1rem;
    }
    
    .form-section {
        margin-bottom: 1rem;
    }
    
    .submission-form-wrapper {
        padding: 1rem;
    }
    
    .manager-acknowledgement {
        padding: 1.5rem;
    }
    
    .manager-acknowledgement h2 {
        font-size: 20px;
        margin-bottom: 12px;
    }
    
    /* Settings form - horizontal */
    .settings-form {
        gap: 0.75rem;
    }
    
    .settings-container {
        padding: 1.5rem;
    }
    
    .settings-info {
        padding: 12px;
        margin-bottom: 20px;
    }
    
    /* Store selection */
    .store-selection {
        padding: 1.5rem;
        max-width: 600px;
        margin: 0 auto;
    }
    
    /* ===== TABLES - FULL WIDTH ===== */
    
    .table-responsive {
        max-height: calc(100vh - 200px);
        overflow-y: auto;
    }
    
    .history-table th,
    .history-table td {
        padding: 0.5rem 0.75rem;
        font-size: 13px;
    }
    
    .history-table-container {
        padding: 12px;
    }
    
    .par-table th,
    .par-table td {
        padding: 8px 10px;
        font-size: 13px;
    }
    
    /* Compact filters */
    .history-controls {
        flex-direction: row;
        gap: 1rem;
        flex-wrap: wrap;
    }
    
    .filter-group {
        flex: 1 1 150px;
        min-width: 0;
    }
    
    .search-bar,
    .status-filter {
        flex: 1 1 200px;
    }
    
    .filters {
        flex-direction: row;
        gap: 1rem;
    }
    
    /* Filter sidebar stays hidden on phone landscape */
    .filter-sidebar {
        display: none;
    }
    
    /* ===== MODALS & DIALOGS - WIDER ===== */
    
    .modal-content,
    .details-modal {
        width: 90%;
        max-width: 800px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header {
        padding: 0.75rem 1rem;
    }
    
    .modal-title {
        font-size: 18px;
    }
    
    .modal-body {
        padding: 1rem;
        max-height: calc(90vh - 120px);
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 0.75rem 1rem;
    }
    
    /* ===== BUTTONS & CONTROLS - COMPACT ===== */
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 14px;
        min-height: 44px;
    }
    
    .btn-primary,
    .btn-secondary,
    .btn-danger {
        min-width: 100px;
    }
    
    .login-btn,
    .acknowledge-btn,
    .submit-btn {
        padding: 0.75rem 1.5rem;
        font-size: 15px;
    }
    
    /* Button groups in row */
    .button-group,
    .form-actions {
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .vendor-credit-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
    
    /* ===== GRIDS - MORE COLUMNS ===== */
    
    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
    
    .par-type-grid {
        grid-template-columns: repeat(2, 1fr);
        max-width: 600px;
    }
    
    /* ===== IMAGE PREVIEWS - COMPACT ===== */
    
    .image-previews {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
    }
    
    .image-preview {
        height: 80px;
    }
    
    /* ===== OFFLINE PAGE - COMPACT ===== */
    
    .offline-container {
        padding: 30px 25px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .offline-container h1 {
        font-size: 24px;
        margin-bottom: 12px;
    }
    
    .offline-icon {
        font-size: 60px;
        margin: 15px 0;
    }
    
    .message {
        font-size: 15px;
        margin-bottom: 20px;
    }
    
    .features {
        padding: 15px;
        margin: 20px 0;
    }
    
    .features h3 {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    .features li {
        padding: 8px 0;
        font-size: 14px;
    }
    
    /* ===== CONTAINER & LAYOUT ===== */
    
    .container {
        padding: 0.75rem;
    }
    
    /* History container - hide sidebar, show results full width */
    .history-container {
        display: block;
    }
    
    .history-results {
        width: 100%;
    }
    
    /* Submission container - hide sidebar on phone landscape */
    .submission-container {
        display: block;
    }
    
    .submission-sidebar {
        display: none;
    }
    
    /* ===== ORDER FORM - COMPACT ===== */
    
    .order-form {
        padding: 1rem;
    }
    
    .date-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
    
    .order-summary {
        padding: 1rem;
        margin-top: 1rem;
    }
    
    /* ===== MAINTAIN TOUCH TARGETS ===== */
    
    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="email"],
    select,
    textarea {
        min-height: 44px;
        padding: 10px 12px;
        font-size: 16px;
    }
    
    button,
    a.btn,
    input[type="submit"],
    input[type="button"],
    .btn-view-details {
        min-height: 44px;
        min-width: 44px;
    }
    
    input[type="radio"],
    input[type="checkbox"] {
        min-width: 20px;
        min-height: 20px;
        cursor: pointer;
    }
    
    /* Radio/checkbox labels need touch targets */
    .par-type-option,
    label {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* ============================================
   TABLET LANDSCAPE / SMALL LAPTOP (769px - 1024px)
   iPad Pro, Surface Pro, small laptops - All orientations
   WCAG 2.1 AA Compliant
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    /* === GLOBAL OVERFLOW PREVENTION === */
    body {
        overflow-x: hidden;
    }
    
    /* === CONTAINER & LAYOUT - PREVENT OVERFLOW === */
    .container {
        max-width: 100%;
        padding: 20px;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    /* === HEADER CONTROLS - RESPONSIVE WRAPPING === */
    .header {
        padding: 12px 20px;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .header-top {
        flex-wrap: wrap;
        gap: 16px;
        max-width: 100%;
    }
    
    .header-right {
        flex-wrap: wrap;
        gap: 12px;
        max-width: 100%;
    }
    
    .header-nav {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
        max-width: 100%;
    }
    
    .header h1 {
        font-size: 22px;
    }
    
    .header-logo {
        height: 48px;
    }
    
    /* === GRIDS - PREVENT OVERFLOW WITH MINMAX === */
    .par-type-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
        gap: 20px;
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .items-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr));
        gap: 16px;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .filter-controls {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
        gap: 16px;
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    /* === VENDOR CREDIT BUTTONS - PREVENT OVERFLOW === */
    .vendor-credit-buttons,
    .nb-vendor-buttons {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .vendor-credit-buttons .acknowledge-btn,
    .nb-vendor-buttons .nb-btn {
        flex: 1 1 auto;
        min-width: 140px;
        max-width: calc(50% - 6px);
        word-break: break-word;
        overflow-wrap: break-word;
        text-align: center;
    }
    
    .history-controls {
        grid-template-columns: 2fr 1fr;
        gap: 20px;
        max-width: 100%;
    }
    
    /* === ORDER FORM - PREVENT OVERFLOW === */
    .order-form,
    .vendor-sheet,
    .vendor-sheets-container {
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    /* === TOUCH TARGETS - WCAG 2.1 AA (44px min) === */
    button,
    .btn,
    a.btn,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    input:not([type="radio"]):not([type="checkbox"]),
    select,
    textarea {
        min-height: 44px;
        font-size: 16px;
    }
    
    /* === TABLES - OPTIMIZED FOR TABLET === */
    .history-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .history-table {
        min-width: 800px;
    }
    
    .history-table th,
    .history-table td {
        padding: 14px 12px;
        font-size: 14px;
    }
    
    /* === MODAL SIZING === */
    .modal-content {
        width: 85%;
        max-width: 800px;
        max-height: 85vh;
    }
    
    /* === SIDEBAR PANELS - VISIBLE ON TABLET LANDSCAPE === */
    .filter-sidebar {
        display: block;
        width: 260px;
        flex-shrink: 0;
    }
    
    .submission-sidebar {
        display: block;
        width: 280px;
        flex-shrink: 0;
    }
    
    .history-container,
    .submission-container {
        display: flex;
        flex-direction: row;
        gap: 24px;
    }
    
    .history-results,
    .submission-form-wrapper {
        flex: 1;
        min-width: 0;
    }
    
    /* === FORM ACTIONS === */
    .form-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 16px;
        justify-content: flex-end;
    }
    
    .form-actions button {
        flex: 0 1 auto;
        min-width: 140px;
    }
    
    /* === VENDOR CREDIT BUTTONS === */
    .vendor-credit-buttons {
        display: flex;
        justify-content: center;
        gap: 16px;
        flex-wrap: wrap;
    }
    
    .vendor-credit-buttons .acknowledge-btn {
        min-height: 44px;
    }
}

/* Tablet Landscape (769px - 1024px) - Landscape-specific overrides */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
    
    /* ===== CONTAINER - EVEN WIDER ===== */
    
    .container {
        max-width: 95%;
        padding: 1rem;
    }
    
    /* ===== FORMS - MORE HORIZONTAL SPACE ===== */
    
    .form-group {
        display: grid;
        grid-template-columns: 150px 1fr;
        align-items: center;
        gap: 1.5rem;
    }
    
    .form-group label {
        text-align: right;
        margin-bottom: 0;
    }
    
    /* Three-column forms for short fields */
    .form-row-triple {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
    
    /* Login form - wider */
    .login-container {
        padding: 2rem;
        max-width: 700px;
    }
    
    /* Settings form - wider */
    .settings-container {
        padding: 2rem;
    }
    
    .par-table-container {
        max-height: calc(100vh - 250px);
    }
    
    /* ===== TABLES - FULL WIDTH ===== */
    
    .table-responsive {
        overflow-x: visible;
        max-height: calc(100vh - 180px);
    }
    
    .history-table th,
    .history-table td {
        padding: 12px 14px;
        font-size: 14px;
    }
    
    /* ===== MODALS - EVEN WIDER ===== */
    
    .modal-content,
    .details-modal {
        width: 85%;
        max-width: 900px;
        max-height: 85vh;
    }
    
    .modal-body {
        max-height: calc(85vh - 140px);
    }
    
    /* ===== MAINTAIN SIDEBAR PANELS ===== */
    
    /* Filter sidebar visible on tablet landscape */
    .filter-sidebar {
        display: block;
        width: 260px;
    }
    
    .history-container {
        display: flex;
        flex-direction: row;
        gap: 24px;
    }
    
    .history-results {
        flex: 1;
    }
    
    /* Submission sidebar visible on tablet landscape */
    .submission-sidebar {
        display: block;
        width: 280px;
    }
    
    .submission-container {
        display: flex;
        flex-direction: row;
        gap: 24px;
    }
    
    .submission-form-wrapper {
        flex: 1;
    }
    
    /* ===== GRIDS - MORE COLUMNS ===== */
    
    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
    
    .par-type-grid {
        grid-template-columns: repeat(2, 1fr);
        max-width: 800px;
    }
    
    .vendor-credit-buttons {
        display: flex;
        justify-content: center;
        gap: 12px;
    }
    
    /* ===== BUTTONS - COMFORTABLE SIZING ===== */
    
    .btn {
        padding: 0.6rem 1.2rem;
        font-size: 15px;
    }
    
    /* ===== MAINTAIN TOUCH TARGETS ===== */
    
    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="email"],
    select,
    textarea,
    button,
    a.btn {
        min-height: 44px;
    }
}

/* General Landscape - Maintain Touch Targets Across All Landscape Modes */
@media (orientation: landscape) {
    
    /* Ensure all interactive elements meet WCAG 2.1 Level AA touch target size */
    button,
    a.btn,
    input[type="submit"],
    input[type="button"],
    select {
        min-height: 44px;
    }
    
    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="email"],
    textarea {
        min-height: 44px;
    }
    
    /* Theme toggle button */
    .theme-toggle {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Ensure no horizontal scroll on any screen size */
@media (max-width: 1024px) {
    * {
        max-width: 100%;
    }
    
    body {
        overflow-x: hidden;
    }
    
    .container {
        overflow-x: hidden;
    }
    
    /* Prevent fixed-width elements from causing overflow */
    .vendor-sheet,
    .order-form,
    .store-selection,
    .manager-acknowledgement {
        box-sizing: border-box;
        max-width: 100%;
    }
}

.admin-gear-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(100, 100, 100, 0.3);
    border-radius: 50%;
    color: #666;
    text-decoration: none;
    transition: opacity 0.3s ease, background 0.3s ease;
    z-index: 1000;
    opacity: 0.3;
}

.admin-gear-icon:hover {
    opacity: 0.8;
    background: rgba(100, 100, 100, 0.5);
}

.admin-gear-icon:focus-visible {
    opacity: 0.8;
    outline: 2px solid #d32f2f;
    outline-offset: 2px;
}

.admin-gear-icon svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.admin-gear-icon:hover svg {
    transform: rotate(90deg);
}

@media (prefers-reduced-motion: reduce) {
    .admin-gear-icon svg {
        transition: none;
    }
    
    .admin-gear-icon:hover svg {
        transform: none;
    }
}

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #d32f2f;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-overlay-text {
    margin-top: 16px;
    color: #333;
    font-size: 16px;
}

/* Button Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
    cursor: not-allowed;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Skeleton Screens */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: 16px;
}

.skeleton-card {
    height: 100px;
    margin-bottom: 16px;
}

/* Dark theme skeleton styles */
.dark-theme .skeleton {
    background: linear-gradient(
        90deg,
        #2a2a2a 25%,
        #3a3a3a 50%,
        #2a2a2a 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Screen reader only content - visually hidden but accessible to screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Credit Submission Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
    font-size: 1em;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    box-sizing: border-box;
    transition: border-color 0.3s;
    min-height: 44px;
}

.form-control:focus {
    outline: none;
    border-color: #d32f2f;
}

.form-control-readonly {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    background-color: #f5f5f5;
    color: #666;
    box-sizing: border-box;
    cursor: not-allowed;
    min-height: 44px;
}

.form-control-file {
    width: 100%;
    padding: 12px;
    border: 2px dashed #ddd;
    border-radius: 10px;
    font-size: 16px;
    box-sizing: border-box;
    cursor: pointer;
    transition: border-color 0.3s;
    min-height: 44px;
}

.form-control-file:hover {
    border-color: #d32f2f;
}

.required {
    color: #d32f2f;
    font-weight: bold;
}

.file-count {
    margin-top: 8px;
    font-size: 0.9em;
    color: #666;
    font-weight: 600;
}

.image-previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.image-preview-item {
    position: relative;
    border: 2px solid #ddd;
    border-radius: 10px;
    padding: 8px;
    background: #f9f9f9;
    overflow: hidden;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

.file-icon {
    text-align: center;
    font-size: 2em;
    color: #666;
    word-break: break-all;
}

.file-icon small {
    font-size: 0.3em;
    display: block;
    margin-top: 8px;
}

.remove-image-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #d32f2f;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
    padding: 0;
    min-width: 44px;
    min-height: 44px;
}

.remove-image-btn:hover {
    background: #b71c1c;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.btn-back {
    background: #666;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background 0.3s;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-back:hover {
    background: #555;
}

.btn-history {
    background: #d32f2f;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background 0.3s;
    flex: 1;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-history:hover {
    background: #c62828;
}

.form-actions .acknowledge-btn {
    flex: 2;
    margin: 0;
}

/* Mobile responsive adjustments for credit form */
@media (max-width: 768px) {
    .form-actions {
        flex-direction: column;
    }
    
    .btn-back,
    .btn-history,
    .form-actions .acknowledge-btn {
        width: 100%;
        flex: none;
    }
    
    .image-previews {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .image-previews {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Credit History Page Styles */

.history-header {
    margin-bottom: 20px;
}

.history-controls {
    background: white;
    padding: 20px;
    border-radius: 14px;
    margin-bottom: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.search-bar,
.status-filter {
    display: flex;
    flex-direction: column;
}

.search-bar label,
.status-filter label {
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.history-table-container {
    background: white;
    padding: 20px;
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.history-table thead {
    background: #d32f2f;
    color: white;
}

.history-table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: bold;
    font-size: 0.95em;
}

.history-table tbody tr {
    border-bottom: 1px solid #e0e0e0;
    transition: background-color 0.2s;
}

.history-table tbody tr:hover {
    background-color: #f9f9f9;
}

.history-table td {
    padding: 12px 15px;
    vertical-align: middle;
}

.history-table .submission-id {
    font-family: monospace;
    font-size: 0.9em;
    color: #666;
}

.history-table .amount,
.history-table .quantity {
    text-align: right;
    font-weight: 600;
}

.loading-cell {
    text-align: center;
    padding: 40px 20px !important;
}

.loading-cell p {
    margin-top: 15px;
    color: #666;
    font-size: 1em;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-pending {
    background: #fff3e0;
    color: #f57c00;
    border: 1px solid #ffb74d;
}

.status-resolved {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #66bb6a;
}

.status-rejected {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef5350;
}

/* View Details Button */
.btn-view-details {
    background: #2196F3;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.3s;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-view-details:hover {
    background: #1976D2;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state p {
    font-size: 1.2em;
    margin-bottom: 10px;
}

.empty-state-subtitle {
    font-size: 0.95em !important;
    color: #999;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    z-index: 10001;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid #e0e0e0;
}

.modal-header h2 {
    margin: 0;
    color: #d32f2f;
    font-size: 1.5em;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 32px;
    color: #666;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
}

.modal-close-btn:hover {
    color: #d32f2f;
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 2px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Modal Detail Sections */
.detail-section {
    margin-bottom: 25px;
}

.detail-section h3 {
    color: #d32f2f;
    font-size: 1.2em;
    margin-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 8px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.detail-item strong {
    color: #666;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-item span {
    color: #333;
    font-size: 1em;
}

.detail-description {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid #d32f2f;
    line-height: 1.6;
    color: #333;
}

/* Modal Image Grid */
.modal-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.modal-image-item {
    position: relative;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 1;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
}

.modal-image-item:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.modal-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Mobile responsive adjustments for credit history */
@media (max-width: 768px) {
    .history-controls {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .history-table-container {
        padding: 10px;
    }
    
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 15px;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-image-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .history-header {
        margin-bottom: 15px;
    }
    
    .btn-back {
        width: 100%;
    }
    
    .history-controls {
        padding: 15px;
    }
    
    .modal-header h2 {
        font-size: 1.2em;
    }
    
    .modal-close-btn {
        font-size: 28px;
    }
}

/* ============================================
   HIGH-VALUE ORDER CONFIRMATION MODAL
   ============================================ */

.high-value-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.high-value-modal-overlay.show {
    opacity: 1;
}

.high-value-confirmation {
    background: var(--color-bg-secondary);
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px var(--color-shadow-strong);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.high-value-confirmation .modal-header.warning {
    background: var(--color-warning-bg);
    color: #856404;
    border-bottom: 2px solid var(--color-warning);
    padding: 20px 25px;
    border-radius: 16px 16px 0 0;
}

.dark-theme .high-value-confirmation .modal-header.warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-dark);
}

.high-value-confirmation .modal-header h3 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 700;
}

.high-value-confirmation .modal-body {
    padding: 30px 25px;
    text-align: center;
    color: var(--color-text-primary);
}

.high-value-confirmation .modal-body p {
    margin: 15px 0;
    font-size: 1em;
    line-height: 1.6;
}

.high-value-confirmation .modal-body p:first-child {
    margin-top: 0;
}

.high-value-confirmation .modal-body p:last-child {
    margin-bottom: 0;
}

.high-value-confirmation .modal-body strong {
    font-size: 1.5em;
    color: var(--color-brand-primary);
    display: block;
    margin: 10px 0;
    font-weight: 700;
}

.high-value-confirmation .modal-footer {
    display: flex;
    gap: 15px;
    justify-content: center;
    padding: 20px 25px;
    border-top: 2px solid var(--color-border);
}

.high-value-confirmation .modal-footer .btn {
    flex: 1;
    max-width: 150px;
    padding: 12px 20px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.high-value-confirmation .modal-footer .btn-secondary {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    border: 2px solid var(--color-border);
}

.high-value-confirmation .modal-footer .btn-secondary:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-brand-primary);
}

.high-value-confirmation .modal-footer .btn-primary {
    background: var(--color-brand-primary);
    color: var(--color-text-inverse);
    border: 2px solid var(--color-brand-primary);
}

.high-value-confirmation .modal-footer .btn-primary:hover {
    background: var(--color-brand-secondary);
    border-color: var(--color-brand-secondary);
}

/* Mobile responsive adjustments for high-value confirmation */
@media (max-width: 480px) {
    .high-value-confirmation {
        width: 95%;
        max-width: none;
    }
    
    .high-value-confirmation .modal-header h3 {
        font-size: 1.1em;
    }
    
    .high-value-confirmation .modal-body {
        padding: 20px 15px;
    }
    
    .high-value-confirmation .modal-body strong {
        font-size: 1.3em;
    }
    
    .high-value-confirmation .modal-footer {
        flex-direction: column;
        gap: 10px;
    }
    
    .high-value-confirmation .modal-footer .btn {
        max-width: none;
        width: 100%;
    }
}

/* ============================================
   OFFLINE QUEUE BADGE & MODAL STYLES
   ============================================ */

/* Queue Status Badge */
.queue-badge {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #ff9800;
    color: white;
    padding: 12px 18px;
    border-radius: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    transform: translateY(100px);
    display: flex;
    align-items: center;
    gap: 10px;
}

.queue-badge.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.queue-badge:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.queue-badge.pending {
    background: #ff9800;
}

.queue-badge.syncing {
    background: #2196f3;
}

.queue-badge.success {
    background: #4caf50;
}

.queue-badge.error {
    background: #f44336;
}

.queue-badge-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.queue-badge-icon {
    font-size: 18px;
    line-height: 1;
}

.queue-badge-text {
    font-size: 14px;
    font-weight: 600;
}

.queue-badge-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

@keyframes fadeOut {
    0%, 70% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        visibility: hidden;
        transform: translateY(100px);
    }
}

/* Queue Details Modal */
.queue-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.queue-modal.show {
    opacity: 1;
    visibility: visible;
}

.queue-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.queue-modal-content {
    position: relative;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.queue-modal-header {
    padding: 24px;
    border-bottom: 2px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.queue-modal-header h2 {
    font-size: 24px;
    color: #d32f2f;
    margin: 0;
}

.queue-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    padding: 0;
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.queue-modal-close:hover {
    background: #f0f0f0;
    color: #d32f2f;
}

.queue-modal-summary {
    padding: 20px 24px;
    background: #f5f7fa;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.queue-stat {
    text-align: center;
}

.queue-stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #d32f2f;
    margin-bottom: 4px;
}

.queue-stat-label {
    font-size: 13px;
    color: #666;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.queue-modal-actions {
    padding: 16px 24px;
    display: flex;
    gap: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.queue-modal-tabs {
    padding: 0 24px;
    display: flex;
    gap: 8px;
    border-bottom: 2px solid #e0e0e0;
}

.queue-tab {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: #666;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.queue-tab:hover {
    color: #d32f2f;
    background: #f5f5f5;
}

.queue-tab.active {
    color: #d32f2f;
    border-bottom-color: #d32f2f;
}

.queue-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.queue-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.queue-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 16px;
}

.queue-item {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 16px;
    padding: 16px;
    transition: all 0.2s ease;
}

.queue-item:hover {
    border-color: #d32f2f;
    box-shadow: 0 4px 12px rgba(211, 47, 47, 0.1);
}

.queue-item.pending {
    border-left: 4px solid #ff9800;
}

.queue-item.success {
    border-left: 4px solid #4caf50;
}

.queue-item.error {
    border-left: 4px solid #f44336;
}

.queue-item-header {
    display: flex;
    align-items: start;
    gap: 12px;
    margin-bottom: 12px;
}

.queue-item-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.queue-item-info {
    flex: 1;
}

.queue-item-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.queue-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: #666;
}

.queue-item-time {
    font-weight: 600;
}

.queue-item-priority {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.priority-0 {
    background: #e3f2fd;
    color: #1976d2;
}

.priority-1 {
    background: #fff3e0;
    color: #f57c00;
}

.priority-2 {
    background: #ffebee;
    color: #c62828;
}

.queue-item-retries {
    padding: 3px 8px;
    border-radius: 6px;
    background: #fff3e0;
    color: #f57c00;
    font-size: 11px;
    font-weight: 600;
}

.queue-item-details {
    padding: 12px;
    background: #f5f5f5;
    border-radius: 10px;
    margin-bottom: 12px;
}

.queue-item-url {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
    word-break: break-all;
}

.queue-item-error {
    color: #f44336;
    font-size: 13px;
    padding: 8px;
    background: #ffebee;
    border-radius: 6px;
    margin-top: 8px;
}

.queue-item-timestamp {
    font-size: 12px;
    color: #999;
}

.queue-item-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    min-height: auto;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
}

/* Mobile responsiveness for queue modal */
@media (max-width: 768px) {
    .queue-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .queue-modal-summary {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .queue-modal-actions {
        flex-direction: column;
    }
    
    .queue-modal-tabs {
        overflow-x: auto;
    }
    
    .queue-item-meta {
        flex-direction: column;
        gap: 6px;
    }
    
    .queue-badge {
        bottom: 10px;
        right: 10px;
        font-size: 13px;
        padding: 10px 14px;
    }
}
/* ============================================
   Lazy Loading Image Styles
   ============================================ */

/* Base lazy loading image styles */
img[data-lazy] {
    opacity: 0;
    transition: opacity 0.3s ease-in;
    background-color: #f5f5f5;
    background-image: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
}

/* Loaded state - fade in smoothly */
img[data-lazy].loaded {
    opacity: 1;
}

/* Error state - light red background */
img[data-lazy].error {
    opacity: 1;
    background-color: #ffebee;
    background-image: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
}

/* Loading animation - pulse effect */
img[data-lazy].loading {
    animation: lazyImagePulse 1.5s ease-in-out infinite;
}

@keyframes lazyImagePulse {
    0%, 100% { 
        opacity: 0.6; 
    }
    50% { 
        opacity: 1; 
    }
}

/* Shimmer placeholder effect for image containers */
.img-placeholder,
.lazy-image-placeholder {
    background: linear-gradient(90deg, #f5f5f5 0%, #e0e0e0 50%, #f5f5f5 100%);
    background-size: 200% 100%;
    animation: lazyImageShimmer 2s infinite;
}

@keyframes lazyImageShimmer {
    0% { 
        background-position: -100% 0; 
    }
    100% { 
        background-position: 200% 0; 
    }
}

/* Lazy image wrapper for better control */
.lazy-image-wrapper {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
}

/* Ensure lazy images maintain aspect ratio */
.lazy-image-wrapper img {
    width: 100%;
    height: auto;
    display: block;
}

/* Credit submission image previews with lazy loading */
.image-previews img[data-lazy] {
    min-height: 150px;
    border-radius: 8px;
}

/* Credit history modal images with lazy loading */
.modal-images img[data-lazy],
.submission-images img[data-lazy] {
    min-height: 200px;
    border-radius: 8px;
}

/* Mobile responsiveness for lazy images */
@media (max-width: 768px) {
    .image-previews img[data-lazy] {
        min-height: 120px;
    }
    
    .modal-images img[data-lazy],
    .submission-images img[data-lazy] {
        min-height: 150px;
    }
}

/* Accessibility: Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    img[data-lazy],
    img[data-lazy].loaded,
    img[data-lazy].loading {
        animation: none;
        transition: opacity 0.01ms;
    }
    
    .img-placeholder,
    .lazy-image-placeholder {
        animation: none;
    }
}

/* Print styles - ensure lazy images load for print */
@media print {
    img[data-lazy] {
        opacity: 1;
    }
}

/* ============================================
   TABLET OPTIMIZATIONS (768px - 1024px)
   Side-by-Side Panels & Adaptive Navigation
   ============================================ */

/* Tablet Breakpoint - Optimized for iPad and Android tablets */
@media (min-width: 768px) and (max-width: 1024px) {
    
    /* ===== GLOBAL OVERFLOW PREVENTION FOR TABLETS ===== */
    
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    .container,
    .order-form,
    .store-selection,
    .manager-acknowledgement,
    .store-info {
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    /* ===== VENDOR FILTER & ORDER FORM OVERFLOW FIXES ===== */
    
    .filter-controls {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
        gap: 16px;
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .filter-controls > * {
        max-width: 100%;
        min-width: 0;
    }
    
    .vendor-sheets-container,
    .vendor-sheet {
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .vendor-header {
        flex-wrap: wrap;
        gap: 8px;
        max-width: 100%;
    }
    
    .vendor-header h5 {
        word-break: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
    }
    
    .delivery-days {
        word-break: break-word;
        max-width: 100%;
    }
    
    .vendor-categories {
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    /* ===== VENDOR CREDIT BUTTONS - PREVENT OVERFLOW ===== */
    
    .vendor-credit-buttons,
    .nb-vendor-buttons {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .vendor-credit-buttons .acknowledge-btn,
    .nb-vendor-buttons .nb-btn {
        flex: 1 1 auto;
        min-width: 140px;
        max-width: calc(50% - 6px);
        word-break: break-word;
        overflow-wrap: break-word;
        text-align: center;
    }
    
    /* ===== ITEMS GRID OVERFLOW FIX ===== */
    
    .items-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr));
        gap: 16px;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .item-card {
        max-width: 100%;
        box-sizing: border-box;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    .item-card h5,
    .item-details {
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    /* ===== HEADER OVERFLOW PREVENTION ===== */
    
    .header {
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .header-top,
    .header-left,
    .header-right {
        flex-wrap: wrap;
        max-width: 100%;
        gap: 10px;
    }
    
    .header-nav {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
        max-width: 100%;
    }
    
    /* ===== TEXT OVERFLOW HANDLING ===== */
    
    h1, h2, h3, h4, h5, h6,
    p, span, label {
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    /* ===== FILTER CHIPS & STATS CARDS OVERFLOW FIX - WCAG 2.1 AA ===== */
    
    .filter-chips,
    .chips-container,
    .stats-cards,
    .stats-container {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    .chip,
    .filter-chip,
    .stats-card {
        flex-shrink: 0;
        max-width: calc(50% - 8px);
        min-height: 44px;
        box-sizing: border-box;
    }
    
    .tag,
    .badge,
    .status-chip {
        flex-shrink: 0;
        max-width: calc(50% - 8px);
        min-height: 44px;
        box-sizing: border-box;
    }
    
    /* ===== CREDIT SUBMISSION PAGE ===== */
    
    /* Submission container - side-by-side layout */
    .submission-container {
        display: flex;
        flex-direction: row;
        gap: 24px;
        align-items: flex-start;
    }
    
    /* Submission sidebar - guidelines */
    .submission-sidebar {
        display: block;
        width: 300px;
        min-width: 280px;
        background: var(--color-bg-secondary);
        padding: 20px;
        border-radius: 14px;
        box-shadow: 0 2px 10px var(--color-shadow);
        position: sticky;
        top: 80px;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }
    
    .submission-sidebar h3 {
        color: var(--color-brand-primary);
        font-size: 1.2em;
        margin-bottom: 16px;
    }
    
    .guidelines-list {
        list-style: none;
        padding: 0;
        margin: 0 0 20px 0;
    }
    
    .guidelines-list li {
        padding: 10px 0;
        border-bottom: 1px solid var(--color-border);
        font-size: 14px;
        line-height: 1.5;
    }
    
    .guidelines-list li:last-child {
        border-bottom: none;
    }
    
    .sidebar-tips {
        background: var(--color-bg-tertiary);
        padding: 15px;
        border-radius: 10px;
        margin-top: 20px;
    }
    
    .sidebar-tips h4 {
        color: var(--color-brand-primary);
        font-size: 1em;
        margin-bottom: 8px;
    }
    
    .sidebar-tips p {
        font-size: 13px;
        color: var(--color-text-secondary);
        margin: 0;
        line-height: 1.4;
    }
    
    /* Submission form wrapper - takes remaining space */
    .submission-form-wrapper {
        flex: 1;
        min-width: 0;
    }
    
    /* ===== CREDIT HISTORY PAGE ===== */
    
    /* History container - side-by-side layout */
    .history-container {
        display: flex;
        flex-direction: row;
        gap: 24px;
        align-items: flex-start;
    }
    
    /* Filter sidebar - persistent filters */
    .filter-sidebar {
        display: block;
        width: 280px;
        min-width: 250px;
        background: var(--color-bg-secondary);
        padding: 20px;
        border-radius: 14px;
        box-shadow: 0 2px 10px var(--color-shadow);
        position: sticky;
        top: 80px;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }
    
    .filter-sidebar h3 {
        color: var(--color-brand-primary);
        font-size: 1.2em;
        margin-bottom: 16px;
    }
    
    .filter-group {
        margin-bottom: 16px;
    }
    
    .filter-group label {
        display: block;
        font-weight: 600;
        margin-bottom: 8px;
        color: var(--color-text-primary);
        font-size: 14px;
    }
    
    .sidebar-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 20px;
        padding-top: 20px;
        border-top: 1px solid var(--color-border);
    }
    
    .btn-apply-filters {
        background: var(--color-brand-primary);
        color: var(--color-text-inverse);
        border: none;
        padding: 10px 16px;
        border-radius: 10px;
        cursor: pointer;
        font-size: 14px;
        font-weight: 600;
        transition: background 0.3s;
        min-height: 44px;
    }
    
    .btn-apply-filters:hover {
        background: var(--color-brand-secondary);
    }
    
    .btn-clear-filters {
        background: var(--color-bg-tertiary);
        color: var(--color-text-primary);
        border: 1px solid var(--color-border);
        padding: 10px 16px;
        border-radius: 10px;
        cursor: pointer;
        font-size: 14px;
        font-weight: 600;
        transition: all 0.3s;
        min-height: 44px;
    }
    
    .btn-clear-filters:hover {
        background: var(--color-bg-hover);
        border-color: var(--color-brand-primary);
    }
    
    .sidebar-summary {
        background: var(--color-bg-tertiary);
        padding: 15px;
        border-radius: 10px;
        margin-top: 20px;
    }
    
    .sidebar-summary h4 {
        color: var(--color-brand-primary);
        font-size: 1em;
        margin-bottom: 12px;
    }
    
    .sidebar-summary p {
        font-size: 13px;
        color: var(--color-text-secondary);
        margin: 6px 0;
    }
    
    .sidebar-summary strong {
        color: var(--color-text-primary);
        font-weight: 700;
    }
    
    /* History results - takes remaining space */
    .history-results {
        flex: 1;
        min-width: 0;
    }
    
    /* Hide mobile filter controls on tablets */
    .history-controls-mobile {
        display: none;
    }
    
    /* ===== MANAGER SETTINGS PAGE ===== */
    
    /* Par type grid - responsive with overflow protection */
    .par-type-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
        gap: 20px;
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    /* ===== TOUCH-FRIENDLY ENHANCEMENTS ===== */
    
    /* Larger touch targets for tablets */
    button, .btn {
        min-height: 48px;
        padding: 12px 24px;
    }
    
    input:not([type="radio"]):not([type="checkbox"]), 
    select, 
    textarea {
        min-height: 48px;
        padding: 12px 16px;
        font-size: 16px;
    }
    
    /* Form controls */
    .form-control {
        min-height: 48px;
        padding: 12px 16px;
        font-size: 16px;
    }
    
    /* Table optimizations */
    .history-table th,
    .history-table td {
        padding: 14px 16px;
        font-size: 14px;
    }
    
    .par-table th,
    .par-table td {
        padding: 12px 16px;
    }
    
    /* Better spacing for form actions */
    .form-actions {
        display: flex;
        gap: 12px;
        flex-wrap: wrap;
        justify-content: flex-end;
        margin-top: 24px;
    }
    
    /* Ensure buttons don't get too small */
    .form-actions button {
        flex: 0 1 auto;
        min-width: 140px;
    }
    
    /* Header optimizations */
    .header h1 {
        font-size: 22px;
    }
    
    .header-logo {
        height: 48px;
    }
    
    /* Card grids - 2 columns on tablets */
    .card-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    /* Store selection optimization */
    .store-selection {
        padding: 30px;
    }
    
    /* Manager acknowledgement */
    .manager-acknowledgement {
        padding: 30px;
    }
    
    /* Better table container */
    .history-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Improved modal sizing for tablets */
    .modal-content {
        width: 90%;
        max-width: 700px;
        max-height: 85vh;
    }
    
    /* Modal close buttons - WCAG 2.1 AA touch targets for tablets */
    .queue-modal-close,
    .modal-close,
    .close-btn,
    button[aria-label*="close"],
    button[aria-label*="Close"] {
        min-width: 48px;
        min-height: 48px;
        width: 48px;
        height: 48px;
    }
}

/* Desktop Breakpoint - 1025px and above */
@media (min-width: 1025px) {
    
    /* Wider sidebars on desktop */
    .submission-sidebar {
        width: 320px;
    }
    
    .filter-sidebar {
        width: 300px;
    }
    
    /* 2-column grid on desktop for balanced 2x2 layout */
    .par-type-grid {
        grid-template-columns: repeat(2, 1fr);
        max-width: 800px;
    }
    
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Larger header */
    .header h1 {
        font-size: 24px;
    }
    
    .header-logo {
        height: 50px;
    }
}

/* Mobile - Hide sidebars */
@media (max-width: 767px) {
    
    /* Hide tablet sidebars on mobile */
    .submission-sidebar,
    .filter-sidebar {
        display: none;
    }
    
    /* Stack containers vertically */
    .submission-container,
    .history-container {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }
    
    /* Show mobile filter controls */
    .history-controls-mobile {
        display: block;
    }
    
    /* Full width on mobile */
    .submission-form-wrapper,
    .history-results {
        width: 100%;
    }
}

/* ===================================
   Small Mobile Devices (425px and below)
   iPhone SE, iPhone 12 Mini, older Android
   =================================== */
@media (max-width: 425px) {
  /* Typography - Optimize for readability */
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  
  /* Navigation - Stack and simplify */
  nav {
    flex-direction: column;
  }
  
  nav a, .nav-link {
    width: 100%;
    justify-content: center;
  }
  
  /* Forms - Full width, larger inputs */
  form {
    padding: 1rem;
  }
  
  input,
  select,
  textarea {
    width: 100%;
    font-size: 16px;
  }
  
  label {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
  }
  
  .form-group {
    margin-bottom: 1rem;
  }
  
  /* Buttons - Full width for primary actions */
  .btn-primary,
  button[type="submit"] {
    width: 100%;
    margin-bottom: 0.5rem;
  }
  
  /* Tables - Enable horizontal scroll */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  table {
    min-width: 600px;
    font-size: 0.875rem;
  }
  
  th, td {
    padding: 0.5rem;
  }
  
  /* Cards - Full width */
  .card {
    margin-bottom: 1rem;
    padding: 1rem;
  }
  
  /* Modals - Full screen on small devices */
  .modal-content {
    width: 95vw;
    max-width: 95vw;
    margin: 1rem auto;
  }
  
  /* Grid layouts - Single column */
  .grid,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  /* Spacing adjustments */
  .container {
    padding: 1rem;
  }
  
  /* Header/Logo sizing */
  .logo {
    max-width: 150px;
  }
  
  /* Tab navigation - Scrollable */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }
  
  .tab-button {
    flex-shrink: 0;
    min-width: auto;
    padding: 12px 16px;
  }
}

/* Extra small devices (375px and below) - Comprehensive Mobile Optimization */
@media (max-width: 375px) {
  /* Typography - Optimized readability */
  body {
    font-size: 14px;
    line-height: 1.5;
  }
  
  h1 { 
    font-size: 22px;
  }
  
  h2 { 
    font-size: 18px;
  }
  
  h3 {
    font-size: 16px;
  }
  
  p {
    margin-bottom: 12px;
  }
  
  /* Main containers - Reduced padding */
  .container,
  .main-content,
  .page-container {
    padding: 12px;
  }
  
  /* Navigation - Compact layout */
  nav {
    padding: 8px 12px;
  }
  
  .nav-link {
    font-size: 14px;
    padding: 10px 12px;
  }
  
  /* Logo/brand - Smaller size */
  .logo {
    max-width: 120px;
    height: auto;
  }
  
  /* Navigation buttons */
  nav button,
  .btn-nav {
    font-size: 14px;
    padding: 10px 16px;
  }
  
  /* Tab navigation - Scrollable, compact */
  .tab-button {
    font-size: 13px;
    padding: 10px 12px;
    min-width: auto;
  }
  
  /* Forms - Full-width, stacked layout */
  form {
    padding: 16px 12px;
  }
  
  .form-group {
    margin-bottom: 16px;
  }
  
  label {
    font-size: 14px;
    margin-bottom: 6px;
  }
  
  /* Input fields - 16px to prevent iOS zoom */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  input[type="date"],
  select,
  textarea {
    width: 100%;
    font-size: 16px;
    padding: 10px 12px;
  }
  
  /* Buttons - Full width */
  button[type="submit"],
  .btn-primary:not(.icon-btn),
  .btn-secondary:not(.icon-btn) {
    width: 100%;
    margin-bottom: 8px;
  }
  
  /* Multi-column forms to single column */
  .form-row,
  .form-cols {
    flex-direction: column;
  }
  
  .form-col {
    width: 100%;
  }
  
  /* Form sections - Reduced padding */
  .form-section {
    padding: 12px;
    margin-bottom: 16px;
  }
  
  /* Tables - Horizontal scroll */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -12px;
  }
  
  table {
    font-size: 13px;
    min-width: 100%;
  }
  
  th {
    font-size: 12px;
    padding: 8px 6px;
    white-space: nowrap;
  }
  
  td {
    padding: 8px 6px;
    font-size: 13px;
  }
  
  /* Action buttons in tables */
  .action-btn,
  .delete-btn,
  .edit-btn {
    padding: 6px 8px;
    font-size: 12px;
  }
  
  /* Cards - Compact spacing */
  .card {
    padding: 12px;
    margin-bottom: 12px;
  }
  
  /* Modals - Full width with small margins */
  .modal-content {
    width: calc(100% - 24px);
    margin: 12px;
    padding: 16px;
  }
  
  /* Sections - Reduced spacing */
  .section {
    margin-bottom: 16px;
  }
  
  /* Stack flex layouts */
  .flex-row {
    flex-direction: column;
  }
  
  /* Grid to single column */
  .grid,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  /* Smaller shadows for performance */
  .card,
  .modal {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
  
  /* Order page specific */
  .order-item {
    padding: 10px;
  }
  
  .item-name {
    font-size: 14px;
  }
  
  .quantity-input {
    width: 60px;
    font-size: 16px;
  }
  
  /* Inventory page specific */
  .inventory-filters {
    flex-direction: column;
  }
  
  .filter-input {
    width: 100%;
    margin-bottom: 8px;
  }
  
  /* Credit submission specific */
  .image-preview {
    max-width: 100%;
  }
  
  .credit-form-section {
    padding: 12px;
  }
}

/* ============================================
   TOUCH GESTURE STYLES
   ============================================ */

/* Swipe-to-delete styles for table rows */
.history-table tbody tr {
  position: relative;
  overflow: hidden;
}

.swipe-actions {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 80px;
  background: var(--color-error);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 1;
}

.swipe-actions.visible {
  opacity: 1;
  pointer-events: auto;
}

.swipe-delete-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 14px;
  font-weight: 600;
  padding: 1rem;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.swipe-delete-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

.swipe-delete-btn:focus {
  outline: 2px solid white;
  outline-offset: -2px;
}

/* Dark mode swipe actions */
.dark-theme .swipe-actions {
  background: var(--color-error-dark);
}

/* Pull-to-refresh indicator */
.pull-refresh-indicator {
  position: absolute;
  top: -60px;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1000;
  pointer-events: none;
}

.refresh-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border);
  border-top: 3px solid var(--color-brand-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.pull-refresh-indicator.ready .refresh-spinner,
.pull-refresh-indicator.refreshing .refresh-spinner {
  opacity: 1;
}

.refresh-text {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary);
}

/* Spin animation for refresh spinner */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Dark mode pull-to-refresh */
.dark-theme .refresh-spinner {
  border-color: var(--color-border);
  border-top-color: var(--color-brand-primary);
}

.dark-theme .refresh-text {
  color: var(--color-text-secondary);
}

/* Drag-and-drop reordering */
.drag-handle-header {
  width: 40px;
  text-align: center;
  cursor: grab;
  user-select: none;
}

.drag-handle {
  width: 40px;
  text-align: center;
  cursor: grab;
  color: #999;
  font-size: 18px;
  user-select: none;
}

.drag-handle:active {
  cursor: grabbing;
}

tr.dragging {
  opacity: 0.8;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  background: var(--color-bg-secondary);
}

tr.drag-placeholder {
  opacity: 0.5;
  background: #f5f5f5;
  border: 2px dashed #d32f2f;
}

.dark-theme tr.drag-placeholder {
  background: #333;
  border-color: var(--color-brand-primary);
}

/* Touch interaction improvements */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets on touch devices */
  .btn,
  button {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Prevent text selection during swipe */
  .history-table tbody tr {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
  }
  
  /* Smooth touch scrolling */
  .history-table-container {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Remove hover effects on touch devices */
  .history-table tbody tr:hover {
    background: inherit;
  }
}

/* Performance optimizations for touch gestures */
.history-table tbody tr {
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.container {
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Accessibility: Focus states for keyboard users */
.swipe-delete-btn:focus-visible {
  outline: 3px solid white;
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .history-table tbody tr,
  .container,
  .swipe-actions,
  .pull-refresh-indicator {
    transition: none;
  }
  
  .refresh-spinner {
    animation: none;
  }
}
