/* ========================================================
   RACHNA BATCHING PLANT - DISPATCH MANAGEMENT PORTAL
   Styles & Print Sheet
   ======================================================== */

/* ========================================================
   LOCAL OUTFIT FONT DEFINITIONS (100% Offline)
   ======================================================== */

@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/Outfit-Regular.ttf') format('truetype');
}

@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/Outfit-Medium.ttf') format('truetype');
}

@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/Outfit-SemiBold.ttf') format('truetype');
}

@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/Outfit-Bold.ttf') format('truetype');
}

@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('fonts/Outfit-ExtraBold.ttf') format('truetype');
}

@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('fonts/Outfit-Black.ttf') format('truetype');
}

:root {
  --primary: #1e3a8a;
  --primary-hover: #1e40af;
  --primary-light: #eff6ff;
  --accent: #d97706;
  --accent-hover: #b45309;
  --dark: #0f172a;
  --gray-900: #111827;
  --gray-800: #1f2937;
  --gray-700: #374151;
  --gray-600: #4b5563;
  --gray-500: #6b7280;
  --gray-400: #9ca3af;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50: #f9fafb;
  --white: #ffffff;
  --success: #10b981;
  --danger: #ef4444;
  --border-radius: 10px;
  --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-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f1f5f9;
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
}

/* App Header - Compact & Streamlined */
.app-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: var(--white);
  padding: 6px 18px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.brand-logo {
  height: 32px;
  width: auto;
  background: white;
  padding: 2px 6px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.brand-text h1 {
  font-size: 1.0rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}

.brand-badge {
  background: #f59e0b;
  color: #0f172a;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 9999px;
  text-transform: uppercase;
}

.brand-text p {
  font-size: 0.72rem;
  color: #cbd5e1;
  line-height: 1.1;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  height: 32px;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.nav-btn.active {
  background: #f59e0b;
  border-color: #fbbf24;
  color: #0f172a;
}

.nav-icon-only {
  padding: 5px 8px;
  min-width: 32px;
  justify-content: center;
}

.nav-badge {
  background: #f59e0b;
  color: #0f172a;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 10px;
  line-height: 1;
}

.nav-btn.active .nav-badge {
  background: #0f172a;
  color: #ffffff;
}

.nav-btn.primary {
  background: #f59e0b;
  color: #0f172a;
  border-color: #fbbf24;
}

.nav-btn.primary:hover {
  background: #d97706;
  color: white;
}

/* Main Layout */
.app-main {
  max-width: 1600px;
  margin: 20px auto;
  padding: 0 20px 40px;
}

/* Views */
.view-panel {
  display: none;
}
.view-panel.active {
  display: block;
}

/* Mobile Form / Preview View Tabs */
.mobile-view-tabs {
  display: none;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 16px;
  gap: 6px;
}

.mobile-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
}

.mobile-tab-btn.active {
  background: #ffffff;
  color: #1e3a8a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  font-weight: 700;
}

.mobile-tab-btn svg {
  flex-shrink: 0;
}

.mobile-only-action {
  display: none;
}

/* Portal Grid Layout */
.portal-grid {
  display: grid;
  grid-template-columns: minmax(480px, 1.15fr) minmax(500px, 1.35fr);
  gap: 24px;
  align-items: start;
}

@media screen and (max-width: 1200px) {
  .portal-grid {
    grid-template-columns: 1fr;
  }
}

/* Card Styling */
.card {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

/* Wizard Stepper Header */
.wizard-stepper {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin-bottom: 24px;
  padding: 0 10px;
}

.wizard-stepper::before {
  content: '';
  position: absolute;
  top: 18px;
  left: 30px;
  right: 30px;
  height: 3px;
  background: var(--gray-200);
  z-index: 1;
}

.step-item {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  flex: 1;
}

.step-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--white);
  border: 3px solid var(--gray-300);
  color: var(--gray-500);
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
}

