:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --muted: #334155;
  --accent: #0b5cff;
  --border: #e6eef9;
  --shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  color: var(--muted);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  padding: 20px;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  color: #0b2545;
  font-weight: 600;
}

h1 {
  font-size: 24px;
  margin-bottom: 8px;
}

h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

h3 {
  font-size: 16px;
  margin-bottom: 12px;
}

.step-description {
  color: #475569;
  margin-bottom: 24px;
  border-left: 3px solid #3b82f6;
  padding-left: 16px;
  line-height: 1.5;
  font-size: 15px;
}

.required-star {
  color: #ef4444;
  font-weight: bold;
  margin-left: 4px;
}

/* ============================================
   CARD STYLES
   ============================================ */
.card {
  background: var(--card);
  border-radius: 20px;
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 28px;
}

.card.emphasis {
  border-left: 4px solid var(--accent);
}

.card h2 {
  color: #0b2545;
  font-size: 18px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-label {
  font-weight: 500;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #334155;
}

.form-input, select.form-input {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  font-size: 0.9rem;
  transition: 0.2s;
  background: white;
  width: 100%;
}

.form-input:focus, select.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 92, 255, 0.1);
}

.form-input.error {
  border-color: #ef4444;
  background-color: #fef2f2;
}

.error-message {
  color: #ef4444;
  font-size: 0.7rem;
  margin-top: 4px;
  display: none;
}

.form-hint {
  font-size: 0.7rem;
  color: #64748b;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 40px;
  font-weight: 500;
  cursor: pointer;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn:hover {
  background: #0a50e0;
  transform: translateY(-1px);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

.btn.ghost:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.btn.delete-btn {
  background: transparent;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 6px 10px;
  font-size: 12px;
}

.btn.delete-btn:hover {
  background: #fef2f2;
}

button:disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.action-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 20px 0 16px;
}

/* ============================================
   DATA TABLE
   ============================================ */
.table-container-step6 {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  background: white;
}

.data-table-step6 {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 1600px;
}

.data-table-step6 th {
  background: linear-gradient(to bottom, #ffffff, #f1f5f9);
  padding: 14px 12px;
  text-align: left;
  font-weight: 600;
  color: #1e293b;
  font-size: 13px;
  border-bottom: 2px solid #e2e8f0;
  border-top: 1px solid #e2e8f0;
  vertical-align: middle;
}

.data-table-step6 td {
  padding: 12px 8px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  line-height: 1.4;
}

/* Shipment grouping rows */
.data-table-step6 tr.shipment-group-start td {
  border-top: 2px solid #3b82f6;
}

.shipment-group-bg {
  background-color: #f0fdf4;
}

/* ============================================
   RISK BADGE - PUSHED DOWN FOR PERFECT ALIGNMENT
   ============================================ */
.risk-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.75rem;
  line-height: 1.2;
  white-space: nowrap;
  min-height: 26px;
  vertical-align: middle;
  /* Push the badge down by 8px for proper alignment */
  transform: translateY(10px);
  margin: 0;
}

.risk-badge.high {
  background: #fee2e2;
  color: #b91c1c;
}

.risk-badge.medium {
  background: #ffedd5;
  color: #c2410c;
}

.risk-badge.low {
  background: #dcfce7;
  color: #15803d;
}

/* Alternative class for final exposure column */
.final-exposure-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.75rem;
  line-height: 1.2;
  white-space: nowrap;
  min-height: 26px;
  vertical-align: middle;
  transform: translateY(10px);
}

.final-exposure-value.high {
  background: #fee2e2;
  color: #b91c1c;
}

.final-exposure-value.medium {
  background: #ffedd5;
  color: #c2410c;
}

.final-exposure-value.low {
  background: #dcfce7;
  color: #15803d;
}

/* Specific column alignment for final exposure */
.data-table-step6 td:last-child,
.data-table-step6 td:nth-child(15) {
  vertical-align: middle;
}

.data-table-step6 td:last-child .risk-badge,
.data-table-step6 td:nth-child(15) .risk-badge,
.data-table-step6 td:last-child .final-exposure-value,
.data-table-step6 td:nth-child(15) .final-exposure-value {
  transform: translateY(8px);
}

/* ============================================
   BADGES & TAGS
   ============================================ */
