/* =============================================================================
   Mobile CSS Variables (inherits from styles.css :root, with mobile-specific)
   ============================================================================= */

:root {
  /* Mobile-specific colors */
  --mobile-header-gradient-start: #1976d2;
  --mobile-header-gradient-end: #1565c0;
  --mobile-tab-active: #1976d2;
  --mobile-tab-inactive: #757575;
}

/* Mobile dark mode */
[data-theme="dark"] {
  --mobile-header-gradient-start: #1565c0;
  --mobile-header-gradient-end: #0d47a1;
  --mobile-tab-active: #64b5f6;
  --mobile-tab-inactive: #9e9e9e;
}

/* System preference dark mode for mobile */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --mobile-header-gradient-start: #1565c0;
    --mobile-header-gradient-end: #0d47a1;
    --mobile-tab-active: #64b5f6;
    --mobile-tab-inactive: #9e9e9e;
  }
}

/* =============================================================================
   Mobile App Layout
   ============================================================================= */

.mobile-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-body);
}

/* Mobile Header */
.mobile-header {
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: linear-gradient(135deg, var(--mobile-header-gradient-start) 0%, var(--mobile-header-gradient-end) 100%);
  color: var(--text-inverse);
  box-shadow: var(--shadow-md);
  z-index: 100;
}

.mobile-header .header-left {
  display: flex;
  align-items: center;
}

.mobile-header .company-logo {
  height: 32px;
  width: auto;
  border-radius: 4px;
}

.mobile-header .company-name {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
  text-align: center;
}

.mobile-header .header-right {
  display: flex;
  align-items: center;
}

.mobile-header .user-menu-btn {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  padding: 8px;
  cursor: pointer;
}

/* Mobile Content */
.mobile-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: 72px; /* Space for bottom nav */
}

/* Bottom Navigation */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  background: none;
  border: none;
  color: var(--mobile-tab-inactive);
  font-size: 12px;
  cursor: pointer;
  transition: color var(--transition-fast);
  min-height: 48px;
}

.tab-item i {
  font-size: 20px;
  margin-bottom: 4px;
}

.tab-item.active {
  color: var(--mobile-tab-active);
}

.tab-item:active {
  background-color: rgba(25, 118, 210, 0.1);
}

/* Mobile Home Page */
.mobile-home {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Main Selector */
.mobile-main-selector {
  padding: 10px 15px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.mobile-main-selector label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.mobile-main-selector select {
  width: 100%;
  padding: 10px;
  font-size: 16px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-card);
  color: var(--text-primary);
}

.mobile-main-selector .selector-search {
  width: 100%;
  padding: 10px;
  font-size: 16px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-card);
  color: var(--text-primary);
  margin-bottom: 8px;
}

.mobile-main-selector .selector-search::placeholder {
  color: var(--text-secondary);
}

/* Stats Summary */
.mobile-stats h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* Quick Actions */
.mobile-quick-actions h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.action-groups {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.action-group .group-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  margin-bottom: 8px;
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.action-wrapper {
  display: contents;
}

.mobile-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 12px;
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  min-height: 80px;
  box-shadow: 0 2px 8px rgba(25, 118, 210, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}

.mobile-action-btn:active {
  transform: scale(0.98);
  box-shadow: 0 1px 4px rgba(25, 118, 210, 0.2);
}

.mobile-action-btn i {
  font-size: 24px;
}

/* Mobile Items Page */
.mobile-items-page {
  display: flex;
  flex-direction: column;
  height: 100%;              /* Fill parent container instead of viewport calc */
  margin: -16px;
  margin-bottom: -72px;      /* Extend into padding area */
  padding-bottom: 16px;      /* Add back some bottom spacing for content */
}

/* Stage Tabs */
.stage-tabs {
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 8px;
  scrollbar-width: none;
}

.stage-tabs::-webkit-scrollbar {
  display: none;
}

.stage-tab {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}

.stage-tab.active {
  color: var(--text-inverse);
  border-radius: 8px 8px 0 0;
  border-bottom-color: currentColor;
}

.stage-tab .tab-count {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
}

.stage-tab.active .tab-count {
  background: rgba(255, 255, 255, 0.3);
}

/* Filter chip count bubble - used by maintenance, compliance, invoices */
.filter-chip-count {
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  min-width: 16px;
  text-align: center;
  background: var(--bg-tertiary);
}

.filter-chip-count.active {
  background: rgba(255, 255, 255, 0.2);
}

/* Items List */
.items-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
}

.empty-stage i {
  font-size: 48px;
  margin-bottom: 12px;
}

