:root {
  --bg-primary: #050811;
  --bg-secondary: #0b1120;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-glass: rgba(15, 23, 42, 0.65);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(255, 255, 255, 0.15);
  --border-focus: #3b82f6;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-emerald-light: #34d399;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-indigo: #6366f1;

  --status-compliant-bg: rgba(16, 185, 129, 0.12);
  --status-compliant-border: rgba(16, 185, 129, 0.4);
  --status-compliant-text: #34d399;

  --status-noncompliant-bg: rgba(244, 63, 94, 0.12);
  --status-noncompliant-border: rgba(244, 63, 94, 0.4);
  --status-noncompliant-text: #fb7185;

  --status-warning-bg: rgba(245, 158, 11, 0.12);
  --status-warning-border: rgba(245, 158, 11, 0.4);
  --status-warning-text: #fbbf24;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.25);
  --emerald-glow: 0 0 25px rgba(16, 185, 129, 0.3);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* Dynamic Ambient Glow Background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 10% 15%, rgba(16, 185, 129, 0.09) 0%, transparent 45%),
    radial-gradient(circle at 90% 40%, rgba(59, 130, 246, 0.09) 0%, transparent 45%),
    radial-gradient(circle at 50% 85%, rgba(99, 102, 241, 0.07) 0%, transparent 50%),
    linear-gradient(to right, rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 100% 100%, 48px 48px, 48px 48px;
  pointer-events: none;
  z-index: 0;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(5, 8, 17, 0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.75rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

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

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-icon-box {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.35);
  flex-shrink: 0;
}

.logo-badge {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(59, 130, 246, 0.2));
  border: 1px solid rgba(52, 211, 153, 0.4);
  color: #34d399;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.logo-title h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.logo-title h1 strong {
  color: #ffffff;
  font-weight: 900;
}

.logo-title h1 span.accent {
  color: var(--accent-emerald-light);
  font-weight: 600;
  text-shadow: 0 0 12px rgba(52, 211, 153, 0.3);
}

.logo-title p {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.badge-gateway {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 8px #34d399;
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Main Container */
main {
  position: relative;
  z-index: 1;
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Preset Toolbar */
.preset-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.4rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.preset-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.btn-preset {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.btn-preset:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.btn-preset.active {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(52, 211, 153, 0.5);
  color: #34d399;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.25);
}

/* Main Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1280px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-md);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  border-color: var(--border-highlight);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 0.85rem;
}

.card-title {
  font-size: 0.96rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

/* Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

textarea, input, select {
  width: 100%;
  background: rgba(11, 17, 32, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.6rem 0.85rem;
  font-size: 0.86rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

textarea {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  resize: vertical;
  min-height: 240px;
  line-height: 1.5;
  color: #cbd5e1;
}

textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
  background: rgba(15, 23, 42, 0.95);
}

/* Action Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.8);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.btn-emerald {
  background: linear-gradient(135deg, #059669, #10b981);
  color: white;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-emerald:hover {
  background: linear-gradient(135deg, #10b981, #34d399);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

/* Map Container */
.map-wrapper {
  position: relative;
  height: 420px;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

#map {
  height: 100%;
  width: 100%;
  background: #0f172a;
}

.map-overlay-legend {
  position: absolute;
  bottom: 14px;
  right: 14px;
  z-index: 500;
  background: rgba(11, 17, 32, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* Results & Pipeline visualizer */
.pipeline-stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.1rem;
}

@media (max-width: 900px) {
  .pipeline-stepper {
    grid-template-columns: repeat(2, 1fr);
  }
}

.step-box {
  background: rgba(11, 17, 32, 0.75);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: all 0.3s ease;
}

.step-box.valid {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.08);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.15);
}

.step-box.invalid {
  border-color: rgba(244, 63, 94, 0.5);
  background: rgba(244, 63, 94, 0.08);
  box-shadow: 0 0 16px rgba(244, 63, 94, 0.15);
}

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

.step-num {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
}

.step-status-icon {
  font-size: 0.95rem;
}

.step-name {
  font-size: 0.84rem;
  font-weight: 700;
  color: #ffffff;
}

.step-detail {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

/* Interactive GIS Map */
.map-wrapper {
  position: relative;
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

#map {
  height: 320px;
  width: 100%;
  background: #020617;
}

.map-overlay-legend {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.72rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 3px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #e2e8f0;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

/* Overall Status Banner */
.overall-status-banner {
  border-radius: var(--radius-md);
  padding: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid transparent;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.overall-status-banner.COMPLIANT {
  background: var(--status-compliant-bg);
  border-color: var(--status-compliant-border);
  color: var(--status-compliant-text);
}

.overall-status-banner.NON_COMPLIANT {
  background: var(--status-noncompliant-bg);
  border-color: var(--status-noncompliant-border);
  color: var(--status-noncompliant-text);
}

.status-left {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.status-icon-large {
  font-size: 2.4rem;
}

.status-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.status-subtitle {
  font-size: 0.84rem;
  color: var(--text-secondary);
}

/* Accordion & Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.6rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Code block */
pre.code-viewer {
  background: #060913;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.1rem;
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  max-height: 400px;
  overflow: auto;
  line-height: 1.45;
}

/* HS Code lookup widget */
.hs-lookup-group {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.hs-result-badge {
  font-size: 0.82rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Modal for HTML report */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal-window {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 95%;
  max-width: 1150px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.85);
}

.modal-header {
  padding: 1.1rem 1.6rem;
  background: rgba(11, 17, 32, 0.95);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  flex: 1;
  background: #ffffff;
  overflow: hidden;
}

.modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

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

/* Responsive Rules for Mobile */
@media (max-width: 900px) {
  header {
    padding: 0.85rem 1rem;
  }

  .header-container {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  .logo-group {
    justify-content: space-between;
  }

  .logo-title p {
    display: none;
  }

  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.5rem;
  }

  .header-actions .btn {
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
  }

  .preset-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .preset-buttons {
    flex-wrap: wrap;
  }

  .dashboard-grid {
    grid-template-columns: 1fr !important;
  }
}
