/* ==========================================================================
   pasarvision — Ethereal Bento Dark UI System (Zero-Lag Pure CSS)
   Inspired by modern tactile Bento dark interfaces:
   Canvas #08090E | Card #13151F | Mint-Lime Hero | Soft Lavender Accents
   ========================================================================== */

:root {
  --bg: #08090e;
  --card: #13151f;
  --card-alt: #181b28;
  --pill-bg: #1e2231;
  --pill-hover: #262b3d;
  --border: rgba(255, 255, 255, 0.055);
  --border-strong: rgba(255, 255, 255, 0.11);

  --text: #f5f7fb;
  --text-soft: #9ca3b8;
  --text-dim: #666e85;
  --ink: #090b10;

  --mint-grad: linear-gradient(135deg, #88f4d8 0%, #b3f6b2 52%, #daf881 100%);
  --mint: #b8f69c;
  --lime-pill: #ccf779;
  --lavender: #c7b5ff;
  --coral-pill: #ff8580;
  --amber: #fcd34d;

  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-pill: 999px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background-color: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.num {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* Minimal Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #232738;
  border-radius: 999px;
}

/* App Shell */
.app-shell {
  max-width: 1560px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ==========================================================================
   TOP BAR (Ethereal Capsule Nav)
   ========================================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 50px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.025em;
  color: var(--text);
  user-select: none;
}

.brand-mark {
  width: 30px;
  height: 24px;
  border-radius: 8px;
  border: 2px solid var(--text);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 0 5px;
}

.brand-mark span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
}

.brand-mark span:last-child {
  width: 68%;
}

.nav-capsule {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #141621;
  border: 1px solid var(--border);
  padding: 5px;
  border-radius: var(--radius-pill);
}

.nav-tab {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

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

.nav-tab.active {
  background: #ffffff;
  color: var(--ink);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #141621;
  border: 1px solid var(--border);
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
}

.status-dot.prod {
  background: var(--mint);
}

.icon-circle-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #141621;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.icon-circle-btn:hover,
.icon-circle-btn.active {
  background: var(--pill-hover);
  border-color: var(--border-strong);
}

/* ==========================================================================
   SUBHEADER & QUICK CONTROLS BAR
   ========================================================================== */
.subheader {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.toolbar-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.seg-group {
  display: inline-flex;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: var(--radius-pill);
  gap: 2px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.seg-btn.active {
  background: var(--pill-hover);
  color: var(--text);
}

.pill-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 30px 8px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  outline: none;
  max-width: 210px;
  text-overflow: ellipsis;
  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='%239ca3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}

.pill-select:hover,
.pill-select:focus {
  border-color: var(--border-strong);
}

.pill-select option {
  background: #13151f;
  color: var(--text);
}

.pill-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 15px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color 0.12s ease, transform 0.1s ease;
}

.pill-btn:hover:not(:disabled) {
  background: var(--pill-hover);
}

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

.pill-btn.white {
  background: #ffffff;
  color: var(--ink);
  border-color: #ffffff;
}

.pill-btn.white:hover:not(:disabled) {
  background: #e9edf5;
}

.pill-btn.ink {
  background: var(--ink);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.08);
}

.pill-btn.ink:hover:not(:disabled) {
  background: #151822;
}

.pill-btn.lavender {
  background: rgba(199, 181, 255, 0.14);
  color: var(--lavender);
  border-color: rgba(199, 181, 255, 0.28);
}

/* ==========================================================================
   FLOATING TUNING POPOVER (Keeps Sliders Accessible Without Visual Clutter)
   ========================================================================== */
.tune-popover {
  position: fixed;
  top: 72px;
  right: 24px;
  width: 330px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  background: #161926;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 18px;
  z-index: 60;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hidden {
  display: none !important;
}

.tune-section {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.tune-section:first-child {
  padding-top: 0;
  border-top: none;
}

.tune-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-soft);
}

.tune-label-row strong {
  color: var(--text);
  font-weight: 600;
}

input[type="range"].sleek-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  background: #25293a;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

input[type="range"].sleek-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--ink);
  cursor: pointer;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  padding-top: 6px;
}

.fallback-banner {
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.32);
  color: #fde68a;
  border-radius: 16px;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tab-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.roi-subpanel {
  display: inline-flex;
  gap: 6px;
}

.image-bar {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.class-collapse summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-soft);
  user-select: none;
}

.class-collapse summary::-webkit-details-marker {
  display: none;
}

.cls-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: #10121b;
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}

.cls-chip.on {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
  background: #202436;
}

.cls-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
}

