/* AURA X — light spectrum theme. Studio-white canvas, blurred violet→orange→red aura, frosted white glass, black pills.
   Tailwind (CDN) handles layout; this file holds the design system for both views (#landing, #admin). */
:root {
  --bg: #FCFCFD;
  --bg-2: #F8F9FA;
  --panel: rgba(255, 255, 255, 0.75);
  --panel-2: rgba(255, 255, 255, 0.82);
  --paper: #FFFFFF;
  --line: rgba(229, 231, 235, 0.8);
  --line-strong: #E5E7EB;
  --text: #111827;
  --muted: #4B5563;
  --faint: #6B7280;
  --violet: #8B5CF6;
  --orange: #F97316;
  --red: #EF4444;
  --green: #059669;    /* net margin healthy */
  --amber: #D97706;    /* review alerts */
  --spectrum: linear-gradient(90deg, #8B5CF6 0%, #D946EF 38%, #F97316 72%, #EF4444 100%);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.04);
  --shadow-lift: 0 24px 60px rgba(17, 24, 39, 0.08);
}

html, body { color: var(--text); font-family: "Plus Jakarta Sans", "Inter", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
body { background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%) fixed; background-color: var(--bg); overflow-x: hidden; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
::selection { background: rgba(139, 92, 246, .22); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }

/* ---------- View switching (html[data-view] is set before first paint and by app.js) ---------- */
html[data-view="admin"] .view-landing, html[data-view="admin"] .landing-only { display: none !important; }
html[data-view="landing"] .view-admin, html[data-view="landing"] .desk-only { display: none !important; }
html { scroll-padding-top: 72px; }

/* ---------- Ambient spectrum aura: diffused blobs under everything ---------- */
.aura { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55; will-change: transform; }
.b1 { width: 46vw; height: 46vw; left: -8vw; top: -12vw; background: #8B5CF6; animation: drift1 26s ease-in-out infinite alternate; }
.b2 { width: 40vw; height: 40vw; right: -10vw; top: 6vh; background: #F97316; opacity: .42; animation: drift2 30s ease-in-out infinite alternate; }
.b3 { width: 34vw; height: 34vw; right: 18vw; bottom: -14vw; background: #EF4444; opacity: .3; animation: drift3 34s ease-in-out infinite alternate; }
.b4 { width: 30vw; height: 30vw; left: 22vw; bottom: -10vw; background: #D946EF; opacity: .22; animation: drift1 38s ease-in-out infinite alternate-reverse; }
html[data-view="admin"] .blob { opacity: .28; }   /* calmer behind dense data */
@keyframes drift1 { to { transform: translate(8vw, 6vh) scale(1.08); } }
@keyframes drift2 { to { transform: translate(-6vw, 10vh) scale(.94); } }
@keyframes drift3 { to { transform: translate(-10vw, -6vh) scale(1.1); } }
@media (prefers-reduced-motion: reduce) { .blob { animation: none; } }

/* Full-screen WebGL particle field; all UI floats above it */
#bgCanvas { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; pointer-events: none; }
body > header, body > main, body > #landingView { position: relative; z-index: 1; }

/* Remap the Tailwind utilities used in markup to slate tones on white glass */
.text-slate-300 { color: #374151 !important; }
.text-slate-400 { color: #4B5563 !important; }
.text-slate-500 { color: #6B7280 !important; }
.text-slate-600 { color: #9CA3AF !important; }
.text-emerald-400, .text-green-400 { color: var(--green) !important; }
.text-purple-400 { color: var(--violet) !important; }
.text-amber-400 { color: var(--amber) !important; }
.text-amber-200 { color: #92400E !important; }
.text-red-400 { color: #DC2626 !important; }
.hover\:text-white:hover { color: #111827 !important; }
.border-amber-500\/40 { border-color: rgba(249, 115, 22, .4) !important; }
.bg-amber-500\/5 { background: linear-gradient(90deg, rgba(249,115,22,.1), rgba(239,68,68,.06)) , rgba(255,255,255,.8) !important; }

/* ---------- Glass ---------- */
.glass, .panel { background: var(--panel); backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.app-header { background: rgba(252, 252, 253, 0.7); backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4); border-bottom: 1px solid var(--line); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-title { font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* ---------- Header / brand / nav ---------- */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark { width: 28px; height: 28px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: var(--spectrum); box-shadow: 0 6px 16px rgba(139, 92, 246, .3); flex: 0 0 auto; }
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: .02em; }
.brand-tag { font-size: 11px; color: var(--faint); padding-left: 10px; border-left: 1px solid var(--line-strong); }
.nav-links { gap: 26px; align-items: center; }
.nav-links a { font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none; transition: color .15s; }
.nav-links a:hover { color: var(--text); }

/* ---------- Landing page ---------- */
.landing-hero { display: grid; gap: 28px; align-items: center; grid-template-columns: minmax(0, 1fr); padding-top: 48px; padding-bottom: 8px; }
@media (min-width: 1024px) { .landing-hero { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: calc(100vh - 60px); padding-top: 0; } }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: #374151;
  background: rgba(255,255,255,.75); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(12px); max-width: 100%; }
.eyebrow-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--spectrum); box-shadow: 0 0 0 3px rgba(139, 92, 246, .15); flex: 0 0 auto; }
.display { margin: 22px 0 0; font-weight: 800; font-size: clamp(40px, 6.4vw, 84px); line-height: .98; letter-spacing: -.045em; color: var(--text); }
.grad-text { background: var(--spectrum); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { margin-top: 20px; max-width: 34em; font-size: clamp(15px, 1.35vw, 18px); line-height: 1.6; color: var(--muted); }
.hero-stats { display: flex; flex-wrap: wrap; gap: 12px 32px; margin-top: 36px; }
.hero-stats dt { font-size: 10.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.hero-stats dd { margin: 3px 0 0; font-family: var(--mono); font-size: 17px; font-weight: 500; color: var(--text); }
.landing-globe { position: relative; overflow: hidden; border-radius: 28px; background: rgba(255,255,255,.45); }
.hero-globe-box { height: clamp(320px, 52vw, 560px); position: relative; cursor: grab; touch-action: pan-y; }
.hero-globe-box:active { cursor: grabbing; }
.hero-globe-box canvas { display: block; width: 100%; height: 100%; }
.globe-legend { position: absolute; left: 18px; bottom: 14px; display: flex; gap: 16px; font-size: 11px; color: var(--muted); pointer-events: none; }
.globe-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.lg-dot.origin { background: var(--violet); } .lg-dot.dest { background: var(--orange); }

.section-kicker { font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; background: var(--spectrum); -webkit-background-clip: text; background-clip: text; color: transparent; display: inline-block; }
.section-title { margin-top: 8px; font-size: clamp(26px, 3.4vw, 40px); font-weight: 800; letter-spacing: -.035em; line-height: 1.1; max-width: 20em; }
.feature-grid { display: grid; gap: 16px; margin-top: 28px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .feature-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.feature { padding: 22px; border-radius: 22px; }
.feature h3 { margin-top: 16px; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.feature p { margin-top: 8px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.feature-icon { width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: var(--spectrum); box-shadow: 0 10px 22px rgba(217, 70, 239, .22); }
.feature:nth-child(2) .feature-icon { background: linear-gradient(135deg, #8B5CF6, #6366F1); }
.feature:nth-child(3) .feature-icon { background: linear-gradient(135deg, #F97316, #EF4444); }
.feature:nth-child(4) .feature-icon { background: linear-gradient(135deg, #111827, #4B5563); }

.flow { list-style: none; margin: 28px 0 0; padding: 8px; display: grid; gap: 4px; grid-template-columns: minmax(0, 1fr); border-radius: 22px; }
@media (min-width: 900px) { .flow { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.flow li { padding: 16px; border-radius: 16px; display: flex; flex-direction: column; gap: 4px; position: relative; }
.flow li:hover { background: rgba(255,255,255,.8); }
.flow b { font-size: 14px; font-weight: 700; }
.flow li > span:last-child { font-size: 12px; line-height: 1.5; color: var(--muted); }
.flow-n { font-family: var(--mono); font-size: 11px; font-weight: 600; background: var(--spectrum); -webkit-background-clip: text; background-clip: text; color: transparent; }
.cta-band { margin-top: 20px; padding: 26px; border-radius: 24px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px;
  background: linear-gradient(120deg, rgba(139,92,246,.1), rgba(255,255,255,.75) 45%, rgba(249,115,22,.12)); }
.cta-band h3 { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.cta-band p { margin-top: 4px; font-size: 13px; color: var(--muted); }
.site-foot { margin-top: 36px; display: flex; justify-content: space-between; gap: 12px; font-size: 11px; color: var(--faint); }
.site-foot span:first-child { font-weight: 800; color: var(--text); letter-spacing: .04em; }

/* ---------- Admin display header ---------- */
.hero { position: relative; padding: 10px 4px 0; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.hero-title { font-weight: 800; letter-spacing: -.045em; line-height: .9; font-size: clamp(44px, 8.4vw, 124px); margin: 0; white-space: nowrap; color: var(--text); }
.hero-x { font-weight: 300; margin: 0 .12em; background: var(--spectrum); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-side { text-align: right; font-size: 11px; line-height: 1.9; color: var(--muted); letter-spacing: .06em; display: none; }
.hero-side span { display: block; border-bottom: 1px solid var(--line-strong); padding-bottom: 1px; }
@media (min-width: 1250px) { .hero-side { display: block; } }

/* Scrollbars */
.scroll { overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(107,114,128,.35) transparent; }
.scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll::-webkit-scrollbar-thumb { background: rgba(107,114,128,.3); border-radius: 8px; }

/* KPI tiles */
.kpi { padding: 14px 18px; border-right: 1px solid var(--line); min-width: 0; }
.kpi:last-child { border-right: 0; }
.kpi-label { font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.kpi-value { font-family: var(--mono); font-size: 26px; font-weight: 500; line-height: 1.2; margin-top: 2px; color: var(--text); }
.kpi-sub { font-size: 10px; color: var(--faint); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { color: #047857; background: rgba(16,185,129,.1); border-color: rgba(16,185,129,.35); }
.badge-amber { color: #B45309; background: rgba(249,115,22,.1); border-color: rgba(249,115,22,.4); }
.badge-amber.pulse::before { animation: pulse 1.4s infinite; }
.badge-red { color: #B91C1C; background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.35); }
.badge-blue { color: #6D28D9; border-color: transparent;
  background: linear-gradient(#fff, #fff) padding-box, var(--spectrum) border-box; }
.badge-blue::before { background: var(--spectrum); }
.badge-gray { color: #4B5563; background: rgba(243,244,246,.9); border-color: var(--line-strong); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* Campaign feed */
.camp-row { width: 100%; text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; transition: background .15s; display: block; }
.camp-row:hover { background: rgba(255,255,255,.7); }
.camp-row.active { background: linear-gradient(90deg, rgba(139,92,246,.09), rgba(249,115,22,.05) 70%, transparent); border-left-color: var(--violet); }

/* Pricing cards */
.price-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; box-shadow: 0 10px 24px rgba(0,0,0,.03); }
.price-card .label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.price-card .value { font-family: var(--mono); font-size: 18px; font-weight: 500; margin-top: 2px; color: var(--text); }
.price-card .hint { font-size: 10px; color: var(--faint); margin-top: 1px; }
.price-card.accent-green { border-top: 2px solid var(--green); }
.price-card.accent-amber { border-top: 2px solid var(--orange); }
.price-card.accent-red { border-top: 2px solid var(--red); }
.price-card.accent-blue { border-top: 2px solid var(--violet); }

/* Spread gauge */
.gauge { position: relative; height: 8px; border-radius: 8px; background: #EEF0F3; overflow: visible; }
.gauge-fill { height: 100%; border-radius: 8px; transition: width .4s; }
.gauge-mark { position: absolute; top: -4px; width: 2px; height: 16px; background: var(--red); }

/* Messages: white paper, coloured border per sender */
.bubble-row { display: flex; margin-bottom: 12px; }
.bubble-row.right { justify-content: flex-end; }
.bubble { max-width: 88%; border-radius: 12px; padding: 10px 13px; border: 1px solid var(--line-strong); background: var(--paper); box-shadow: 0 8px 20px rgba(0,0,0,.035); border-left-width: 4px; }
.bubble-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 10px; margin-bottom: 4px; }
.bubble-who { font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.bubble-subject { font-size: 11.5px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.bubble-body { font-family: var(--mono); font-size: 11px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; color: #374151; }
.bubble.buyer { border-left-color: var(--green); }
.bubble.buyer .bubble-who { color: var(--green); }
.bubble.supplier { border-left-color: var(--orange); }
.bubble.supplier .bubble-who { color: #C2410C; }
.bubble.desk { border-left-color: var(--violet); background: linear-gradient(135deg, rgba(139,92,246,.06), #fff 55%); }
.bubble.desk .bubble-who { color: #6D28D9; }

/* Audit timeline */
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 1px; background: var(--line-strong); }
.tl-item { position: relative; padding-bottom: 12px; }
.tl-dot { position: absolute; left: -18px; top: 3px; width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 2px solid var(--faint); }
.tl-dot.green { border-color: var(--green); } .tl-dot.amber { border-color: var(--orange); }
.tl-dot.red { border-color: var(--red); } .tl-dot.blue { border-color: var(--violet); }

/* Pipeline stepper */
.step { flex: 1; text-align: center; font-size: 10px; color: var(--faint); position: relative; }
.step .n { width: 22px; height: 22px; margin: 0 auto 3px; border-radius: 50%; border: 1px solid var(--line-strong); display: flex; align-items: center; justify-content: center; font-weight: 700; background: #fff; }
.step.done .n { background: #111827; border-color: #111827; color: #fff; }
.step.now .n { border-color: transparent; color: #6D28D9; background: linear-gradient(#fff, #fff) padding-box, var(--spectrum) border-box; border-width: 2px; box-shadow: 0 0 0 4px rgba(139,92,246,.12); }
.step.done, .step.now { color: var(--text); }

/* Tabs / controls */
.tab { padding: 4px 11px; font-size: 11px; font-weight: 600; border-radius: 999px; color: var(--muted); border: 1px solid transparent; transition: color .15s, background .15s; }
.tab:hover { color: var(--text); }
.tab.active { color: #fff; background: #111827; border-color: #111827; }
.input { width: 100%; background: rgba(255,255,255,.9); border: 1px solid var(--line-strong); border-radius: 10px; padding: 7px 10px; font-size: 12px; color: var(--text); }
.input::placeholder { color: #9CA3AF; }
.input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(139,92,246,.16); }
input[type="checkbox"], input[type="radio"] { accent-color: #111827; }

/* Buttons: black pill primary, white glass secondary */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border-radius: 999px; font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap;
  border: 1px solid var(--line-strong); background: rgba(255,255,255,.85); color: var(--text); transition: transform .12s, box-shadow .15s, background .15s; }
.btn:hover { box-shadow: 0 10px 24px rgba(17,24,39,.08); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-lg { padding: 12px 22px; font-size: 14px; }
.btn-blue { background: #111827; border-color: #111827; color: #FFFFFF; }
.btn-blue:hover { background: #000; box-shadow: 0 12px 28px rgba(17,24,39,.25), 0 0 0 4px rgba(139,92,246,.12); }
.btn-green { background: #059669; border-color: #059669; color: #fff; }
.btn-green:hover { background: #047857; box-shadow: 0 12px 26px rgba(5,150,105,.25); }
.btn-red { background: #fff; border-color: rgba(239,68,68,.45); color: #B91C1C; }
.btn-red:hover { background: #FEF2F2; box-shadow: 0 10px 24px rgba(239,68,68,.15); }
details > summary { list-style: none; } details > summary::-webkit-details-marker { display: none; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(17,24,39,.22); backdrop-filter: blur(8px); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop.hidden { display: none; }
.modal { width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; background: rgba(255,255,255,.92); backdrop-filter: blur(24px); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 40px 90px rgba(17,24,39,.18); }

/* Toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 14px; border-radius: 12px; font-size: 12px; background: #fff; border: 1px solid var(--line-strong); box-shadow: 0 14px 30px rgba(17,24,39,.12); max-width: 340px; }
.toast.error { border-color: rgba(239,68,68,.5); color: #B91C1C; }
.toast.ok { border-color: rgba(5,150,105,.45); color: #047857; }

/* Layout */
.workspace { display: grid; gap: 14px; grid-template-columns: 300px minmax(0, 1fr); }
@media (max-width: 820px) { .workspace { grid-template-columns: minmax(0, 1fr); } .kpi { border-right: 0; border-bottom: 1px solid var(--line); } }
.inspector-split { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .inspector-split { grid-template-columns: minmax(0, 1fr) 320px; } }

/* 3D strip */
.stage-3d { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .stage-3d { grid-template-columns: minmax(0, 1fr) 380px; } }
.viz-box { height: 270px; position: relative; cursor: grab; touch-action: pan-y; }
.viz-box:active { cursor: grabbing; }
.viz-box canvas { display: block; width: 100%; height: 100%; }
.viz-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); text-align: center; padding: 16px; }
.cube-readout { position: absolute; left: 16px; bottom: 12px; pointer-events: none; }
.cube-readout .big { font-family: var(--mono); font-size: 22px; font-weight: 500; }
.cube-readout .sub { font-size: 10px; color: var(--muted); }

/* Tilt with light glare (driven by --rx/--ry/--gx/--gy from components.js) */
.tilt { position: relative; transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .2s ease-out, box-shadow .2s; will-change: transform; }
.tilt::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .2s;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 0%), rgba(255,255,255,.9), rgba(255,255,255,0) 55%); mix-blend-mode: soft-light; }
.tilt.tilting { box-shadow: var(--shadow-lift); z-index: 2; }
.tilt.tilting::after { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .tilt { transform: none !important; transition: none; } }
