/**
 * Android PWA Styles - Optimized for EDA52 Honeywell Device
 * Mobile-first, touch-optimized design
 */

:root {
  --primary-color: #0062A3;
  --primary-dark: #004d7f;
  --primary-light: #3385b8;
  --secondary-color: #00A8E8;
  --success-color: #2E7D32;
  --warning-color: #F57C00;
  --error-color: #D32F2F;
  --text-primary: #1A1A1A;
  --text-secondary: #6B7280;
  --bg-primary: #FFFFFF;
  --bg-secondary: #F9FAFB;
  --border-color: #E5E7EB;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
  --touch-target: 48px;
  --border-radius: 12px;
  --spacing: 16px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Screen Management */
.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
  position: relative;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

#app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
}

.screen-section {
  display: none;
  width: 100%;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0; /* Important for flex children */
}

.screen-section.active {
  display: block;
}

/* Loading Screen */
#loading-screen {
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.loading-container {
  text-align: center;
  color: white;
}

.loading-container .logo {
  margin-bottom: 32px;
}

.loading-container .logo {
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-container .logo img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

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

/* Login Screen */
#login-screen {
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  padding: var(--spacing);
  min-height: 100vh;
  max-height: 100vh;
  position: relative;
  overflow: hidden;
}

#login-screen::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
  animation: pulse 20s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

.login-container {
  width: 100%;
  max-width: 420px;
  background: var(--bg-primary);
  border-radius: 20px;
  padding: 24px 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  position: relative;
  z-index: 1;
  animation: slideInUp 0.5s ease-out;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

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

/* Logo Section */
.logo-section {
  text-align: center;
  margin-bottom: 0.5rem;
  margin-top: 0.5rem;
  animation: slideInDown 0.8s ease-out;
  position: relative;
  z-index: 10;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border-radius: 0;
  backdrop-filter: none;
  border: none;
  margin: 0 auto;
  transition: all 0.3s ease;
  box-shadow: none;
  position: relative;
  width: auto;
  height: auto;
  overflow: visible;
}


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

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

.company-logo {
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
  width: 140px;
  height: auto;
  object-fit: contain;
  object-position: center center;
  transition: all 0.3s ease;
  display: block;
  flex-shrink: 0;
}

.logo-header {
  text-align: center;
  margin-bottom: 20px;
  margin-top: 0;
}

.logo-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  animation: fadeIn 0.6s ease-out 0.2s both;
}

.logo-header p {
  font-size: 12px;
  color: var(--text-secondary);
  animation: fadeIn 0.6s ease-out 0.4s both;
  margin: 0;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.logo-header h1 {
  font-size: 32px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.logo-header p {
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-install-app-wrap {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.login-install-app-btn {
  width: 100%;
  font-size: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.form-group label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 15px;
  margin-bottom: 4px;
}

/* Input Wrapper */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 16px;
  font-size: 18px;
  color: var(--text-secondary);
  z-index: 1;
  pointer-events: none;
  transition: color 0.2s;
}

.form-group input:focus ~ .input-icon,
.form-group:focus-within .input-icon {
  color: var(--primary-color);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 16px 48px 16px 48px;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  font-size: 16px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  background: var(--bg-primary);
  box-shadow: 0 4px 12px rgba(0, 98, 163, 0.15);
  transform: translateY(-1px);
}

/* Modern Select Dropdown */
.modern-select-wrapper {
  position: relative;
  width: 100%;
}

.modern-select {
  width: 100%;
  padding: 16px 50px 16px 16px;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  font-size: 16px;
  font-weight: 500;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  background-image: none;
}

.modern-select:focus {
  outline: none;
  border-color: var(--primary-color);
  background: var(--bg-primary);
  box-shadow: 0 4px 12px rgba(0, 98, 163, 0.15);
  transform: translateY(-1px);
}

.modern-select:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(0, 98, 163, 0.1);
}

.modern-select option {
  padding: 12px 16px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-weight: 500;
}

.modern-select option:checked {
  background: var(--primary-color);
  color: white;
}

.select-arrow {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-secondary);
  font-size: 12px;
  transition: transform 0.3s ease, color 0.3s ease;
}

.modern-select:focus + .select-arrow,
.modern-select-wrapper:hover .select-arrow {
  color: var(--primary-color);
  transform: translateY(-50%) scale(1.1);
}

.form-group input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

/* Password field wrapper */
.form-group:has(input[type="password"]) .input-wrapper {
  position: relative;
}

.form-group .toggle-password {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  transition: all 0.2s;
  z-index: 10;
}

.form-group .toggle-password:hover {
  background: var(--bg-secondary);
  color: var(--primary-color);
}

.form-group .toggle-password:active {
  transform: translateY(-50%) scale(0.95);
}

.checkbox-group {
  margin-top: -4px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  transition: color 0.2s;
}

.checkbox-group label:hover {
  color: var(--text-primary);
}

.checkbox-group input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary-color);
  border-radius: 4px;
}