.badge {
  background: #e2e8f0;
  padding: 4px 8px;
  border-radius: 30px;
  font-size: 0.7rem;
  font-weight: 500;
  display: inline-block;
  vertical-align: middle;
}

.badge-warning {
  background: #fef3c7;
  color: #b45309;
}

.badge-info {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-success {
  background: #dcfce7;
  color: #15803d;
}

.badge-secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* ============================================
   STATUS INDICATORS
   ============================================ */
.status-indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

.status-complete {
  background-color: #10b981;
}

.status-incomplete {
  background-color: #f59e0b;
}

.save-status-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.save-status {
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 20px;
  background: #f1f5f9;
  color: #64748b;
  font-weight: 500;
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-bar-container {
  background: #e2e8f0;
  border-radius: 20px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-bar {
  background: var(--accent);
  height: 8px;
  transition: width 0.3s;
  border-radius: 20px;
}

/* ============================================
   SUMMARY & SIDEBAR
   ============================================ */
.bottom-sidebar {
  margin-top: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.summary-card {
  background: #f1f5f9;
  border-radius: 16px;
  padding: 12px;
}

.summary-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: #64748b;
}

.summary-card span {
  font-size: 20px;
  font-weight: 700;
  color: #0b2545;
}

/* ============================================
   PORTFOLIO VIEW
   ============================================ */
.portfolio-summary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 20px;
}

.portfolio-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  border: 1px solid #e2e8f0;
  transition: transform 0.2s;
  position: relative;
  overflow: hidden;
}

.portfolio-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.portfolio-card.high {
  border-left: 4px solid #ef4444;
}

.portfolio-card.medium {
  border-left: 4px solid #f59e0b;
}

.portfolio-card.low {
  border-left: 4px solid #10b981;
}

.impact-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0 4px;
}

.impact-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #dc2626);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ============================================
   BLUR EFFECT
   ============================================ */
.blurred-section {
  filter: blur(5px);
  pointer-events: none;
  user-select: none;
  transition: filter 0.3s;
}

.unblurred {
  filter: blur(0);
  pointer-events: auto;
}

/* ============================================
   INFO BANNER & UTILITIES
   ============================================ */
.info-banner {
  background: #e0f2fe;
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 20px;
  font-size: 0.85rem;
}

.read-only-banner {
  background: #e5ddd1;
  border-left: 4px solid #1e40af;
  padding: 12px 20px;
  margin-bottom: 20px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #94a3b8;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px dashed var(--border);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  color: #cbd5e1;
}

/* ============================================
   DELETE BUTTON
   ============================================ */
.delete-btn {
  background: none;
  border: none;
  color: #dc2626;
  cursor: pointer;
  font-size: 1rem;
  padding: 6px 10px;
  border-radius: 8px;
  transition: all 0.2s;
}

.delete-btn:hover {
  background: #fee2e2;
}

/* ============================================
   VERIFIER OVERLAY
   ============================================ */
.verifier-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  body {
    padding: 12px;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .summary-grid {
    grid-template-columns: 1fr;
  }
  
  .data-table-step6 {
    min-width: 1200px;
  }
  
  .card {
    padding: 16px;
  }
  
  h1 {
    font-size: 1.5rem;
  }
  
  h2 {
    font-size: 1.2rem;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  body {
    background: white;
    padding: 0;
  }
  
  .btn, 
  .action-buttons, 
  .delete-btn, 
  #submitStep, 
  #resetAllBtn,
  .save-status-container, 
  footer,
  .info-banner {
    display: none !important;
  }
  
  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #e2e8f0;
  }
  
  .blurred-section, 
  .unblurred {
    filter: none;
    pointer-events: auto;
  }
  
  .data-table-step6 {
    font-size: 10px;
  }
  
  .risk-badge,
  .final-exposure-value {
    border: 1px solid #ccc;
    background: #f5f5f5 !important;
    color: #000 !important;
    transform: none;
    padding: 2px 6px;
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease forwards;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(11, 92, 255, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent);
  animation: spin 1s ease-in-out infinite;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mt-2 {
  margin-top: 8px;
}

.mt-3 {
  margin-top: 12px;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-3 {
  margin-bottom: 12px;
}

.hidden {
  display: none;
}

.visible {
  display: block;
}