.step-item.active .step-circle {
  background: var(--primary);
  border-color: #93c5fd;
  color: var(--white);
  box-shadow: 0 0 0 4px rgba(30, 58, 138, 0.2);
}

.step-item.completed .step-circle {
  background: var(--success);
  border-color: #a7f3d0;
  color: var(--white);
}

.step-label {
  margin-top: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  text-align: center;
  max-width: 90px;
}

.step-item.active .step-label {
  color: var(--primary);
  font-weight: 700;
}

.step-item.completed .step-label {
  color: var(--gray-700);
}

/* Form Sections */
.wizard-step-content {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

.wizard-step-content.active {
  display: block;
}

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

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

@media screen and (max-width: 640px) {
  .form-grid-2, .form-grid-3 {
    grid-template-columns: 1fr;
  }
}

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

.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
}

.form-label-tag {
  font-size: 0.7rem;
  font-weight: normal;
  color: var(--gray-500);
}

.input-with-action {
  display: flex;
  gap: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.95rem;
  color: var(--gray-900);
  background-color: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  transition: all 0.15s ease-in-out;
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-input.highlight {
  font-weight: 600;
  color: var(--primary);
}

.btn-inline-action {
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
  padding: 0 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-inline-action:hover {
  background: var(--gray-200);
  color: var(--gray-900);
}

/* Quick Chips */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chip-btn {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  color: var(--gray-700);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.chip-btn:hover {
  background: #e0e7ff;
  border-color: #c7d2fe;
  color: var(--primary);
}

.chip-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

/* Wizard Navigation Footer */
.wizard-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 20px;
  margin-top: 20px;
  border-top: 1px solid var(--gray-200);
}

.btn {
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  border: none;
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-secondary:hover {
  background: var(--gray-200);
  color: var(--gray-900);
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 2px 6px rgba(30, 58, 138, 0.3);
}

.btn-success {
  background: #059669;
  color: var(--white);
}
.btn-success:hover {
  background: #047857;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
}

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

/* ========================================================
   SLIP PREVIEW (SCREEN & PRINT EXACT REPLICA)
   ======================================================== */

.preview-wrapper {
  position: sticky;
  top: 86px;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: #1e293b;
  color: white;
  border-top-left-radius: var(--border-radius);
  border-top-right-radius: var(--border-radius);
}

.toolbar-title {
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}

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

.tool-btn.highlight {
  background: #f59e0b;
  color: #0f172a;
  border-color: #fbbf24;
}

/* The Paper Sheet Container */
.paper-scroll-box {
  background: #475569;
  padding: 16px;
  border-bottom-left-radius: var(--border-radius);
  border-bottom-right-radius: var(--border-radius);
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  display: flex;
  justify-content: center;
}

/* 1:1 Scalable A4 Document */
.a4-sheet {
  width: 210mm;
  min-height: 297mm;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  margin: 0 auto;
  box-sizing: border-box;
  padding: 5mm 10mm;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  color: #000000;
  font-family: 'Outfit', Arial, "Helvetica Neue", Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Single Slip Half (Takes 138mm height to generously fill full A4 page) */
.slip-half {
  position: relative !important;
  width: 100%;
  height: 138mm;
  min-height: 138mm;
  max-height: 138mm;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
  padding: 1.5mm 0;
  overflow: hidden !important;
  font-family: 'Outfit', Arial, sans-serif;
}

/* Watermark */
.slip-watermark {
  position: absolute !important;
  top: 52% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 50% !important;
  max-width: 100mm !important;
  opacity: 0.08; /* exactly matching Batching Plant Slip.jpg */
  pointer-events: none !important;
  z-index: 0 !important;
  user-select: none !important;
}

.slip-watermark img {
  width: 100% !important;
  height: auto !important;
  display: block !important;
}

/* Bottom Left Meta Footer: Printed By & Timestamp */
.slip-meta-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3px;
  padding: 0 1mm;
  font-size: 6.5pt;
  color: #555555;
  font-family: 'Outfit', Arial, sans-serif;
  z-index: 2;
  position: relative;
  line-height: 1.1;
}

.slip-meta-printed-by {
  font-size: 7pt;
  font-weight: 500;
  color: #111111;
}

.slip-meta-printed-by strong {
  font-weight: 700;
  color: #000000;
}

.slip-meta-timestamp {
  font-size: 6.5pt;
  color: #666666;
}

/* Slip Header */
.slip-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 4px;
}

.slip-header-logo {
  flex-shrink: 0;
  width: 72px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slip-header-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.slip-header-info {
  flex-grow: 1;
}

.slip-main-title {
  font-size: 22pt;
  font-weight: 900;
  letter-spacing: 0.8px;
  color: #1a1a1a;
  text-transform: uppercase;
  line-height: 1.1;
  font-family: 'Outfit', "Arial Black", Arial, sans-serif;
}

.slip-contact-line {
  font-size: 11pt;
  font-weight: 600;
  color: #111111;
  margin-top: 2px;
  letter-spacing: 0.2px;
  font-family: 'Outfit', Arial, sans-serif;
}

.slip-contact-line .pipe-sep {
  margin: 0 8px;
  color: #333333;
  font-weight: 400;
}

/* Solid Black Divider line below header */
.slip-header-divider {
  width: 100%;
  height: 2px;
  background-color: #000000;
  margin-top: 2px;
  margin-bottom: 5px;
}

/* Body Content Rows */
.slip-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-grow: 1;
  padding: 1mm 0 0 0;
  font-family: 'Outfit', Arial, sans-serif;
}

/* Field Rows - Increased Vertical Spacing */
.slip-row {
  display: flex;
  align-items: baseline;
  width: 100%;
  margin-bottom: 2mm;
  line-height: 1.35;
}

.slip-col {
  display: flex;
  align-items: baseline;
  min-width: 0;
}

.slip-label {
  font-size: 10.5pt;
  font-weight: 700;
  color: #000000;
  white-space: nowrap;
  flex-shrink: 0;
  padding-right: 5px;
  font-family: 'Outfit', Arial, sans-serif;
}

.slip-value-line {
  flex-grow: 1;
  border-bottom: 1.5px solid #000000;
  min-height: 18pt;
  display: inline-block;
  padding: 1px 6px 2px 6px;
  font-size: 11.5pt; /* Exactly +1pt larger than 10.5pt fixed label text */
  font-weight: 700;
  color: #051d3b; /* crisp dark print text */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Outfit', Arial, sans-serif;
}

/* Boxed Copy Badge (Plant Copy / Client Copy) */
.copy-badge-box {
  border: 1.5px solid #000000;
  padding: 2px 10px;
  font-size: 10pt;
  font-weight: 800;
  color: #000000;
  white-space: nowrap;
  margin-left: 10px;
  border-radius: 2px;
  text-align: center;
  font-family: 'Outfit', Arial, sans-serif;
}

/* Row Specific Width Alignments matching original photo */
.row-1 .col-slip {
  width: 44%;
}
.row-1 .col-date {
  width: 38%;
}

.row-full {
  width: 100%;
}

/* 3 Column Rows (Rows 4, 5, 6, 7) */
.row-3col .col-1 {
  width: 32%;
}
.row-3col .col-2 {
  width: 35%;
  margin-left: 10px;
}
.row-3col .col-3 {
  width: 33%;
  margin-left: 10px;
}

/* Row 6: Reduced Line for Temps, Increased Line for Vehicle Detail */
.row-temps-vehicle .col-1 {
  width: 26% !important;
}
.row-temps-vehicle .col-2 {
  width: 26% !important;
  margin-left: 8px !important;
}
.row-temps-vehicle .col-3 {
  width: 48% !important;
  margin-left: 8px !important;
}

/* 2 Column Rows (Rows 8, 10) */
.row-2col .col-1 {
  width: 48%;
}
.row-2col .col-2 {
  width: 52%;
  margin-left: 16px;
}

.row-receiver .col-1 {
  width: 58%;
}
.row-receiver .col-2 {
  width: 42%;
  margin-left: 16px;
}

/* Middle Cut / Perforation Line */
.slip-tear-divider {
  width: 100%;
  position: relative;
  height: 8mm;
  min-height: 8mm;
  margin: 1.5mm 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.slip-tear-divider::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1.5px dashed #000000;
  z-index: 1;
}

.tear-indicator-box {
  position: relative;
  z-index: 2;
  background: #ffffff;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 7.5pt;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #111111;
  text-transform: uppercase;
  font-family: 'Outfit', Arial, sans-serif;
  border-radius: 3px;
}

.tear-scissors {
  font-size: 10pt;
}

/* Single Copy Display Modes */
.a4-sheet.mode-plant-only .slip-bottom,
.a4-sheet.mode-plant-only .slip-tear-divider {
  display: none !important;
}

.a4-sheet.mode-client-only .slip-top,
.a4-sheet.mode-client-only .slip-tear-divider {
  display: none !important;
}

.a4-sheet.mode-plant-only,
.a4-sheet.mode-client-only {
  min-height: auto;
  height: auto;
}

/* Print instructions box */
.print-tip-box {
  background: #f8fafc;
  border-left: 4px solid #3b82f6;
  padding: 10px 14px;
  font-size: 0.8rem;
  color: #334155;
  margin-top: 12px;
  border-radius: 0 6px 6px 0;
}

.print-tip-box strong {
  color: #1e3a8a;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-900);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--gray-500);
}

.modal-body {
  padding: 20px;
}

/* History Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th {
  background: var(--gray-100);
  color: var(--gray-700);
  font-weight: 700;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-800);
}

.data-table tr:hover {
  background: #f8fafc;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-blue {
  background: #dbeafe;
  color: #1e40af;
}

/* ========================================================
   AUTHENTICATION & MULTI-USER UI STYLES
   ======================================================== */
.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 4px 10px;
  border-radius: 30px;
  margin-left: 6px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f59e0b;
  color: #0f172a;
  font-weight: 800;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.user-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: #ffffff;
}

.user-role-badge {
  font-size: 0.65rem;
  font-weight: 600;
  color: #fbbf24;
  text-transform: uppercase;
}

.btn-sm {
  padding: 5px 10px !important;
  font-size: 0.78rem !important;
  border-radius: 20px !important;
}

.btn-logout {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
  color: #fca5a5 !important;
}

.btn-logout:hover {
  background: #ef4444 !important;
  color: #ffffff !important;
}

/* Login Overlay & Dialog */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-overlay.active {
  display: flex;
}

.login-card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 440px;
  padding: 32px;
  animation: modalFadeIn 0.25s ease-out;
}

