/* ═══════════════════════════════════════════════
   Stockd — Design System
   Aesthetic: Industrial Kitchen Command Center
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,500;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;600&display=swap');

/* ── Variables ────────────────────────────── */
:root {
  --bg-base: #0d0f14;
  --bg-card: #161921;
  --bg-card-alt: #1a1e2a;
  --bg-hover: rgba(0, 212, 170, 0.03);
  --border: #262b38;
  --border-hover: #3a4060;
  --text-primary: #e8ecf4;
  --text-secondary: #c8cee0;
  --text-muted: #6b7394;
  --text-dim: #4a5070;
  --text-faint: #3a4060;
  --accent: #00d4aa;
  --accent-hover: #00b894;
  --accent-glow: rgba(0, 212, 170, 0.3);
  --blue: #0088ff;
  --blue-soft: #4da6ff;
  --purple: #a855f7;
  --orange: #ff9500;
  --orange-soft: #ffb347;
  --red: #ff4444;
  --red-soft: #ff6b6b;
  --yellow: #ff9500;
  --green: #34c759;
  --green-soft: #5dda7e;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
}

/* ── Reset ────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-secondary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── Animations ───────────────────────────── */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

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

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

.animate-in {
  animation: slideUp 0.5s ease forwards;
}

.stagger-1 {
  animation-delay: 0.05s;
  opacity: 0;
}

.stagger-2 {
  animation-delay: 0.1s;
  opacity: 0;
}

.stagger-3 {
  animation-delay: 0.15s;
  opacity: 0;
}

.stagger-4 {
  animation-delay: 0.2s;
  opacity: 0;
}

/* ── Layout ───────────────────────────────── */
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 28px 60px;
}

.page-narrow {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 20px;
}

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

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

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

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

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gap-8 {
  gap: 8px;
}

.gap-12 {
  gap: 12px;
}

.gap-16 {
  gap: 16px;
}

