@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-light: #ecfdf5;
  --primary-glow: rgba(16, 185, 129, 0.15);
  
  --secondary: #4f46e5;
  --secondary-hover: #4338ca;
  --secondary-light: #e0e7ff;
  
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-light: #fef2f2;
  
  --warning: #f59e0b;
  --warning-light: #fefbeb;
  
  --success: #10b981;
  --success-light: #ecfdf5;
  
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-input: #f1f5f9;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-white: #ffffff;
  
  --border: #e2e8f0;
  --border-focus: #cbd5e1;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 15px;
  overflow-x: hidden;
  padding-bottom: 60px; /* Spacer for fixed mobile nav if any */
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Animations */
@keyframes pulseGlow {
  0% { transform: scale(0.95); opacity: 0.5; }
  50% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.5; }
}

@keyframes fadeScaleIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes glowCheck {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  100% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
}

.animate-pulse {
  animation: pulseGlow 2s infinite ease-in-out;
}

.fade-in {
  animation: fadeScaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.slide-up {
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Container */
.app-container {
  max-width: 100%;
  margin: 0 auto;
  padding: 16px;
}

@media (min-width: 1024px) {
  .app-container {
    padding: 16px 24px;
  }
}

/* Login Panel */
.login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  background: radial-gradient(circle at 10% 20%, rgba(240, 253, 244, 1) 0%, rgba(248, 250, 252, 1) 90%);
}

.login-card {
  background: var(--bg-card);
  width: 100%;
  max-width: 420px;
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-premium);
  border: 1px solid var(--border);
  animation: fadeScaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo svg {
  width: 56px;
  height: 56px;
  color: var(--primary);
  margin-bottom: 12px;
}

.login-logo h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  color: var(--text-main);
  font-weight: 700;
  letter-spacing: -0.5px;
}

.login-logo p {
  color: var(--text-muted);
  font-size: 14px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-main);
  margin-bottom: 6px;
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: var(--bg-input);
  color: var(--text-main);
  font-size: 15px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--bg-card);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.role-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.role-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.role-btn.active {
  background-color: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-hover);
}