/* Item Card */
.mobile-item-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.mobile-item-card .card-header {
  margin-bottom: 8px;
}

.mobile-item-card .card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.mobile-item-card .card-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.mobile-item-card .card-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mobile-item-card .card-field {
  display: flex;
  gap: 4px;
  font-size: 12px;
  background: var(--bg-secondary);
  padding: 4px 8px;
  border-radius: 4px;
}

.mobile-item-card .field-label {
  color: var(--text-muted);
  text-transform: capitalize;
}

.mobile-item-card .field-value {
  color: var(--text-primary);
}

.mobile-item-card .card-footer {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.mobile-item-card .item-id {
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
}

/* Item Card - New Layout with Thumbnail */
.mobile-item-card .card-content-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.mobile-item-card .card-thumbnail {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.mobile-item-card .card-thumbnail.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  color: var(--text-muted);
}

.mobile-item-card .card-thumbnail.placeholder i {
  font-size: 20px;
}

.mobile-item-card .card-main-content {
  flex: 1;
  min-width: 0; /* Allow text truncation */
}

.mobile-item-card .card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.mobile-item-card .card-title {
  flex: 1;
  min-width: 0;  /* Critical for text truncation in flex */
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Confidence Badge */
.mobile-item-card .confidence-badge {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  max-width: 80px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-item-card .confidence-badge.high {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.mobile-item-card .confidence-badge.medium {
  background-color: #fff3e0;
  color: #ef6c00;
}

.mobile-item-card .confidence-badge.low {
  background-color: #ffebee;
  color: #c62828;
}

/* Dark mode confidence badges */
[data-theme="dark"] .mobile-item-card .confidence-badge.high {
  background-color: rgba(46, 125, 50, 0.2);
  color: #81c784;
}

[data-theme="dark"] .mobile-item-card .confidence-badge.medium {
  background-color: rgba(239, 108, 0, 0.2);
  color: #ffb74d;
}

[data-theme="dark"] .mobile-item-card .confidence-badge.low {
  background-color: rgba(198, 40, 40, 0.2);
  color: #e57373;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mobile-item-card .confidence-badge.high {
    background-color: rgba(46, 125, 50, 0.2);
    color: #81c784;
  }

  :root:not([data-theme="light"]) .mobile-item-card .confidence-badge.medium {
    background-color: rgba(239, 108, 0, 0.2);
    color: #ffb74d;
  }

  :root:not([data-theme="light"]) .mobile-item-card .confidence-badge.low {
    background-color: rgba(198, 40, 40, 0.2);
    color: #e57373;
  }
}

.mobile-item-card .card-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.mobile-item-card .card-category {
  font-size: 12px;
  color: var(--text-muted);
}

/* Metadata Grid */
.mobile-item-card .card-metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.mobile-item-card .metadata-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  background: var(--bg-secondary);
  padding: 4px 8px;
  border-radius: 4px;
  max-width: 100%;
}

.mobile-item-card .metadata-label {
  color: var(--text-muted);
  text-transform: capitalize;
}

.mobile-item-card .metadata-label::after {
  content: ":";
}

.mobile-item-card .metadata-value {
  color: var(--text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Mobile Settings Page */
.mobile-settings-page {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.mobile-settings-page h2 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.user-info-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.user-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark, #1565c0) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse);
  font-size: 32px;
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-role {
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.settings-section {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.settings-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.mobile-logout-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: 8px;
  background: var(--color-danger);
  color: var(--text-inverse);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.mobile-logout-btn:active {
  background: var(--color-danger-dark, #d32f2f);
}

.about-info {
  color: var(--text-secondary);
}

.about-info .version {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Override login page styles for mobile */
.mobile-app .login-page-container {
  padding: 16px;
}

.mobile-app .login-container {
  max-width: 100%;
  padding: 24px;
}

.mobile-app .login-container input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px; /* Prevents zoom on iOS */
}

.mobile-app .login-container button {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
}

/* Touch-friendly sizing */
.mobile-btn {
  min-height: 48px;
  padding: 12px 24px;
}

/* Spinner positioning for mobile */
.mobile-app .spinner-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
}

/* Modal adjustments for mobile */
.mobile-app .modal-overlay {
  padding: 16px;
}

.mobile-app .modal-content {
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  width: 100%;
  max-width: 100%;
  border-radius: 16px;
}

/* Safe area padding for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
  .mobile-bottom-nav {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    height: calc(56px + env(safe-area-inset-bottom));
  }

  .mobile-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .mobile-items-page {
    margin-bottom: calc(-72px - env(safe-area-inset-bottom));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

/* =============================================================================
   Visitor Application Page (USDOT Experts)
   ============================================================================= */

.mobile-visitor-app {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-body);
  color: var(--text-primary);
}

.visitor-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.visitor-header img {
  height: 40px;
  width: auto;
}

/* Resume Scanner on Mobile */
.resume-photo-scanner {
  padding: 16px;
  color: var(--text-primary);
}

.resume-photo-scanner h2 {
  font-size: 20px;
  text-align: center;
  color: var(--text-primary);
}

.resume-photo-scanner p {
  color: var(--text-secondary);
}

.resume-photo-scanner .photo-inputs label {
  width: 100%;
  text-align: center;
}

.resume-photo-scanner .actions button {
  padding: 14px 20px;
  font-size: 16px;
  min-height: 48px;
}

/* Scan Results on Mobile */
.scan-results {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
}

.scan-results h3 {
  font-size: 18px;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.scan-results h4 {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.scan-result-field {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

/* Application Form on Mobile */
.mobile-visitor-app .form-wrapper {
  padding: 16px;
}

.mobile-visitor-app .form-wrapper input,
.mobile-visitor-app .form-wrapper select,
.mobile-visitor-app .form-wrapper textarea {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px; /* Prevents zoom on iOS */
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 12px;
  background: var(--bg-card);
  color: var(--text-primary);
}

.mobile-visitor-app .form-wrapper label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.mobile-visitor-app .form-wrapper button[type="submit"],
.mobile-visitor-app .form-wrapper .submit-btn {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  font-weight: 600;
  background: #4CAF50;
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 16px;
}

/* Confidence indicator */
.confidence-indicator {
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
}

/* File upload buttons on mobile */
.mobile-visitor-app input[type="file"] {
  display: block;
  width: 100%;
  padding: 12px;
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  margin-bottom: 12px;
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Photo preview grid on mobile */
.photo-preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.photo-preview-grid img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
}

/* Spinner animation for resume scanning */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* =============================================================================
   Receipt Scanner Styles
   ============================================================================= */

.mobile-receipts-page {
  padding: 8px;
}

.receipt-scanner {
  padding: 10px;
  background-color: var(--bg-body);
}

.receipt-scanner h2 {
  margin-bottom: 12px;
  color: var(--text-primary);
  font-size: 20px;
}

.receipt-scanner > p {
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-size: 14px;
}

/* Receipt capture buttons */
.receipt-btn-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.receipt-btn-camera,
.receipt-btn-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  flex: 1;
}

.receipt-btn-camera {
  background-color: var(--color-primary);
  color: var(--text-inverse);
  border: none;
}

.receipt-btn-file {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

/* Receipt preview */
.receipt-preview {
  margin-bottom: 16px;
  text-align: center;
}

.receipt-thumbnail {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}

.receipt-remove-btn {
  padding: 8px 16px;
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

/* Receipt selections (driver, truck, trip) */
.receipt-selections {
  margin-bottom: 16px;
}

.receipt-field {
  margin-bottom: 12px;
}

.receipt-field label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.receipt-field select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 16px;
  background-color: var(--bg-card);
  color: var(--text-primary);
}

/* Receipt actions */
.receipt-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.receipt-btn-analyze {
  flex: 1;
  padding: 14px 20px;
  background-color: var(--color-primary);
  color: var(--text-inverse);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
}

.receipt-btn-analyze:disabled {
  background-color: var(--text-muted);
  cursor: not-allowed;
}

.receipt-btn-clear {
  padding: 14px 20px;
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-weight: 500;
  font-size: 16px;
  cursor: pointer;
}

/* Receipt loading indicator */
.receipt-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px;
  color: var(--text-secondary);
}

.receipt-loading .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 12px;
}

/* Receipt results */
.receipt-results {
  background-color: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.receipt-results h3 {
  margin-bottom: 12px;
  color: var(--text-primary);
  font-size: 16px;
}

.receipt-result-fields {
  margin-bottom: 16px;
}

.receipt-result-field {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.receipt-result-field:last-child {
  border-bottom: none;
}

.receipt-result-field .field-label {
  color: var(--text-secondary);
  font-size: 14px;
}

.receipt-result-field .field-value {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 14px;
  text-align: right;
}

.receipt-success-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background-color: var(--color-success-bg, #e8f5e9);
  color: var(--color-success, #2e7d32);
  border-radius: 8px;
  font-size: 14px;
}

.receipt-success-note i {
  font-size: 18px;
}

/* =============================================================================
   DVIR Form Styles
   ============================================================================= */

.mobile-dvir-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-x: hidden;
}

.dvir-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}

.dvir-header h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.dvir-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.dvir-step {
  padding: 16px;
}

.dvir-step h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--text-primary);
}

.dvir-instruction {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 12px;
}

/* Form Fields */
.dvir-field {
  margin-bottom: 16px;
}

.dvir-field label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.dvir-select,
.dvir-input,
.dvir-textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 16px;
  background: var(--bg-input, var(--bg-card));
  color: var(--text-primary);
  box-sizing: border-box;
  -webkit-appearance: none;
}

.dvir-select:focus,
.dvir-input:focus,
.dvir-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

.dvir-textarea {
  resize: vertical;
  min-height: 80px;
}

/* Inspection Type Buttons */
.dvir-type-buttons {
  display: flex;
  gap: 8px;
}

.dvir-type-btn {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.dvir-type-btn.selected {
  border-color: var(--color-primary);
  background: rgba(25, 118, 210, 0.1);
  color: var(--color-primary);
}

/* Checklist */
.dvir-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dvir-checklist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.dvir-item-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
}

.dvir-item-options {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.dvir-status-btn {
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary, #f5f5f5);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.dvir-status-btn.selected {
  color: white;
  border-color: transparent;
}

/* Other Defects Section */
.dvir-other-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

/* Navigation Buttons */
.dvir-nav-buttons {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-bottom: 24px;
}

.dvir-back-btn,
.dvir-next-btn,
.dvir-submit-btn,
.dvir-new-btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.dvir-back-btn {
  background: var(--bg-secondary, #f5f5f5);
  color: var(--text-secondary);
}

.dvir-next-btn {
  background: var(--color-primary);
  color: white;
}

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

.dvir-submit-btn {
  background: #4caf50;
  color: white;
}

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

.dvir-new-btn {
  background: var(--color-primary);
  color: white;
  margin-top: 24px;
}

/* Review & Sign */
.dvir-summary {
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  margin-bottom: 16px;
}

.dvir-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

.dvir-summary-row:last-child {
  border-bottom: none;
}

.dvir-summary-row.has-defects {
  background: #ffebee;
  color: #c62828;
  font-weight: 600;
}

.dvir-summary-row.no-defects {
  background: #e8f5e9;
  color: #2e7d32;
  font-weight: 600;
}

.dvir-defect-list {
  margin-bottom: 16px;
}

.dvir-defect-list h3 {
  font-size: 16px;
  margin: 0 0 8px;
  color: var(--text-primary);
}

.dvir-defect-item {
  display: flex;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
  color: var(--text-primary);
}

/* Signature Section */
.dvir-signature-section {
  margin-top: 16px;
}

/* Complete Step */
.dvir-complete {
  text-align: center;
  padding: 48px 16px;
}

.dvir-success-icon {
  margin-bottom: 16px;
}

.dvir-complete h2 {
  margin-bottom: 8px;
}

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

/* =============================================================================
   DVIR History Styles
   ============================================================================= */

/* Tab Selector */
.dvir-tabs {
  display: flex;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}

.dvir-tab {
  flex: 1;
  padding: 14px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}

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

.dvir-tab:active {
  background-color: rgba(25, 118, 210, 0.1);
}

/* History Container */
.dvir-history-container {
  padding: 16px;
  min-height: 200px;
}

.dvir-history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Empty History State */
.dvir-empty-history {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  color: var(--text-muted);
  text-align: center;
}

.dvir-empty-history p {
  margin: 8px 0 0;
  font-size: 16px;
}

.dvir-empty-history .dvir-empty-hint {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Inspection Card */
.dvir-inspection-card {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.dvir-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  cursor: pointer;
}

.dvir-card-header:active {
  background-color: rgba(0, 0, 0, 0.03);
}

.dvir-card-main {
  flex: 1;
}

.dvir-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.dvir-card-date {
  color: var(--text-primary);
}

.dvir-card-separator {
  color: var(--text-secondary);
}

.dvir-card-type {
  color: var(--text-secondary);
  font-weight: 400;
}

.dvir-card-subtitle {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.dvir-card-truck {
  color: var(--text-secondary);
}

.dvir-status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.dvir-status-badge.pass {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.dvir-status-badge.defects {
  background-color: #ffebee;
  color: #c62828;
}

.dvir-card-expand {
  padding: 8px;
  color: var(--text-secondary);
}

.dvir-card-expand i {
  font-size: 16px;
  transition: transform 0.2s;
}

/* Card Details (Expanded) */
.dvir-card-details {
  padding: 0 16px 16px;
  border-top: 1px solid var(--border-color);
  animation: dvir-expand 0.2s ease-out;
}

@keyframes dvir-expand {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dvir-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.dvir-detail-row:last-child {
  border-bottom: none;
}

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

.dvir-detail-value {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  text-align: right;
}

.dvir-detail-row.dvir-notes {
  flex-direction: column;
  gap: 4px;
}

.dvir-detail-row.dvir-notes .dvir-detail-value {
  text-align: left;
  font-weight: 400;
}

/* Defects Section in Card */
.dvir-defects-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.dvir-defects-section .dvir-detail-label {
  margin-bottom: 8px;
}

.dvir-card-details .dvir-defect-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.dvir-card-details .dvir-defect-item {
  display: flex;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
  color: var(--text-primary);
}

/* Dark mode adjustments for status badges */
[data-theme="dark"] .dvir-status-badge.pass {
  background-color: rgba(46, 125, 50, 0.2);
  color: #81c784;
}

[data-theme="dark"] .dvir-status-badge.defects {
  background-color: rgba(198, 40, 40, 0.2);
  color: #e57373;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dvir-status-badge.pass {
    background-color: rgba(46, 125, 50, 0.2);
    color: #81c784;
  }

  :root:not([data-theme="light"]) .dvir-status-badge.defects {
    background-color: rgba(198, 40, 40, 0.2);
    color: #e57373;
  }
}

/* =============================================================================
   Ultra-Small Screen Adjustments (iPhone SE, older devices < 320px)
   ============================================================================= */

@media (max-width: 320px) {
  .mobile-item-card {
    padding: 12px;
  }

  .mobile-item-card .card-title {
    font-size: 14px;
  }

  .mobile-item-card .confidence-badge {
    font-size: 10px;
    padding: 2px 6px;
    max-width: 60px;
  }

  .mobile-item-card .card-content-row {
    gap: 8px;
  }

  .mobile-item-card .metadata-item {
    font-size: 11px;
    padding: 3px 6px;
  }
}

/* =============================================================================
   Mobile Full Compliance Dashboard
   ============================================================================= */

.mobile-compliance-dashboard {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: var(--bg-body);
}

/* Summary grid - 2x2 layout */
.compliance-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
  border-radius: 0;
}

.compliance-stat-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Customer card styles */
.compliance-customer-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.compliance-customer-card:active {
  transform: scale(0.98);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* Count badges */
.compliance-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 6px;
}

.compliance-count-badge.expired,
.compliance-count-badge.critical {
  background-color: #ffebee;
  color: #c62828;
}

.compliance-count-badge.urgent,
.compliance-count-badge.warning {
  background-color: #fff3e0;
  color: #ef6c00;
}

.compliance-count-badge.upcoming {
  background-color: #e3f2fd;
  color: #1976d2;
}

/* Dark mode adjustments for compliance dashboard */
[data-theme="dark"] .compliance-count-badge.expired,
[data-theme="dark"] .compliance-count-badge.critical {
  background-color: rgba(198, 40, 40, 0.2);
  color: #e57373;
}

[data-theme="dark"] .compliance-count-badge.urgent,
[data-theme="dark"] .compliance-count-badge.warning {
  background-color: rgba(239, 108, 0, 0.2);
  color: #ffb74d;
}

[data-theme="dark"] .compliance-count-badge.upcoming {
  background-color: rgba(25, 118, 210, 0.2);
  color: #64b5f6;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .compliance-count-badge.expired,
  :root:not([data-theme="light"]) .compliance-count-badge.critical {
    background-color: rgba(198, 40, 40, 0.2);
    color: #e57373;
  }

  :root:not([data-theme="light"]) .compliance-count-badge.urgent,
  :root:not([data-theme="light"]) .compliance-count-badge.warning {
    background-color: rgba(239, 108, 0, 0.2);
    color: #ffb74d;
  }

  :root:not([data-theme="light"]) .compliance-count-badge.upcoming {
    background-color: rgba(25, 118, 210, 0.2);
    color: #64b5f6;
  }
}

/* Ultra-small screen adjustments for compliance dashboard */
@media (max-width: 320px) {
  .compliance-summary-grid {
    gap: 8px;
    padding: 12px;
  }

  .compliance-stat-card {
    padding: 12px;
  }

  .compliance-stat-card > div:first-child {
    font-size: 24px;
  }

  .compliance-customer-card {
    padding: 12px;
  }

  .compliance-count-badge {
    font-size: 11px;
    padding: 2px 6px;
  }
}