.gap-20 {
  gap: 20px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-24 {
  margin-top: 24px;
}

.mt-32 {
  margin-top: 32px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-24 {
  margin-bottom: 24px;
}

/* ── Top Nav ──────────────────────────────── */
.topnav {
  background: linear-gradient(180deg, #12141c 0%, var(--bg-base) 100%);
  border-bottom: 1px solid #1e2230;
  padding: 0 28px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.topnav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topnav-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  color: var(--bg-base);
}

.topnav-title {
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.topnav-sub {
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.topnav-links {
  display: flex;
  gap: 2px;
}

.topnav-link {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  transition: all 0.2s;
}

.topnav-link:hover {
  color: var(--text-secondary);
}

.topnav-link.active {
  background: rgba(0, 212, 170, 0.1);
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.topnav-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ── Cards ────────────────────────────────── */
.card {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-alt) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s, transform 0.3s;
}

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

.card-accent-bar {
  position: absolute;
  bottom: 0;
  left: 24px;
  right: 24px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.5;
}

/* ── KPI Stat Cards ───────────────────────── */
.stat-card {
  position: relative;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stat-value {
  color: var(--text-primary);
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.stat-sub {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 6px;
}

.stat-icon {
  position: absolute;
  top: -20px;
  right: -20px;
  font-size: 72px;
  opacity: 0.04;
}

/* ── Section Headers ──────────────────────── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  margin-top: 28px;
}

.section-header h2 {
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-header h2::before {
  content: '';
  width: 3px;
  height: 18px;
  background: linear-gradient(180deg, var(--accent), var(--blue));
  border-radius: 2px;
  display: inline-block;
}

/* ── Tables ───────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead tr {
  border-bottom: 1px solid var(--border);
}

.data-table th {
  padding: 13px 14px;
  text-align: left;
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #1a1e2a;
}

.data-table tbody tr {
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.data-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.008);
}

.data-table tbody tr:nth-child(even):hover {
  background: var(--bg-hover);
}

.mono {
  font-family: var(--font-mono);
}

/* ── Status Badges ────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.badge-ok {
  background: #0a2d14;
  border: 1px solid var(--green);
  color: var(--green-soft);
}

.badge-ok::before {
  background: var(--green-soft);
  box-shadow: 0 0 6px var(--green-soft);
}

.badge-warning {
  background: #2d1f0a;
  border: 1px solid var(--orange);
  color: var(--orange-soft);
}

.badge-warning::before {
  background: var(--orange-soft);
  box-shadow: 0 0 6px var(--orange-soft);
}


.badge-critical {
  background: #2d0a0a;
  border: 1px solid var(--red);
  color: var(--red-soft);
}

.badge-critical::before {
  background: var(--red-soft);
  box-shadow: 0 0 6px var(--red-soft);
  animation: pulse 1.2s infinite;
}

.badge-unknown {
  background: #1a1c28;
  border: 1px solid var(--text-faint);
  color: var(--text-muted);
}

.badge-unknown::before {
  background: var(--text-muted);
}

.category-tag {
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(0, 136, 255, 0.1);
  color: var(--blue-soft);
  font-size: 11px;
  font-weight: 600;
}

/* ── Buttons ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: var(--bg-base);
  border: none;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-secondary {
  background: rgba(0, 212, 170, 0.1);
  border: 1px solid rgba(0, 212, 170, 0.3);
  color: var(--accent);
}

.btn-secondary:hover {
  background: rgba(0, 212, 170, 0.15);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-outline:hover {
  border-color: var(--text-muted);
  color: var(--text-secondary);
}

.btn-danger {
  background: rgba(255, 68, 68, 0.12);
  border: 1px solid var(--red);
  color: var(--red-soft);
}

.btn-blue {
  background: rgba(0, 136, 255, 0.1);
  border: 1px solid rgba(0, 136, 255, 0.3);
  color: var(--blue-soft);
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-lg {
  padding: 13px 24px;
  font-size: 14px;
}

/* ── Forms ────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: 0.03em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: #111420;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-body);
  transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.1);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7394' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-input.mono,
.form-select.mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ── Upload Zone ──────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius-md);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(0, 212, 170, 0.03);
}

.upload-zone input[type="file"] {
  display: none;
}

.upload-zone .icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.upload-zone .label {
  color: var(--text-muted);
  font-size: 13px;
}

.upload-zone .hint {
  color: var(--text-faint);
  font-size: 11px;
  margin-top: 8px;
}

/* ── Progress Bar ─────────────────────────── */
.progress-bar {
  width: 100%;
  height: 8px;
  background: #1e2230;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  border-radius: 4px;
  transition: width 0.3s;
}

.progress-label {
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
  margin-top: 6px;
}

/* ── Alerts / Banners ─────────────────────── */
.alert-banner {
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  animation: slideUp 0.4s ease;
}

.alert-banner.critical {
  background: linear-gradient(135deg, #2d0a0a 0%, #1a1015 100%);
  border: 1px solid #442020;
}

.alert-banner.info {
  background: rgba(0, 136, 255, 0.06);
  border: 1px solid rgba(0, 136, 255, 0.2);
}

.alert-banner.success {
  background: rgba(0, 212, 170, 0.06);
  border: 1px solid rgba(0, 212, 170, 0.2);
}

.alert-banner .alert-icon {
  font-size: 24px;
}

.alert-banner .alert-body {
  flex: 1;
}

.alert-banner .alert-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 2px;
}

.alert-banner .alert-text {
  font-size: 12px;
  color: var(--text-muted);
}

.alert-banner.critical .alert-title {
  color: var(--red-soft);
}

.alert-banner.success .alert-title {
  color: var(--accent);
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.alert-item.alert-critical {
  background: rgba(255, 68, 68, 0.06);
  border: 1px solid #331a1a;
}

.alert-item.alert-warning {
  background: rgba(255, 149, 0, 0.06);
  border: 1px solid #332a1a;
}

.alert-item .alert-icon {
  font-size: 14px;
  margin-top: 2px;
}

.alert-item strong {
  font-size: 12px;
  font-weight: 600;
}

.alert-item.alert-critical strong {
  color: var(--red-soft);
}

.alert-item.alert-warning strong {
  color: var(--orange-soft);
}

.alert-item p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Status Message ───────────────────────── */
.status-msg {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 12px;
  line-height: 1.5;
}

.status-msg.info {
  background: rgba(0, 136, 255, 0.08);
  border: 1px solid rgba(0, 136, 255, 0.2);
  color: var(--blue-soft);
}

.status-msg.error {
  background: rgba(255, 68, 68, 0.08);
  border: 1px solid rgba(255, 68, 68, 0.2);
  color: var(--red-soft);
}

.status-msg.success {
  background: rgba(0, 212, 170, 0.08);
  border: 1px solid rgba(0, 212, 170, 0.2);
  color: var(--accent);
}

/* ── Parse Preview Stats ──────────────────── */
.parse-stats {
  display: grid;
  gap: 6px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.stat-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.015);
}

.stat-row .label {
  color: var(--text-muted);
}

.stat-row .value {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}

/* ── Mini progress bars (in tables) ───────── */
.mini-bar {
  width: 60px;
  height: 3px;
  background: #1e2230;
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  border-radius: 2px;
}

/* ── Step indicator ───────────────────────── */
.step {
  margin-bottom: 16px;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: rgba(0, 212, 170, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.step-num.done {
  background: var(--accent);
  color: var(--bg-base);
}

.step-title {
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
}

/* ── Loading / Empty states ───────────────── */
.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 15, 20, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state h3 {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  max-width: 400px;
  margin: 0 auto;
}

/* ── Footer ───────────────────────────────── */
.page-footer {
  margin-top: 40px;
  padding: 18px 0;
  border-top: 1px solid #1a1e2a;
  text-align: center;
  color: var(--text-faint);
  font-size: 11px;
}

/* ── Modal ────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-alt) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 460px;
  max-width: 90vw;
  animation: slideUp 0.3s ease;
}

.modal-content h3 {
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

/* ── Toast / Snackbar ─────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  animation: slideUp 0.3s ease;
  min-width: 280px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.toast.success {
  background: #0a2d14;
  border: 1px solid var(--green);
  color: var(--green-soft);
}

.toast.error {
  background: #2d0a0a;
  border: 1px solid var(--red);
  color: var(--red-soft);
}

.toast.info {
  background: #0a1a2d;
  border: 1px solid var(--blue);
  color: var(--blue-soft);
}

/* ── Responsive ───────────────────────────── */
@media (max-width: 900px) {
  .grid-4 {
    grid-template-columns: 1fr 1fr;
  }

  .grid-3 {
    grid-template-columns: 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .topnav-links {
    display: none;
  }
}

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

  .page-container {
    padding: 16px 14px 40px;
  }

  .topnav {
    padding: 0 14px;
  }
}