/* ==========================================================================
   VendHub B2B Design System — Linear / Stripe / Raycast Telemetry Craft
   ========================================================================== */

:root {
  color-scheme: light;

  /* 4px Spacing Scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Radius Scale (strict 6–12px B2B geometry) */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Light Palette — Crisp Zinc & Indigo */
  --bg-canvas: #F8F8FA;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F4F4F5;
  --bg-muted: #E4E4E7;
  --bg-hover: #F4F4F6;
  --bg-overlay: rgba(9, 9, 11, 0.42);

  --border: #E4E4E7;
  --border-subtle: #EFEFF1;
  --border-strong: #D4D4D8;

  --text-primary: #09090B;
  --text-secondary: #52525B;
  --text-muted: #71717A;

  /* Primary Interactive & Data Accents */
  --accent-primary: #18181B;
  --accent-primary-hover: #27272A;
  --accent-primary-fg: #FFFFFF;

  --accent-data: #4F46E5;
  --accent-data-hover: #4338CA;
  --accent-data-soft: rgba(79, 70, 229, 0.10);
  --accent-data-secondary: #CBD5E1;

  /* Semantic Statuses — Muted, High-Contrast B2B */
  --status-ok-fg: #047857;
  --status-ok-dot: #10B981;
  --status-ok-bg: rgba(16, 185, 129, 0.09);
  --status-ok-border: rgba(16, 185, 129, 0.24);

  --status-warn-fg: #B45309;
  --status-warn-dot: #F59E0B;
  --status-warn-bg: rgba(245, 158, 11, 0.10);
  --status-warn-border: rgba(245, 158, 11, 0.26);

  --status-err-fg: #B91C1C;
  --status-err-dot: #EF4444;
  --status-err-bg: rgba(239, 68, 68, 0.09);
  --status-err-border: rgba(239, 68, 68, 0.24);
}

html.dark {
  color-scheme: dark;

  --bg-canvas: #09090B;
  --bg-surface: #111114;
  --bg-subtle: #18181C;
  --bg-muted: #27272A;
  --bg-hover: #1C1C22;
  --bg-overlay: rgba(0, 0, 0, 0.72);

  --border: #27272A;
  --border-subtle: #1E1E23;
  --border-strong: #3F3F46;

  --text-primary: #FAFAFA;
  --text-secondary: #A1A1AA;
  --text-muted: #71717A;

  --accent-primary: #F4F4F5;
  --accent-primary-hover: #E4E4E7;
  --accent-primary-fg: #09090B;

  --accent-data: #6366F1;
  --accent-data-hover: #818CF8;
  --accent-data-soft: rgba(99, 102, 241, 0.16);
  --accent-data-secondary: #3F3F46;

  --status-ok-fg: #34D399;
  --status-ok-dot: #10B981;
  --status-ok-bg: rgba(16, 185, 129, 0.12);
  --status-ok-border: rgba(16, 185, 129, 0.26);

  --status-warn-fg: #FBBF24;
  --status-warn-dot: #F59E0B;
  --status-warn-bg: rgba(245, 158, 11, 0.12);
  --status-warn-border: rgba(245, 158, 11, 0.28);

  --status-err-fg: #F87171;
  --status-err-dot: #EF4444;
  --status-err-bg: rgba(239, 68, 68, 0.12);
  --status-err-border: rgba(239, 68, 68, 0.28);
}

/* Base Reset & Typography */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-feature-settings: "cv02" 1, "cv03" 1, "cv04" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
}

::selection {
  background-color: rgba(99, 102, 241, 0.22);
  color: var(--text-primary);
}

.num,
.tabular-nums {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "cv11" 1;
}