.switch-row input {
  accent-color: var(--mint);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ==========================================================================
   BENTO DASHBOARD GRID
   ========================================================================== */
.bento-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.95fr) minmax(320px, 1fr);
  gap: 16px;
  flex: 1;
  min-height: 0;
}

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

.bento-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

/* Stage Card */
.stage-card {
  padding: 14px;
  gap: 12px;
  justify-content: space-between;
}

.stage-viewport {
  position: relative;
  flex: 1;
  min-height: 410px;
  max-height: calc(100vh - 235px);
  background: #0b0d14;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage-viewport.drop-active {
  outline: 2px dashed var(--mint);
  outline-offset: -6px;
}

.viewport-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
}

#roi-editor-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
}

#roi-editor-canvas.editing-active {
  pointer-events: auto;
  cursor: crosshair;
}

.stage-top-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 20;
}

.stage-top-overlay > * {
  pointer-events: auto;
}

.glass-pill {
  background: rgba(14, 16, 24, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.stage-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 4px 0;
}

.video-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

/* Right Bento Column */
.right-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Hero Mint-Lime Card (Exact Ethereal Reference Match) */
.hero-mint-card {
  background: var(--mint-grad);
  color: var(--ink);
  border-radius: var(--radius-xl);
  padding: 22px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
}

.hero-mint-card::after {
  content: "";
  position: absolute;
  right: -36px;
  top: 12px;
  width: 140px;
  height: 140px;
  border-radius: 28px;
  background: rgba(9, 11, 16, 0.07);
  transform: rotate(28deg);
  pointer-events: none;
}

.hero-label {
  font-size: 14px;
  font-weight: 600;
  opacity: 0.78;
}

.hero-value {
  font-size: 44px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  margin-top: 6px;
}

.hero-sub {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.72;
  margin-top: 6px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 2;
}

/* Twin Metric Cards (In Zone & Confidence) */
.metric-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.mini-bento {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.mini-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
}

.mini-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.05;
}

.mini-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.mini-caption {
  font-size: 11px;
  color: var(--text-dim);
}

.badge-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--lime-pill);
  color: var(--ink);
}

.badge-pill.neg {
  background: var(--coral-pill);
  color: #1f0606;
}

.badge-pill.neutral {
  background: var(--pill-bg);
  color: var(--text-soft);
}

/* Class Split Donut Card (Exact Expense Split Match) */
.split-card {
  flex: 1;
  justify-content: space-between;
  gap: 12px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tag-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  background: var(--pill-bg);
  color: var(--text-soft);
}

.donut-layout {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  margin: auto 0;
}

.donut-box {
  position: relative;
  width: 128px;
  height: 128px;
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.donut-center span {
  font-size: 11px;
  color: var(--text-dim);
}

.donut-center strong {
  font-size: 19px;
  font-weight: 700;
}

.split-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}

.legend-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legend-name {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-val {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

/* ==========================================================================
   COMPARE & REPORTS TABS
   ========================================================================== */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.ba-stage {
  position: relative;
  height: 360px;
  background: #0b0d14;
  border-radius: 20px;
  overflow: hidden;
  user-select: none;
}

.ba-swipe-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.ba-before-clip {
  clip-path: inset(0 calc(100% - var(--swipe-pct, 50%)) 0 0);
}

.ba-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--swipe-pct, 50%);
  width: 2px;
  background: #ffffff;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 12;
}

.ba-knob {
  position: absolute;
  top: 50%;
  left: var(--swipe-pct, 50%);
  transform: translate(-50%, -50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #ffffff;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  cursor: ew-resize;
  z-index: 13;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.ba-split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  height: 100%;
  padding: 8px;
}

.ba-split-pane {
  position: relative;
  background: #08090e;
  border-radius: 14px;
  overflow: hidden;
}

.ba-split-pane img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Ethereal Row List (Like Subscriptions / Recent Transactions) */
.row-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
}

.row-item {
  background: var(--card-alt);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.row-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #222638;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.row-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  font-size: 11px;
  color: var(--text-dim);
}

/* Batch Strip */
.batch-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-top: 4px;
}

.batch-thumb {
  background: var(--card-alt);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px 10px 6px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text);
  font-family: inherit;
}

.batch-thumb:hover {
  border-color: var(--mint);
}

.batch-thumb img {
  width: 44px;
  height: 34px;
  object-fit: cover;
  border-radius: 9px;
}

/* Loader & Toast */
.loader-mask {
  position: absolute;
  inset: 0;
  background: rgba(8, 9, 14, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 25;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--mint);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

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

.toast-stack {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #191d2b;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}