/* Buttons */
.btn {
  padding: 14px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 98, 163, 0.3);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(0, 98, 163, 0.2);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

.btn-outline {
  background: transparent;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
}

.btn-outline:hover {
  background: rgba(0, 98, 163, 0.08);
}

.btn-success {
  background: var(--success-color);
  color: white;
}

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

.btn-large {
  width: 100%;
  padding: 18px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-top: 8px;
}

.btn .btn-text {
  display: inline-block;
}

.btn .btn-loader {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn.loading .btn-text {
  display: none;
}

.btn.loading .btn-loader {
  display: inline-flex;
}

.spinner-small {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  color: white;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

.icon-btn:active {
  transform: scale(0.95);
}

.logout-icon {
  display: inline-block;
  font-size: 22px;
  line-height: 1;
  color: white;
  font-weight: bold;
  width: 24px;
  height: 24px;
  text-align: center;
}

/* App Header */
.app-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  padding: 16px var(--spacing);
  box-shadow: 0 4px 12px rgba(0, 98, 163, 0.2);
  position: relative;
  z-index: 100;
  flex-shrink: 0; /* Prevent header from shrinking */
  width: 100%;
}

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

.header-logo-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.header-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  flex-shrink: 0;
}

.header-content h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.welcome-section {
  margin-bottom: 8px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.bluetooth-icon {
  width: 24px;
  height: 24px;
  display: block;
  transition: all 0.3s ease;
  position: relative;
}

.bluetooth-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Connected State - Blue with glow effect (matching blue.php) */
.bluetooth-icon.connected {
  color: #2563eb;
  filter: drop-shadow(0 0 6px rgba(37, 99, 235, 0.7));
  animation: pulse-connected 2s ease-in-out infinite;
}

@keyframes pulse-connected {
  0%, 100% {
    filter: drop-shadow(0 0 6px rgba(37, 99, 235, 0.7));
  }
  50% {
    filter: drop-shadow(0 0 10px rgba(37, 99, 235, 0.9));
  }
}

/* Disconnected State - Red/Gray with slash */
.bluetooth-icon.disconnected {
  color: #dc2626;
  opacity: 0.7;
}

/* Main Content */
.app-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: var(--spacing);
  padding-bottom: 80px; /* Space for footer */
  background: linear-gradient(180deg, #f0f7ff 0%, #ffffff 100%);
  min-height: 0; /* Important for flex children */
  width: 100%;
  box-sizing: border-box;
}

.screen-content {
  max-width: 600px;
  margin: 0 auto;
  animation: fadeInUp 0.4s ease-out;
}

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

.screen-content h2 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.screen-description {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 32px;
  line-height: 1.6;
}

/* Action areas: primary + secondary buttons (Cancel / Save, Back / Submit) */
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 24px;
}

/* Form-actions: Cancel left, Save/Submit right – professional dialog-style row */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.form-actions .btn {
  min-height: var(--touch-target);
  min-width: 120px;
}

.form-actions .btn-primary,
.form-actions .btn-success {
  min-width: 140px;
  order: 2; /* Save/Submit on the right */
}

.form-actions .btn-secondary {
  order: 1; /* Cancel/Back on the left */
}

/* Stacked variant: primary on top full-width, secondary below (mobile-friendly) */
.form-actions--stacked {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 10px;
}

.form-actions--stacked .btn-primary,
.form-actions--stacked .btn-success,
.form-actions--stacked .btn-secondary {
  order: unset;
  width: 100%;
  min-width: unset;
}

.form-actions--stacked .btn-primary,
.form-actions--stacked .btn-success {
  margin-bottom: 4px;
}

/* Selection Grid */
.selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 20px;
  margin-top: 32px;
}

.selection-card {
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  position: relative;
  overflow: hidden;
}

.selection-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.selection-card:hover::before,
.selection-card:active::before {
  transform: scaleX(1);
}

.selection-card:active {
  transform: scale(0.96) translateY(2px);
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(0, 98, 163, 0.2);
}

.selection-card.selected {
  border-color: var(--primary-color);
  background: linear-gradient(135deg, rgba(0, 98, 163, 0.08) 0%, rgba(0, 168, 232, 0.08) 100%);
  box-shadow: 0 4px 16px rgba(0, 98, 163, 0.15);
}

