/* =========================================================================
   1. RESET & UTILITY CLASSES
   ========================================================================= */
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
body { background: #f1f5f9; min-height: 100vh; padding: 20px; color: #0f172a; line-height: 1.45; }
.app-container { width: 100%; max-width: 1360px; margin: 0 auto; }

.hidden { display: none !important; }
.block { display: block; }
.bold, .font-bold { font-weight: 700; }
.uppercase { text-transform: uppercase; }
.font-mono { font-family: monospace; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-slate-500 { color: #64748b; }
.text-slate-700 { color: #334155; }
.leading-relaxed { line-height: 1.6; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.pt-4 { padding-top: 16px; }
.pb-4 { padding-bottom: 16px; }
.border-t { border-top: 1px solid #e2e8f0; }
.border-b { border-bottom: 1px solid #e2e8f0; }

.bg-white { background: #fff; }
.rounded-xl { border-radius: 12px; }
.shadow-sm { box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05); }
.border { border: 1px solid #e2e8f0; }
.border-slate-200 { border-color: #e2e8f0; }
.overflow-hidden { overflow: hidden; }

/* =========================================================================
   2. GLOBAL HEADER & LOGIN / HOME SCREEN
   ========================================================================= */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  padding: 14px 20px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  margin-bottom: 28px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}
.app-header h1 { font-size: 18px; font-weight: 800; color: #0f172a; }

.login-wrapper {
  display: flex;
  gap: 28px;
  justify-content: center;
  align-items: stretch;
  flex-wrap: wrap;
}
.card-column { flex: 1; min-width: 320px; max-width: 480px; display: flex; flex-direction: column; }
.column-title { font-size: 14px; font-weight: 800; color: #475569; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }

.card {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e2e8f0;
}
.visitor-card .card-image {
  height: 125px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 55%, #ea580c 100%);
}
.employee-card { background: #0f172a; color: #fff; border-color: #1e293b; }
.card-content { padding: 28px; display: flex; flex-direction: column; flex-grow: 1; }
.card-content h3 { font-size: 20px; margin-bottom: 8px; }
.card-content p { font-size: 13px; color: #64748b; margin-bottom: 18px; }
.employee-card .card-content p { color: #cbd5e1; }
.shield-icon { font-size: 34px; margin-bottom: 10px; }

.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 38px; }
.toggle-password { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); cursor: pointer; font-size: 15px; user-select: none; }
.error-text { color: #f87171; font-size: 12px; font-weight: 700; min-height: 16px; margin-bottom: 10px; }

/* =========================================================================
   3. BUTTONS, BADGES & INPUTS
   ========================================================================= */
.input-group { margin-bottom: 14px; }
.input-group label { display: block; margin-bottom: 5px; font-size: 12px; font-weight: 700; color: #334155; }
.employee-card .input-group label { color: #cbd5e1; }
.input-group input,
.input-group select,
.input-group textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  color: #0f172a;
  background: #fff;
}
.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus { outline: 2px solid #fb923c; border-color: #ea580c; }

.btn {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  transition: opacity 0.2s, transform 0.1s;
}
.btn:hover:not(:disabled) { opacity: 0.92; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-orange { background: #ea580c; color: #fff; border: none; padding: 9px 16px; border-radius: 6px; font-weight: 700; cursor: pointer; }
.btn-blue { background: #0284c7; color: #fff; border: none; padding: 9px 16px; border-radius: 6px; font-weight: 700; cursor: pointer; }
.btn-dark { background: #0f172a; color: #fff; border: none; padding: 9px 16px; border-radius: 6px; font-weight: 700; cursor: pointer; }
.btn-green { background: #059669; color: #fff; border: none; padding: 9px 16px; border-radius: 6px; font-weight: 700; cursor: pointer; }
.btn-red { background: #dc2626; color: #fff; border: none; padding: 9px 16px; border-radius: 6px; font-weight: 700; cursor: pointer; }
.btn-outline { background: #fff; color: #334155; border: 1px solid #cbd5e1; padding: 8px 14px; border-radius: 6px; font-weight: 700; cursor: pointer; }
.btn-outline:hover { background: #f8fafc; }
.btn-small { padding: 6px 12px !important; font-size: 12px !important; width: auto !important; }

.badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 800; color: #fff; letter-spacing: 0.03em; }
.badge-green { background: #059669; }
.badge-yellow { background: #d97706; }
.badge-red { background: #dc2626; }
.badge-orange { background: #ea580c; }
.badge-blue { background: #e0f2fe; color: #0369a1; border-radius: 12px; padding: 3px 9px; font-size: 10px; font-weight: 700; display: inline-block; }

/* =========================================================================
   4. PORTAL HEADERS, SAP FORM & SECTION CARDS (SINGLE COLUMN)
   ========================================================================= */
.portal-header {
  background: #fff;
  padding: 16px 20px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}
.portal-wrapper { max-width: 1120px; margin: 0 auto; }

.sap-top-banner {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}
.banner-left { display: flex; align-items: center; gap: 12px; }
.banner-left h2 { font-size: 17px; color: #0f172a; margin-bottom: 2px; }
.banner-left p { font-size: 12px; color: #64748b; }
.banner-right { min-width: 240px; }
.banner-right label { display: block; font-size: 10px; font-weight: 800; color: #64748b; text-align: right; }
.banner-right input { width: 100%; padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-family: monospace; font-weight: 700; background: #f8fafc; margin-top: 3px; text-align: right; }

.sap-layout { max-width: 1160px; margin: 0 auto; display: block; }

.section-card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
  margin-bottom: 22px;
  overflow: hidden;
}
.section-header {
  background: #0f172a;
  color: #fff;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
}
.section-body { padding: 20px; }
.section-desc { font-size: 13px; color: #475569; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

.alert-box { padding: 12px 14px; border-radius: 8px; font-size: 12.5px; margin-bottom: 14px; border: 1px solid; }
.alert-green { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-orange { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.gray-box { background: #f8fafc; border: 1px solid #e2e8f0; padding: 16px; border-radius: 8px; }

.duration-box { background: #f8fafc; border: 1px solid #e2e8f0; padding: 10px 12px; border-radius: 6px; display: flex; flex-direction: column; justify-content: center; margin-bottom: 14px; }
.duration-box label { font-size: 10px; color: #64748b; font-weight: 800; }
.duration-box strong { font-size: 16px; color: #0f172a; margin: 2px 0; }

/* Zone Reference Cards */
.zone-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.zone-card { border: 2px solid #e2e8f0; border-radius: 8px; padding: 12px; }
.zone-card strong { display: block; margin-top: 6px; font-size: 13px; color: #0f172a; }
.zone-card p { font-size: 11px; color: #475569; margin-top: 3px; }
.cat-a { background: #ecfdf5; border-color: #a7f3d0; }
.cat-b { background: #fffbeb; border-color: #fde68a; }
.cat-c { background: #fef2f2; border-color: #fecaca; }

.radio-card { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid #e2e8f0; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; background: #fff; }
.radio-card:hover { background: #f8fafc; }

/* PPE Quantity Grid */
.ppe-qty-table { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px; align-items: center; font-size: 12px; }
.ppe-header { font-weight: 800; color: #334155; font-size: 11px; border-bottom: 1px solid #cbd5e1; padding-bottom: 5px; }
.ppe-qty-table input[type="number"] { width: 100%; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 12px; }

/* =========================================================================
   5. DATA TABLES & HORIZONTAL SCROLLING
   ========================================================================= */
.table-scroll-container { width: 100%; overflow-x: auto; border: 1px solid #e2e8f0; border-radius: 8px; }
.modern-table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 640px; }
#visitorTable { min-width: 1320px; }
.fixed-table { min-width: 100%; }
.modern-table th { background: #f1f5f9; color: #334155; padding: 10px 8px; text-align: left; border-bottom: 2px solid #cbd5e1; font-size: 11px; font-weight: 800; white-space: nowrap; }
.modern-table td { padding: 8px; border-bottom: 1px solid #e2e8f0; vertical-align: middle; }
.modern-table input, .modern-table select { width: 100%; padding: 6px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 12px; }

/* =========================================================================
   6. OFFICIAL PRINTABLE PDF DOCUMENTS (SAP, WORK ORDER, PTW)
   ========================================================================= */
.doc-paper {
  background: #fff;
  border: 1px solid #cbd5e1;
  padding: 36px 40px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.07);
  border-radius: 4px;
}
.doc-section-title {
  background: #0f172a;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 6px 10px;
  margin-top: 14px;
  text-transform: uppercase;
}
.doc-form-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin-bottom: 10px;
  border: 1px solid #000;
}
.doc-form-table th, .doc-form-table td {
  border: 1px solid #000;
  padding: 6px 8px;
  vertical-align: middle;
}
.doc-form-inner-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.doc-form-inner-table td { border: none; padding: 4px 6px; }

/* =========================================================================
   7. MODALS (EMAIL & PTW POPUP)
   ========================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-content {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
}
.ptw-modal-box {
  max-width: 720px !important;
  width: 95% !important;
  max-height: 90vh;
  overflow-y: auto;
  text-align: left !important;
}

/* =========================================================================
   8. RESPONSIVE & PRINT PDF RULES
   ========================================================================= */
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4, .zone-cards { grid-template-columns: 1fr; }
  .doc-paper { padding: 18px; }
}

@media print {
  body { background: #fff; padding: 0; }
  .no-print { display: none !important; }
  .app-container, .portal-wrapper { max-width: 100%; margin: 0; }
  .doc-paper { box-shadow: none; border: none; padding: 0; width: 100%; max-width: 100%; }
  .print-page-break { page-break-before: always; }
}