.mono {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* Custom Slim Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.scrollbar-none::-webkit-scrollbar {
  display: none;
}
.scrollbar-none {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Focus Rings */
:focus-visible {
  outline: 2px solid var(--accent-data);
  outline-offset: 1px;
}

/* Number Input Spinners Removal */
.no-spinners::-webkit-outer-spin-button,
.no-spinners::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.no-spinners {
  -moz-appearance: textfield;
}

/* Surfaces (Declare elevation once: 1px hairline border, no muddy blur shadows) */
.vh-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.vh-panel-subtle {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

/* Topbar & Navigation Tabs */
.vh-topbar {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.vh-nav-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: color 140ms ease, border-color 140ms ease;
  white-space: nowrap;
  cursor: pointer;
  background: transparent;
}

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

.vh-nav-tab.active {
  color: var(--text-primary);
  font-weight: 600;
  border-bottom-color: var(--text-primary);
}

/* Mobile Fixed Bottom Navigation (< 640px) */
.vh-mobile-nav {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.vh-mobile-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  min-width: 44px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 140ms ease;
  background: transparent;
  border: none;
  cursor: pointer;
}

.vh-mobile-tab.active {
  color: var(--text-primary);
  font-weight: 600;
}

/* Buttons */
.vh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: background-color 130ms ease, border-color 130ms ease, color 130ms ease, opacity 130ms ease;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.vh-btn.hidden {
  display: none;
}

@media (min-width: 640px) {
  .vh-btn.hidden.sm\:inline-flex {
    display: inline-flex;
  }
}

@media (max-width: 639px) {
  .vh-btn-touch {
    min-height: 44px;
    padding: 0 14px;
    font-size: 13px;
  }
}

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

.vh-btn-primary {
  background-color: var(--accent-primary);
  color: var(--accent-primary-fg);
  border: 1px solid transparent;
  font-weight: 600;
}
.vh-btn-primary:hover:not(:disabled) {
  background-color: var(--accent-primary-hover);
}

.vh-btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.vh-btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-subtle);
  border-color: var(--border-strong);
}

.vh-btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.vh-btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.vh-btn-danger {
  background-color: transparent;
  color: var(--status-err-fg);
  border: 1px solid var(--status-err-border);
}
.vh-btn-danger:hover:not(:disabled) {
  background-color: var(--status-err-bg);
}

/* Inputs & Selects */
.vh-input,
.vh-select {
  height: 36px;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 11px;
  font-size: 13px;
  transition: border-color 130ms ease, box-shadow 130ms ease;
}

@media (max-width: 639px) {
  .vh-input,
  .vh-select {
    min-height: 44px;
    font-size: 14px;
  }
}

.vh-input::placeholder {
  color: var(--text-muted);
}

.vh-input:hover,
.vh-select:hover {
  border-color: var(--border-strong);
}

.vh-input:focus,
.vh-select:focus {
  outline: none;
  border-color: var(--accent-data);
  box-shadow: 0 0 0 2px var(--accent-data-soft);
}

/* Segmented Controls */
.vh-segmented {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  gap: 2px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.vh-seg-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
  white-space: nowrap;
}

@media (max-width: 639px) {
  .vh-seg-btn {
    min-height: 36px;
    padding: 0 12px;
  }
}

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

.vh-seg-btn.active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Semantic Status Badges */
.vh-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.vh-badge-ok {
  color: var(--status-ok-fg);
  background-color: var(--status-ok-bg);
  border: 1px solid var(--status-ok-border);
}

.vh-badge-warn {
  color: var(--status-warn-fg);
  background-color: var(--status-warn-bg);
  border: 1px solid var(--status-warn-border);
}

.vh-badge-err {
  color: var(--status-err-fg);
  background-color: var(--status-err-bg);
  border: 1px solid var(--status-err-border);
}

.vh-badge-neutral {
  color: var(--text-secondary);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border);
}

.vh-fifo-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
  max-width: 100%;
}

.vh-dot {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  flex-shrink: 0;
}
.vh-dot-ok { background-color: var(--status-ok-dot); }
.vh-dot-warn { background-color: var(--status-warn-dot); }
.vh-dot-err { background-color: var(--status-err-dot); }

/* Signature Element: Precision Hopper Telemetry Gauge */
.vh-gauge {
  position: relative;
  width: 100%;
  height: 6px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  overflow: visible;
}

.vh-gauge-track {
  width: 100%;
  height: 100%;
  border-radius: 9999px;
  overflow: hidden;
}

.vh-gauge-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

.vh-gauge-threshold {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 1.5px;
  background-color: var(--status-err-dot);
  opacity: 0.7;
  pointer-events: none;
}

/* Professional B2B Data Tables */
.vh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.vh-table thead th {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.vh-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.vh-table tbody tr:last-child td {
  border-bottom: none;
}

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

/* Modal Backdrop & Dialog */
.vh-modal-backdrop {
  background-color: var(--bg-overlay);
  backdrop-filter: blur(2px);
}

.vh-modal-panel {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.28);
}

/* Toast Notification */
@keyframes vh-toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.vh-toast {
  animation: vh-toast-in 200ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.16);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