.selection-card.selected::before {
  transform: scaleX(1);
}

.selection-card .card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  font-size: 24px;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 98, 163, 0.3);
}

.selection-card.selected .card-icon {
  box-shadow: 0 6px 16px rgba(0, 98, 163, 0.4);
  transform: scale(1.1);
}

.selection-card h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.selection-card p {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Weight Display */
.weight-display-container {
  background: var(--bg-primary);
  border-radius: var(--border-radius);
  padding: 32px;
  margin: 24px 0;
  box-shadow: var(--shadow);
  text-align: center;
}

.weight-display {
  margin-bottom: 16px;
}

.weight-value {
  font-size: 64px;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1;
}

.weight-unit {
  font-size: 24px;
  color: var(--text-secondary);
  margin-left: 8px;
}

.stability-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.stability-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: pulse 2s infinite;
}

.stability-indicator.stable .stability-dot {
  background: var(--success-color);
  animation: none;
}

.stability-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.stability-indicator.stable .stability-text {
  color: var(--success-color);
  font-weight: 600;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Bluetooth Controls */
.bluetooth-controls {
  margin: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bluetooth-status-card {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.bluetooth-status-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: all 0.3s ease;
}

.status-dot.connected {
  background: var(--success-color);
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
  animation: pulse-dot 2s infinite;
}

.status-dot.disconnected {
  background: var(--text-secondary);
}

.status-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.bluetooth-status-indicator.connected .status-text {
  color: var(--success-color);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

.bluetooth-buttons-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.btn-bluetooth {
  background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
  transition: all 0.3s ease;
}

.btn-bluetooth:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(74, 144, 226, 0.4);
}

.btn-bluetooth:active:not(:disabled) {
  transform: translateY(0);
}

.btn-bluetooth:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.btn-icon {
  font-size: 20px;
  line-height: 1;
}

.btn-label {
  font-weight: 600;
}

.bluetooth-warning {
  background: #FFF3CD;
  border: 2px solid #FFC107;
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.warning-icon {
  font-size: 20px;
  color: #856404;
  flex-shrink: 0;
}

.warning-text {
  font-size: 13px;
  color: #856404;
  line-height: 1.4;
}

/* Variance Display */
.variance-display {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
}

.variance-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.variance-label {
  font-weight: 600;
  color: var(--text-primary);
}

.variance-value {
  font-weight: 700;
  font-size: 18px;
}

.variance-value.ok {
  color: var(--success-color);
}

.variance-value.warning {
  color: var(--warning-color);
}

.variance-value.error {
  color: var(--error-color);
}

.variance-value.low_weight {
  color: var(--error-color);
  animation: pulse-warning 1s ease-in-out infinite;
}

.variance-value.high_weight {
  color: var(--error-color);
  animation: pulse-warning 1s ease-in-out infinite;
}

.variance-message {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

.variance-message.ok {
  background-color: rgba(34, 197, 94, 0.1);
  color: var(--success-color);
}

.variance-message.warning {
  background-color: rgba(251, 191, 36, 0.1);
  color: var(--warning-color);
}

.variance-message.error,
.variance-message.low_weight,
.variance-message.high_weight {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--error-color);
  font-weight: 600;
}

@keyframes pulse-warning {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.tolerance-info {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Progress Bar */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  transition: width 0.3s;
  width: 0%;
}

/* Orders List */
.orders-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.order-card {
  background: linear-gradient(135deg, #ffffff, #f3f8fc);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 16px;
  padding: 18px 20px;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.order-card:active {
  transform: scale(0.97);
  border-color: #0062A3;
  box-shadow: 0 2px 8px rgba(0, 98, 163, 0.3);
}

.order-card h3 {
  font-size: 18px;
  font-weight: 600;
  color: #003a63;
  margin-bottom: 8px;
}

.order-card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 4px 0;
}

/* Materials Summary */
.materials-summary {
  background: var(--bg-primary);
  border-radius: var(--border-radius);
  padding: 20px;
  margin: 24px 0;
  box-shadow: var(--shadow);
}

.material-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

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

.material-item-name {
  font-weight: 600;
  color: var(--text-primary);
}

.material-item-weight {
  color: var(--text-secondary);
}

/* Footer */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  padding: 12px var(--spacing);
  display: flex;
  gap: 16px;
  justify-content: center;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
  z-index: 100;
}

.nav-btn {
  flex: 0 0 56px;
  height: 56px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #0062A3, #0091D9);
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  min-height: var(--touch-target);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 98, 163, 0.35);
}

.nav-btn:active {
  background: linear-gradient(135deg, #004c7b, #007ab4);
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 2px 6px rgba(0, 98, 163, 0.4);
}

.nav-btn-icon {
  display: inline-block;
  font-size: 22px;
  line-height: 1;
}

/* Global loading overlay (blocks repeated taps during backend calls) */
.global-loading-overlay[hidden] {
  display: none !important;
}

.global-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: auto;
}

.global-loading-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
}

.global-loading-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 190px;
  padding: 18px 22px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.global-loading-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid rgba(0, 98, 163, 0.2);
  border-top-color: #0062A3;
  animation: global-loading-spin 0.8s linear infinite;
}

.global-loading-text {
  margin: 0;
  font-size: 15px;
  color: var(--text-primary);
  font-weight: 500;
}

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

/* Install App Banner (PWA) */
.install-app-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 999;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.2);
  padding: 12px var(--spacing);
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.install-app-banner-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 600px;
  margin: 0 auto;
  flex-wrap: wrap;
}
.install-app-icon {
  font-size: 24px;
  flex-shrink: 0;
}
.install-app-text {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  line-height: 1.3;
}
.install-app-btn {
  flex-shrink: 0;
  background: white !important;
  color: var(--primary-color) !important;
  border: none !important;
  font-weight: 600;
}
.install-app-dismiss {
  background: transparent;
  border: none;
  color: white;
  font-size: 24px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  opacity: 0.9;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 90%;
}