.login-header {
  text-align: center;
  margin-bottom: 22px;
}

.login-logo {
  height: 52px;
  width: auto;
  margin-bottom: 12px;
  background: #ffffff;
  padding: 4px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.login-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: #1e3a8a;
  letter-spacing: 0.5px;
}

.login-header p {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-top: 4px;
}

.login-error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 12px !important;
  font-size: 0.95rem !important;
  font-weight: 700 !important;
}

/* ========================================================
   RESPONSIVE DESIGN (TABLETS & MOBILE PHONES)
   ======================================================== */

@media screen and (max-width: 991px) {
  .mobile-view-tabs {
    display: flex;
  }

  .mobile-only-action {
    display: block;
  }

  .portal-grid {
    display: block !important;
  }

  #wizardView.mobile-show-form .wizard-card {
    display: block !important;
  }

  #wizardView.mobile-show-form .preview-wrapper {
    display: none !important;
  }

  #wizardView.mobile-show-preview .wizard-card {
    display: none !important;
  }

  #wizardView.mobile-show-preview .preview-wrapper {
    display: block !important;
  }

  .preview-wrapper {
    position: static !important;
    top: auto !important;
    width: 100% !important;
  }
}

@media screen and (max-width: 768px) {
  .app-header {
    padding: 8px 12px;
  }

  .header-container {
    flex-wrap: wrap;
    gap: 8px;
  }

  .brand-section {
    flex: 1;
    min-width: 180px;
  }

  .brand-logo {
    height: 28px;
  }

  .brand-text h1 {
    font-size: 0.85rem;
  }

  .brand-text p {
    display: none;
  }

  .brand-badge {
    font-size: 0.6rem;
    padding: 1px 4px;
  }

  .header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    max-width: 100%;
  }

  .nav-btn {
    padding: 6px 10px;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .user-badge {
    padding: 2px 6px;
  }

  .user-info {
    display: none;
  }

  /* Form & inputs iOS Safari auto-zoom prevention (must be >= 16px) */
  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  select,
  textarea {
    font-size: 16px !important;
  }

  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

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

  .app-main {
    padding: 10px 8px;
  }

  .card-body {
    padding: 14px 12px;
  }

  .card-header {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .card-title {
    font-size: 0.92rem;
  }

  /* Stepper mobile layout */
  .wizard-stepper {
    padding: 0 2px;
    margin-bottom: 16px;
  }

  .wizard-stepper::before {
    top: 14px;
    left: 10px;
    right: 10px;
    height: 2px;
  }

  .step-circle {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
    border-width: 2px;
  }

  .step-label {
    font-size: 0.62rem;
    max-width: 55px;
    line-height: 1.1;
    margin-top: 4px;
  }

  /* Wizard Footer on mobile */
  .wizard-footer {
    flex-direction: column-reverse;
    gap: 10px;
  }

  .wizard-footer > div {
    width: 100%;
    display: flex;
    gap: 8px;
  }

  .wizard-footer .btn {
    flex: 1;
    justify-content: center;
  }

  /* Preview toolbar */
  .preview-toolbar {
    padding: 8px 10px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .toolbar-title {
    font-size: 0.8rem;
    justify-content: center;
  }

  .toolbar-actions {
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
  }

  .tool-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .paper-scroll-box {
    padding: 8px 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 75vh;
  }

  /* Modals on mobile */
  .modal-overlay {
    padding: 8px;
  }

  .modal-content {
    max-width: 100%;
    max-height: 94vh;
    border-radius: 8px;
  }

  .modal-header {
    padding: 12px 14px;
  }

  .modal-body {
    padding: 14px;
  }

  .login-card {
    padding: 24px 18px;
    margin: 8px;
    border-radius: 10px;
  }

  .login-logo {
    height: 44px;
  }

  .login-header h2 {
    font-size: 1.1rem;
  }

  .login-header p {
    font-size: 0.78rem;
  }
}

@media screen and (max-width: 480px) {
  .brand-text h1 {
    font-size: 0.8rem;
  }

  .brand-badge {
    display: none;
  }

  .nav-btn span {
    display: none;
  }

  .nav-btn {
    padding: 6px 8px;
  }

  .step-label {
    font-size: 0.58rem;
    max-width: 48px;
  }
}

/* ========================================================
   PRINT STYLESHEET (PIXEL PERFECT A4 OUTPUT)
   Strictly placed at the very end to guarantee precedence
   over all screen and responsive rules!
   ======================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 4mm 8mm;
  }

  /* Force pure white background and exact colors */
  html, body {
    width: 100% !important;
    height: 100% !important;
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Explicitly hide ALL web UI, form wizard cards, headers, buttons, and overlays */
  .no-print,
  .app-header,
  .wizard-card,
  #wizardView .wizard-card,
  #wizardView.mobile-show-form .wizard-card,
  #wizardView.mobile-show-preview .wizard-card,
  .mobile-view-tabs,
  .mobile-only-action,
  .preview-toolbar,
  .modal-overlay,
  .login-overlay,
  .history-view,
  #historyView,
  .settings-modal {
    display: none !important;
    visibility: hidden !important;
  }

  /* Explicitly display preview wrapper and A4 slip container */
  .app-main,
  #wizardView,
  .portal-grid,
  .preview-wrapper,
  #wizardView.mobile-show-form .preview-wrapper,
  #wizardView.mobile-show-preview .preview-wrapper {
    display: block !important;
    visibility: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    width: 100% !important;
    position: static !important;
    overflow: visible !important;
  }

  .paper-scroll-box {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    display: block !important;
    width: 100% !important;
  }

  /* A4 Document layout strictly 284mm height to fill the single page */
  .a4-sheet {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    width: 100% !important;
    min-height: auto !important;
    height: 284mm !important;
    max-height: 285mm !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
    transform-origin: initial !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
    overflow: hidden !important;
  }

  /* Individual Slip Copies (138mm height per copy - generously spaced) */
  .slip-half {
    position: relative !important;
    width: 100% !important;
    height: 138mm !important;
    min-height: 138mm !important;
    max-height: 138mm !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    page-break-inside: avoid !important;
    page-break-after: avoid !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    padding: 1.5mm 0 !important;
  }

  .slip-body {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    flex-grow: 1 !important;
    height: 100% !important;
    padding: 1mm 0 0 0 !important;
  }

  .slip-row {
    display: flex !important;
    align-items: baseline !important;
    width: 100% !important;
    margin-bottom: 2.2mm !important;
    line-height: 1.35 !important;
  }

  .slip-label {
    font-size: 10.5pt !important;
    font-weight: 700 !important;
    color: #000000 !important;
    padding-right: 5px !important;
    white-space: nowrap !important;
  }

  .slip-value-line {
    font-size: 11.5pt !important;
    font-weight: 700 !important;
    color: #000000 !important;
    border-bottom: 1.5px solid #000000 !important;
    min-height: 18pt !important;
    padding: 1px 6px 2px 6px !important;
  }

  /* Single Copy Print Modes */
  .mode-plant-only #plantCopySection {
    display: flex !important;
    height: 138mm !important;
  }
  .mode-plant-only #clientCopySection,
  .mode-plant-only .slip-tear-divider {
    display: none !important;
  }

  .mode-client-only #clientCopySection {
    display: flex !important;
    height: 138mm !important;
  }
  .mode-client-only #plantCopySection,
  .mode-client-only .slip-tear-divider {
    display: none !important;
  }

  /* Middle Cut / Perforation Divider in Print */
  .slip-tear-divider {
    width: 100% !important;
    position: relative !important;
    height: 8mm !important;
    min-height: 8mm !important;
    margin: 1mm 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    page-break-inside: avoid !important;
    page-break-after: avoid !important;
    box-sizing: border-box !important;
  }

  .slip-tear-divider::before {
    content: '' !important;
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    top: 50% !important;
    border-top: 1.5px dashed #000000 !important;
    z-index: 1 !important;
  }

  .tear-indicator-box {
    position: relative !important;
    z-index: 2 !important;
    background: #ffffff !important;
    padding: 0 10px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-size: 7pt !important;
    font-weight: 700 !important;
    letter-spacing: 1.5px !important;
    color: #000000 !important;
    text-transform: uppercase !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Watermark in print output */
  .slip-watermark {
    position: absolute !important;
    top: 52% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 50% !important;
    max-width: 100mm !important;
    opacity: 0.08 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    pointer-events: none !important;
    z-index: 0 !important;
    display: block !important;
  }

  .slip-watermark img {
    width: 100% !important;
    height: auto !important;
    display: block !important;
  }

  .slip-meta-footer {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    position: relative !important;
    z-index: 2 !important;
    margin-top: 2px !important;
  }
}