.role-btn svg {
  width: 20px;
  height: 20px;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background-color: var(--primary);
  color: var(--text-white);
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

/* App Layout */
.app-header {
  background-color: var(--bg-card);
  padding: 16px 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand svg {
  width: 32px;
  height: 32px;
  color: var(--primary);
}

.brand-title {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 700;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  background-color: var(--primary-light);
  color: var(--primary-hover);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.btn-logout {
  padding: 8px 14px;
  background-color: #f1f5f9;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  background-color: #e2e8f0;
  color: var(--text-main);
}

/* Phase Bar */
.phase-banner {
  background-color: var(--secondary-light);
  color: var(--secondary);
  border: 1px solid rgba(79, 70, 229, 0.15);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14.5px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.phase-tag {
  background-color: var(--secondary);
  color: var(--text-white);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  margin-left: 8px;
}

/* Grid Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  padding: 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-focus);
}

.stat-card.active-card {
  background-color: var(--primary-light);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.stat-card.primary::before { background-color: var(--primary); }
.stat-card.secondary::before { background-color: var(--secondary); }
.stat-card.danger::before { background-color: var(--danger); }
.stat-card.warning::before { background-color: var(--warning); }

.stat-title {
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1;
  font-family: 'Outfit', sans-serif;
}

.stat-sub {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 6px;
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 1px;
}

.tab-btn {
  padding: 12px 20px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Filters & Actions */
.workspace-controls {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.filter-mode-switch {
  display: inline-flex;
  background-color: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  align-self: flex-start;
}

.filter-mode-btn {
  background: none;
  border: none;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-mode-btn.active {
  background-color: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.filter-selection {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.letter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 6px;
  width: 100%;
}

.letter-btn {
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 0;
  text-align: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.letter-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.letter-btn.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--text-white);
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

/* Card List */
.product-list-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.product-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  transition: all 0.2s ease;
  position: relative;
}

.product-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-focus);
}

.product-info-column {
  flex: 1;
}

.product-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.sku-badge {
  background-color: var(--bg-input);
  color: var(--text-main);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.loc-badge {
  background-color: var(--secondary-light);
  color: var(--secondary);
  padding: 2px 6px;
  border-radius: 4px;
}

.product-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.product-stock-reference {
  display: flex;
  gap: 16px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.stock-value {
  font-weight: 600;
  color: var(--text-main);
}

/* Input Area in Card */
.product-count-area {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 220px;
}

.counter-control {
  display: flex;
  align-items: center;
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  height: 48px;
}

.counter-btn {
  background: none;
  border: none;
  width: 44px;
  height: 100%;
  font-size: 20px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

.counter-btn:hover {
  background-color: #cbd5e1;
}

.counter-btn:active {
  background-color: #94a3b8;
}

.counter-input {
  width: 72px;
  height: 100%;
  border: none;
  background: none;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.counter-input:focus {
  outline: none;
  background-color: var(--bg-card);
}

.saved-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.saved-indicator.show {
  opacity: 1;
}

.saved-indicator svg {
  width: 14px;
  height: 14px;
}

.stamp-info {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: right;
}

.stamp-info .stamp-user {
  font-weight: 600;
  color: var(--text-main);
}

/* Mobile responsive layout for cards */
@media (max-width: 680px) {
  .product-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
  }
  
  .product-count-area {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  
  .stamp-info {
    text-align: left;
  }
}

/* Admin Dashboard Table */
.panel-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.panel-title {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.data-table th {
  background-color: var(--bg-input);
  color: var(--text-main);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr.row-diff-major {
  background-color: var(--danger-light);
}

.data-table tr.row-diff-minor {
  background-color: var(--warning-light);
}

.data-table tr.row-match {
  background-color: var(--success-light);
}

/* Lock Status Badge */
.lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 4px;
}

.lock-badge.locked {
  background-color: var(--danger-light);
  color: var(--danger);
}

.lock-badge.unlocked {
  background-color: var(--success-light);
  color: var(--success);
}

/* Control Controls Grid */
.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.control-box {
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: var(--radius-md);
  background-color: var(--bg-app);
}

.control-box h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* Drag and Drop Zone */
.upload-zone {
  border: 2px dashed var(--border-focus);
  border-radius: var(--radius-md);
  padding: 30px;
  text-align: center;
  background-color: var(--bg-app);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 12px;
}

.upload-zone:hover {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.upload-zone svg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Audit Log Feed */
.audit-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.audit-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-app);
  border-left: 3px solid var(--border);
  font-size: 13px;
  line-height: 1.4;
}

.audit-item.success {
  border-left-color: var(--success);
}

.audit-item.warning {
  border-left-color: var(--warning);
}

.audit-user {
  font-weight: 600;
  color: var(--text-main);
  margin-right: 6px;
}

.audit-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: 12px;
}

/* QR Code and Local Share Box */
.share-box {
  background-color: var(--primary-light);
  color: var(--primary-hover);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.share-details h4 {
  font-weight: 700;
  margin-bottom: 4px;
}

.share-details p {
  font-size: 13px;
  color: var(--text-muted);
}

/* Floating Barcode Scanner Viewport */
.scanner-container {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0,0,0,0.8);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.scanner-box {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.scanner-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #f1f5f9;
  border: none;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

#reader {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* Utility buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-secondary {
  background-color: var(--secondary);
  color: var(--text-white);
}
.btn-secondary:hover { background-color: var(--secondary-hover); }

.btn-outline {
  background-color: var(--bg-card);
  border-color: var(--border);
  color: var(--text-main);
}
.btn-outline:hover { background-color: var(--bg-input); }

.btn-danger {
  background-color: var(--danger);
  color: var(--text-white);
}
.btn-danger:hover { background-color: var(--danger-hover); }

.search-bar-container {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 18px;
  height: 18px;
}

.search-field {
  padding-left: 42px;
}

/* ==========================================================================
   MOBILE-FIRST RESPONSIVE STYLING & PREMIUM LAYOUT ENHANCEMENTS
   ========================================================================== */

/* 1. Responsive Multi-column Grid (Used in User CRUD etc.) */
.responsive-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
  align-items: start;
}

/* Smooth Tab Navigation Scrolling on Mobile */
.nav-tabs {
  scrollbar-width: none; /* Firefox */
  -webkit-overflow-scrolling: touch;
}
.nav-tabs::-webkit-scrollbar {
  display: none; /* Hide Chrome/Safari/Opera scrollbar */
}

/* Force horizontal overflow handling on data tables to avoid squishing columns */
.data-table {
  min-width: 950px;
}

/* Ensure User List Table inside CRUD is reasonably wide but scrollable */
#usersTable {
  min-width: 500px;
}

/* 2. Media Queries for Responsive Views */

/* A. Tablets and Medium Viewports (max-width: 992px) */
@media (max-width: 992px) {
  .responsive-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

/* B. Mobile Landscape and Small Tablets (max-width: 768px) */
@media (max-width: 768px) {
  .app-container {
    padding: 12px;
  }
  
  .control-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* C. Phone Viewports (max-width: 600px) */
@media (max-width: 600px) {
  /* Fix Current Round Status Banner clipping/cutoff */
  .phase-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    font-size: 13.5px;
  }
  
  #phaseLockDisplay {
    align-self: flex-start;
    margin-top: 2px;
  }
  
  /* Make App Header stack gracefully */
  .app-header {
    padding: 12px 16px;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
  }
  
  .brand {
    justify-content: center;
  }
  
  .user-info {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
  }
  
  .btn-logout {
    margin-left: auto;
  }
  
  /* Navigation Tab adjustments */
  .tab-btn {
    padding: 10px 14px;
    font-size: 13.5px;
  }
  
  /* Filter switch styling */
  .workspace-controls {
    padding: 12px;
    gap: 12px;
  }
  
  .filter-mode-switch {
    display: flex;
    width: 100%;
  }
  
  .filter-mode-btn {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    font-size: 12.5px;
  }
  
  .filter-selection {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  #locFilterDropdown {
    max-width: 100% !important;
    width: 100%;
  }
}

/* D. Micro Viewports & iPhones (max-width: 480px) */
@media (max-width: 480px) {
  /* Stagger search input and scan button vertically to prevent squishing */
  .search-bar-container {
    flex-direction: column;
    gap: 8px;
  }
  
  .search-bar-container button {
    width: 100%;
    justify-content: center;
    height: 44px;
  }
  
  /* Ultra-Premium 2x2 Dashboard grid for mobile instead of massive vertical lists */
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
  }
  
  .stat-card {
    padding: 12px 10px;
  }
  
  .stat-title {
    font-size: 11px;
    margin-bottom: 4px;
  }
  
  .stat-value {
    font-size: 18px;
  }
  
  .stat-sub {
    font-size: 9.5px;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  /* Product Cards Mobile Optimization */
  .product-card {
    padding: 12px;
    gap: 12px;
  }
  
  .product-title {
    font-size: 15px;
  }
  
  .product-meta {
    gap: 8px;
    margin-bottom: 4px;
  }
  
  .product-stock-reference {
    gap: 10px;
    font-size: 12px;
  }
  
  /* Optimize counter placement - Full width button controls for fat-finger prevention */
  .product-count-area {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
  }
  
  .counter-control {
    width: 100%;
    justify-content: space-between;
    height: 44px;
  }
  
  .counter-btn {
    flex: 1;
    max-width: 60px;
  }
  
  .counter-input {
    flex: 2;
    width: auto;
  }
  
  .stamp-info {
    text-align: left;
    width: 100%;
    font-size: 11px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  /* Thai Letter Buttons Grid optimization on mobile */
  .letter-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
  }
  
  .letter-btn {
    padding: 8px 0;
    font-size: 13px;
  }
  
  /* Login screen card spacing */
  .login-card {
    padding: 24px 16px;
  }
  
  .login-logo h1 {
    font-size: 22px;
  }
}

/* E. Narrowest Screens (max-width: 360px) */
@media (max-width: 360px) {
  .letter-grid {
    grid-template-columns: repeat(5, 1fr);
  }
  
  .user-info {
    flex-direction: column;
    align-items: center;
  }
  
  .btn-logout {
    margin-left: 0;
    width: 100%;
    text-align: center;
  }
}