.toast {
  background: var(--text-primary);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  animation: slideDown 0.3s;
  font-size: 14px;
}

.toast.success {
  background: var(--success-color);
}

.toast.error {
  background: var(--error-color);
}

.toast.warning {
  background: var(--warning-color);
}

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

/* Alert / Error Modal - professional popup */
.alert-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.alert-modal.is-open {
  opacity: 1;
  visibility: visible;
}

.alert-modal[hidden] {
  display: none !important;
}

.alert-modal:not([hidden]).is-open {
  display: flex !important;
}

.alert-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.alert-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2), 0 8px 16px rgba(0, 0, 0, 0.12);
  padding: 24px;
  text-align: center;
  animation: alertModalIn 0.3s ease;
}

@keyframes alertModalIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.alert-modal-icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.alert-modal-icon {
  font-size: 28px;
  line-height: 1;
  font-weight: 700;
}

.alert-modal.error .alert-modal-icon-wrap {
  background: rgba(211, 47, 47, 0.12);
  color: var(--error-color);
}

.alert-modal.error .alert-modal-icon::before {
  content: "✕";
}

.alert-modal.warning .alert-modal-icon-wrap {
  background: rgba(245, 124, 0, 0.12);
  color: var(--warning-color);
}

.alert-modal.warning .alert-modal-icon::before {
  content: "!";
  font-family: inherit;
  font-weight: 700;
}

.alert-modal.success .alert-modal-icon-wrap {
  background: rgba(46, 125, 50, 0.12);
  color: var(--success-color);
}

.alert-modal.success .alert-modal-icon::before {
  content: "✓";
}

.alert-modal.info .alert-modal-icon-wrap {
  background: rgba(0, 98, 163, 0.12);
  color: var(--primary-color);
}

.alert-modal.info .alert-modal-icon::before {
  content: "i";
  font-style: italic;
  font-weight: 700;
  font-family: Georgia, serif;
}

.alert-modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px;
  line-height: 1.3;
}

.alert-modal-message {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 20px;
}

.alert-modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

