:root {
  --bg-primary: #0a0f18;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(31, 41, 55, 0.95);
  --border-color: rgba(75, 85, 99, 0.4);
  --border-focus: #3b82f6;
  
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

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

  --status-compliant-bg: rgba(16, 185, 129, 0.15);
  --status-compliant-border: #10b981;
  --status-compliant-text: #34d399;

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

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

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.25);
  --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.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Background grid styling */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 15% 15%, rgba(59, 130, 246, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(16, 185, 129, 0.06) 0%, transparent 40%),
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(10, 15, 24, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
}

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

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

.logo-badge {
  background: linear-gradient(135deg, #10b981, #3b82f6);
  color: #fff;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.logo-title h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ffffff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

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

.badge-cutoff {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #93c5fd;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.badge-cutoff span.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #3b82f6;
  box-shadow: 0 0 6px #3b82f6;
}

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

/* Preset Toolbar */
.preset-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.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.5rem;
}

.btn-preset {
  background: rgba(31, 41, 55, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-preset:hover {
  background: rgba(55, 65, 81, 0.9);
  border-color: var(--accent-blue);
  transform: translateY(-1px);
}

.btn-preset.active {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--accent-blue);
  color: #bfdbfe;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

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

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

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(75, 85, 99, 0.25);
  padding-bottom: 0.75rem;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

textarea, input, select {
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  resize: vertical;
  min-height: 220px;
  line-height: 1.4;
}

textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

/* 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 ease;
}

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

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

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

.btn-secondary:hover {
  background: rgba(55, 65, 81, 1);
  border-color: #9ca3af;
}

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

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

/* Map Container */
.map-wrapper {
  position: relative;
  height: 380px;
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

#map {
  height: 100%;
  width: 100%;
  background: #1e293b;
}

.map-overlay-legend {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 500;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

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

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

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

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

.step-box {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: all 0.3s ease;
}

.step-box.valid {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
}

.step-box.invalid {
  border-color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.08);
}

.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.9rem;
}

.step-name {
  font-size: 0.82rem;
  font-weight: 700;
}

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

/* Overall Status Banner */
.overall-status-banner {
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid transparent;
}

.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: 1rem;
}

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

.status-title {
  font-size: 1.2rem;
  font-weight: 800;
}

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

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

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

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

.tab-content {
  display: none;
}

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

/* Code block */
pre.code-viewer {
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  max-height: 380px;
  overflow: auto;
}

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

.hs-result-badge {
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(31, 41, 55, 0.8);
  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(8px);
  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: 1100px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.modal-header {
  padding: 1rem 1.5rem;
  background: rgba(15, 23, 42, 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); }
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.5);
}

::-webkit-scrollbar-thumb {
  background: rgba(75, 85, 99, 0.5);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(107, 114, 128, 0.8);
}