.alert-modal-actions--row {
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.alert-modal-btn {
  min-width: 100px;
  min-height: var(--touch-target);
  font-weight: 600;
  padding: 12px 20px;
}

/* Error Messages */
.error-message {
  background: linear-gradient(135deg, rgba(211, 47, 47, 0.1) 0%, rgba(211, 47, 47, 0.05) 100%);
  color: var(--error-color);
  padding: 14px 18px;
  border-radius: 12px;
  border: 2px solid rgba(211, 47, 47, 0.2);
  margin: 20px 0 0 0;
  font-size: 14px;
  font-weight: 500;
  animation: shake 0.4s ease-out;
  box-shadow: 0 2px 8px rgba(211, 47, 47, 0.1);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.loading-message {
  text-align: center;
  padding: 32px;
  color: var(--text-secondary);
}

.spinner-small {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

/* Success Screen */
.success-content {
  text-align: center;
  padding: 48px 24px;
}

.success-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--success-color);
  color: white;
  font-size: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}

/* Input Large */
.input-large {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: var(--touch-target);
}

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

/* Responsive Adjustments */
@media (max-width: 480px) {
  .weight-value {
    font-size: 48px;
  }
  
  .selection-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  
  .selection-card {
    min-height: 130px;
    padding: 20px 16px;
  }
  
  .selection-card .card-icon {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }
  
  .screen-content h2 {
    font-size: 24px;
  }
}

/* Small Screen Optimizations (360px width) */
@media (max-width: 360px) {
  :root {
    --spacing: 12px;
    --border-radius: 10px;
  }
  
  /* Login Screen */
  .login-container {
    max-width: 100%;
    padding: 28px 20px;
    border-radius: 16px;
  }
  
  .logo-section {
    margin-bottom: 0.25rem;
    margin-top: 0.25rem;
  }
  
  .logo-container {
    width: auto;
    height: auto;
  }
  
  .company-logo {
    width: 120px;
    height: auto;
  }
  
  .logo-header {
    margin-bottom: 12px;
  }
  
  .logo-header p {
    font-size: 11px;
  }
  
  .login-container {
    padding: 20px 16px;
  }
  
  .header-logo {
    width: 40px;
    height: 40px;
  }
  
  .header-content h1 {
    font-size: 18px;
  }
  
  .logo-header h1 {
    font-size: 26px;
  }
  
  .logo-header p {
    font-size: 13px;
  }
  
  .login-form {
    gap: 20px;
  }
  
  .form-group {
    gap: 8px;
  }
  
  .form-group label {
    font-size: 14px;
  }
  
  .form-group input {
    padding: 14px 44px 14px 44px;
    font-size: 16px;
  }
  
  .input-icon {
    left: 14px;
    font-size: 16px;
  }
  
  .btn-large {
    padding: 16px;
    font-size: 17px;
  }
  
  /* App Header */
  .app-header {
    padding: 12px var(--spacing);
  }
  
  .header-content h1 {
    font-size: 18px;
  }
  
  /* Main Content */
  .app-main {
    padding: var(--spacing);
    padding-bottom: 70px;
  }
  
  .screen-content h2 {
    font-size: 22px;
  }
  
  .screen-description {
    font-size: 13px;
    margin-bottom: 24px;
  }
  
  /* Selection Grid */
  .selection-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 24px;
  }
  
  .selection-card {
    min-height: 120px;
    padding: 16px 12px;
  }
  
  .selection-card .card-icon {
    width: 40px;
    height: 40px;
    font-size: 20px;
    margin-bottom: 10px;
  }
  
  .selection-card h3 {
    font-size: 18px;
  }
  
  .selection-card p {
    font-size: 12px;
  }
  
  /* Weight Display */
  .weight-display-container {
    padding: 24px 20px;
    margin: 20px 0;
  }
  
  .weight-value {
    font-size: 56px;
  }
  
  .weight-unit {
    font-size: 20px;
  }
  
  /* Buttons */
  .btn {
    padding: 12px 20px;
    font-size: 15px;
    min-height: 44px;
  }
  
  .btn-large {
    padding: 14px;
    font-size: 16px;
  }
  
  .bluetooth-buttons-grid {
    gap: 10px;
  }
  
  .btn-bluetooth,
  .btn-action {
    padding: 14px 20px;
    font-size: 15px;
  }
  
  .btn-icon {
    font-size: 18px;
  }
  
  .bluetooth-status-card {
    padding: 12px;
  }
  
  .status-text {
    font-size: 13px;
  }
  
  /* Footer */
  .app-footer {
    padding: 10px var(--spacing);
  }
  
  .nav-btn {
    padding: 10px;
    font-size: 14px;
    min-height: 44px;
  }
}

/* Height-specific adjustments for 592px height */
@media (max-height: 600px) {
  #login-screen {
    padding: 12px;
  }
  
  .login-container {
    padding: 24px 20px;
  }
  
  .logo-header {
    margin-bottom: 24px;
  }
  
  .logo-header img {
    width: 80px;
    margin-bottom: 12px;
  }
  
  .logo-header h1 {
    font-size: 24px;
    margin-bottom: 4px;
  }
  
  .logo-header p {
    font-size: 12px;
  }
  
  .login-form {
    gap: 16px;
  }
  
  .app-main {
    padding: 12px;
  }
  
  .screen-content {
    padding-top: 8px;
  }
}

/* Landscape Orientation */
@media (orientation: landscape) and (max-height: 500px) {
  .app-header {
    padding: 8px var(--spacing);
  }
  
  .app-main {
    padding: 12px;
  }
  
  .weight-value {
    font-size: 48px;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000000;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

