/*
 * GhostCart component styles (Phantom) — the shell (layout.js), the design
 * system (ui.js), brand/HUD bits (phantom.js, ghost.js), charts (charts.js) and
 * retailer badges (retailer.js). Only tokens.css variables are referenced, so
 * both themes come for free. Live showcase: /styleguide.
 */

/* Instant theme swap (store.js toggles this for two frames). */
.theme-switching *, .theme-switching *::before, .theme-switching *::after { transition: none !important; }

/* ============================================================
   App shell: 76px rail + main column
   ============================================================ */
.app { position: relative; min-height: 100vh; min-height: 100dvh; }
.app-rail { position: fixed; inset: 0 auto 0 0; z-index: var(--z-sidebar); width: var(--rail-w); }
.app-main {
  min-width: 0; margin-left: var(--rail-w);
  display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh;
}
.app-content {
  flex: 1; width: 100%; max-width: var(--content-max); margin: 0 auto;
  padding: 4px 32px 56px;
}
.app-content:focus { outline: none; }
.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: var(--z-toast);
  background: var(--surface-2); padding: 8px 12px; border-radius: var(--r-md); border: 1px solid var(--border-strong);
}
.skip-link:focus { top: 12px; }
@media (max-width: 759px) {
  .app-rail { display: none; }
  .app-main { margin-left: 0; }
  .app-content { padding: 4px 14px calc(var(--bottomnav-h) + 28px + env(safe-area-inset-bottom)); }
}

/* Page transitions: pages apparate in. */
.page { min-width: 0; }
.page-enter { animation: apparition 600ms var(--ease-out) backwards; }
.page.is-leaving { opacity: 0.55; transition: opacity var(--dur-2) ease-out; pointer-events: none; }
.page-skeleton { animation: fade-in var(--dur-3) ease-out both; }
.page-skeleton .card { padding: var(--s-5); }

/* ============================================================
   Ghost mascot (components/ghost.js)
   ============================================================ */
.ghost { display: block; overflow: visible; color: var(--ecto-text); }
.ghost-body { animation: ghost-float 4.2s ease-in-out infinite; transform-origin: 50% 60%; transform-box: fill-box; }
.ghost-eye { animation: ghost-blink 5.5s infinite; transform-origin: center; transform-box: fill-box; }
.ghost-shadow { animation: ghost-shadow 4.2s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
.ghost.is-still .ghost-body, .ghost.is-still .ghost-eye, .ghost.is-still .ghost-shadow { animation: none; }
.ghost-mark { position: relative; display: inline-grid; place-items: center; isolation: isolate; }
.ghost-mark::after {
  content: ""; position: absolute; inset: 4px; border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, color-mix(in srgb, var(--ecto) 38%, transparent), transparent 70%); filter: blur(8px);
}

/* ============================================================
   Rail
   ============================================================ */
.rail {
  position: relative; height: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 0 16px;
  background: linear-gradient(180deg, var(--surface-0), color-mix(in srgb, var(--surface-0) 80%, transparent));
  border-right: 1px solid var(--border);
}
.rail-brand { display: grid; place-items: center; width: 48px; height: 52px; margin-bottom: 14px; border-radius: var(--r-lg); }
.rail-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; align-items: center; }
.rail-bottom { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.rail-item {
  position: relative; width: 48px; height: 48px; border-radius: var(--r-lg);
  display: grid; place-items: center; color: var(--text-3);
  transition: color var(--dur-2), background var(--dur-2), transform 0.35s var(--spring);
}
.rail-item:hover, .rail-group.is-open > .rail-item { color: var(--text); background: var(--surface-2); transform: translateY(-1px); }
.rail-item:active { transform: scale(0.92); }
.rail-item.is-active { color: var(--ecto-text); background: var(--ecto-soft); }
.rail-item.is-active::before {
  content: ""; position: absolute; left: -14px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--ecto-grad); box-shadow: 0 0 12px var(--ecto), 0 0 2px var(--ecto);
  animation: pop-in 0.45s var(--spring) both;
}
.rail-item.is-active .icon { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--ecto) 55%, transparent)); }
.rail-tip {
  position: absolute; left: 58px; top: 50%; padding: 5px 9px; border-radius: 8px; white-space: nowrap;
  background: var(--surface-3); color: var(--text); font-size: 12px; font-weight: 600; line-height: 1.3;
  opacity: 0; transform: translate(-6px, -50%); pointer-events: none; transition: opacity 0.2s, transform 0.25s var(--spring);
  box-shadow: var(--shadow-md); z-index: 5;
}
.rail-item:hover .rail-tip, .rail-item:focus-visible .rail-tip { opacity: 1; transform: translate(0, -50%); }
.rail-group { position: relative; }
.rail-flyout {
  position: absolute; left: 60px; top: -6px; z-index: var(--z-dropdown); min-width: 210px;
  padding: 8px; border-radius: var(--r-lg);
  background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  animation: flyout-in 0.32s var(--spring) both;
}
.rail-flyout::before { /* hover bridge so the pointer can travel from icon to panel */
  content: ""; position: absolute; left: -14px; top: 0; bottom: 0; width: 14px;
}
[data-theme="light"] .rail-flyout { background: var(--surface-1); }
@keyframes flyout-in { from { opacity: 0; transform: translateX(-8px) scale(0.98); } }
.rail-flyout-title { padding: 6px 10px 8px; font-size: 10px; }
.rail-flyout-item {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--r-sm);
  color: var(--text-2); font-weight: 550; white-space: nowrap;
  transition: background var(--dur-1), color var(--dur-1), transform 0.3s var(--spring);
}
.rail-flyout-item .icon { color: var(--text-3); }
.rail-flyout-item:hover, .rail-flyout-item:focus-visible { background: var(--surface-3); color: var(--text); transform: translateX(2px); }
.rail-flyout-item.is-active { color: var(--ecto-text); background: var(--ecto-soft); }
.rail-flyout-item.is-active .icon { color: var(--ecto-text); }
.rail-avatar {
  width: 36px; height: 36px; margin-top: 4px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--surface-3), var(--surface-2)); border: 1px solid var(--border-strong);
  font: 700 13px var(--font-display); color: var(--text-2);
  transition: transform 0.35s var(--spring), border-color var(--dur-2);
}
.rail-avatar:hover { border-color: color-mix(in srgb, var(--ecto) 45%, var(--border-strong)); transform: translateY(-1px); }
@media (max-height: 640px) {
  .rail-item { height: 40px; }
  .rail-brand { margin-bottom: 4px; }
}

/* ============================================================
   Sidebar (phone "More" drawer)
   ============================================================ */
.sidebar { height: 100%; display: flex; flex-direction: column; padding: var(--s-3) var(--s-2); }
.sidebar-head { display: flex; align-items: center; height: 48px; padding: 0 var(--s-2); margin-bottom: var(--s-2); }
.brand { display: inline-flex; align-items: center; gap: 10px; border-radius: var(--r-md); min-width: 0; }
.brand-text { font: 600 18px var(--font-display); letter-spacing: -0.01em; white-space: nowrap; }
.brand-text-2 { color: var(--ecto-text); }
.sidebar-search {
  display: flex; align-items: center; gap: 8px; width: 100%;
  height: 40px; padding: 0 10px; margin-bottom: var(--s-3);
  border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--surface-glass); color: var(--text-3); font-size: var(--fs-sm);
}
.sidebar-search span:first-of-type { flex: 1; text-align: left; }
.sidebar-scroll { position: relative; flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: var(--s-3); }
.nav-section { margin-top: var(--s-4); }
.nav-section-label { font: 600 10px/1 var(--font-mono); letter-spacing: var(--eyebrow-track); text-transform: uppercase; color: var(--text-3); padding: 0 10px; margin-bottom: 8px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px; width: 100%;
  height: 42px; padding: 0 10px; margin: 1px 0; border-radius: var(--r-md);
  color: var(--text-2); font-size: var(--fs-md); font-weight: 550; white-space: nowrap;
  transition: color var(--dur-1), background var(--dur-1);
}
.nav-item .icon { color: var(--text-3); }
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.is-active { color: var(--ecto-text); background: var(--ecto-soft); }
.nav-item.is-active .icon { color: var(--ecto-text); }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: var(--s-2); margin-top: var(--s-2); padding-bottom: env(safe-area-inset-bottom); }

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 32px;
  /* Frosted ink: scrolled content blurs out under the title instead of reading
     through it; the mask feathers the bottom edge so there is no hard band. */
  background: linear-gradient(color-mix(in srgb, var(--bg) 86%, transparent) 60%, color-mix(in srgb, var(--bg) 40%, transparent));
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  -webkit-mask-image: linear-gradient(#000 78%, transparent); mask-image: linear-gradient(#000 78%, transparent);
}
/* Title and actions share the free space equally (basis 0) so the search
   stays put from page to page instead of sliding with the title width. */
.title-block { display: flex; flex-direction: column; gap: 4px; min-width: 210px; flex: 1 1 0; }
.topbar-eyebrow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-eyebrow .row { display: inline-flex; }
.topbar-title { margin: 0; font: 600 var(--fs-display)/1.1 var(--font-display); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-mark { display: inline-flex; flex: none; }
.cmd {
  flex: 0 1 520px; min-width: 0; height: 40px; display: flex; align-items: center; gap: 10px;
  padding: 0 8px 0 14px; border-radius: 12px; background: var(--surface-glass); border: 1px solid var(--border);
  color: var(--text-3); font-size: 13.5px; text-align: left;
  transition: border-color var(--dur-2), box-shadow 0.3s, color var(--dur-2);
}
.cmd-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmd:hover { border-color: color-mix(in srgb, var(--ecto) 35%, var(--border)); color: var(--text-2); box-shadow: 0 0 0 4px var(--ecto-softer); }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-left: auto; flex: 1 0 0; }
.cmd + .top-actions { margin-left: 0; }
.topbar-scrape.is-scanning .icon { animation: spin 1s linear infinite; color: var(--ecto-text); }
.topbar-add { margin-left: 4px; }

/* "N monitors haunting" chip */
.live-chip {
  display: inline-flex; align-items: center; gap: 9px; height: 34px; padding: 0 12px 0 11px;
  border-radius: var(--r-full); border: 1px solid var(--border); background: var(--surface-glass);
  font: 600 12px var(--font); color: var(--text-2); white-space: nowrap;
  transition: border-color var(--dur-2), transform 0.35s var(--spring);
}
.live-chip:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.live-chip-pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--tone-alive); position: relative; flex: none; box-shadow: 0 0 8px var(--tone-alive); }
.live-chip-pulse::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--tone-alive);
  animation: ping 2s var(--ease-out) infinite;
}
.live-chip.is-off .live-chip-pulse { background: var(--tone-refunded); box-shadow: none; }
.live-chip.is-off .live-chip-pulse::after { display: none; }
.live-chip.is-scanning .live-chip-pulse { background: var(--ecto); box-shadow: 0 0 10px var(--ecto); }
.live-chip.is-stale .live-chip-pulse { background: var(--tone-alerts); box-shadow: 0 0 8px var(--tone-alerts); }
.live-chip.is-stale .live-chip-pulse::after { display: none; }
.live-chip.is-error .live-chip-pulse { background: var(--tone-cancelled); box-shadow: 0 0 8px var(--tone-cancelled); }
.live-chip.is-error .live-chip-pulse::after { display: none; }
.live-chip-n { font: 600 13px var(--font-display); color: var(--text); }

@media (max-width: 1180px) { .cmd-text { display: none; } .cmd { flex: 0 0 auto; width: 40px; padding: 0; justify-content: center; } .cmd .kbd-group { display: none; } }
@media (max-width: 959px) { .live-chip-label { display: none; } .live-chip { padding: 0 10px; } }
@media (max-width: 759px) {
  .topbar {
    height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0 14px; gap: 10px;
  }
  .title-block { min-width: 0; max-width: none; flex: 1; gap: 3px; }
  .topbar-title { font-size: 22px; }
  .topbar-eyebrow { letter-spacing: 0.08em; font-size: 10px; }
  .top-actions { gap: 2px; flex: none; }
  .live-chip { height: 32px; padding: 0 10px 0 9px; gap: 7px; }
}

/* ============================================================
   Scan banner
   ============================================================ */
.scan-banner {
  position: sticky; top: var(--topbar-h); z-index: var(--z-banner);
  margin: 0 32px 10px; border-radius: var(--r-lg); overflow: hidden;
  background: color-mix(in srgb, var(--surface-2) 90%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-md);
  animation: apparition 0.5s var(--ease-out) backwards;
}
.scan-banner.is-closing { animation: fade-out var(--dur-2) ease-in both; }
.scan-banner-inner { display: flex; align-items: center; gap: var(--s-3); padding: 8px var(--s-4); min-height: 46px; }
.scan-banner-icon { display: inline-flex; color: var(--ecto-text); }
.scan-banner.is-done .scan-banner-icon { color: var(--success); }
.scan-banner.is-error .scan-banner-icon { color: var(--danger); }
.scan-banner-text { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1; }
.scan-banner-title { font-weight: 600; white-space: nowrap; }
.scan-banner-msg { color: var(--text-3); font-size: var(--fs-sm); }
.scan-banner-pct { font: 600 13px var(--font-mono); color: var(--ecto-text); }
.scan-banner-bar .progress-track { border-radius: 0; background: transparent; }
@media (max-width: 759px) {
  .scan-banner { top: calc(var(--topbar-h) + env(safe-area-inset-top)); margin: 0 12px 10px; }
  .scan-banner-text { flex-direction: column; gap: 0; align-items: flex-start; }
}

/* ============================================================
   Page header (title + eyebrow live in the topbar)
   ============================================================ */
.page-header { margin: 2px 0 18px; }
.page-header.is-empty { display: none; }
.page-header-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; min-height: 36px; }
.page-header-text { min-width: 0; }
.page-title { font: 600 var(--fs-display)/1.1 var(--font-display); letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.page-title-icon { display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center; border-radius: var(--r-md); background: var(--ecto-soft); color: var(--ecto-text); }
.page-subtitle { color: var(--text-2); font-size: var(--fs-md); }
.page-header-actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.page-header-extra { margin-top: var(--s-3); }
.page-header-row + .page-header-extra { margin-top: var(--s-4); }
@media (max-width: 640px) {
  .page-header { margin-bottom: var(--s-3); }
  .page-subtitle { font-size: var(--fs-sm); }
  .page-header-actions { width: 100%; }
}

/* Section label: "— OVERVIEW" */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 6px 0 14px; flex-wrap: wrap; }
.section-head-title {
  margin: 0; font: 600 13px var(--font-mono); letter-spacing: var(--eyebrow-track); text-transform: uppercase; color: var(--text-2);
  display: flex; gap: 10px; align-items: center;
}
.section-head-title::before { content: ""; width: 18px; height: 2px; border-radius: 2px; background: var(--ecto-grad); box-shadow: 0 0 8px color-mix(in srgb, var(--ecto) 60%, transparent); }
.section-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 759px) { .section-head { flex-direction: column; align-items: stretch; gap: 10px; } }

/* ============================================================
   Buttons — springy press, light sweep on primary
   ============================================================ */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 11px;
  font-size: 13px; font-weight: 600; white-space: nowrap; line-height: 1;
  border: 1px solid transparent; user-select: none;
  transition: transform 0.4s var(--spring), background var(--dur-2), border-color var(--dur-2), color var(--dur-2),
    box-shadow 0.3s, opacity var(--dur-1), filter var(--dur-2);
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: scale(0.94); transition-duration: 0.1s; }
.btn:disabled { opacity: 0.5; }
.btn.is-loading { opacity: 0.85; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; gap: 6px; border-radius: 9px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: var(--fs-lg); border-radius: 13px; }
.btn-block { width: 100%; }
.btn-icon-only.btn-md { width: 36px; padding: 0; }
.btn-icon-only.btn-sm { width: 30px; padding: 0; }

.btn-primary {
  color: var(--ecto-ink); background: var(--ecto-grad); border: 0; box-shadow: var(--ecto-glow);
  overflow: hidden; isolation: isolate;
}
.btn-primary::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform 0.8s var(--ease-out);
}
.btn-primary:hover:not(:disabled)::after { transform: translateX(120%); }
.btn-primary:hover:not(:disabled) { filter: saturate(1.15) brightness(1.04); }
.btn-primary .spinner { color: var(--ecto-ink); }
.btn-secondary { background: var(--surface-glass); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled), .btn-secondary.is-active { background: var(--surface-2); border-color: color-mix(in srgb, var(--ecto) 30%, var(--border-strong)); }
.btn-secondary.is-active { color: var(--ecto-text); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled), .btn-ghost.is-active { background: var(--surface-2); color: var(--text); }
.btn-subtle { background: var(--ecto-soft); color: var(--ecto-text); border-color: color-mix(in srgb, var(--ecto) 30%, transparent); }
.btn-subtle:hover:not(:disabled) { background: color-mix(in srgb, var(--ecto) 20%, transparent); }
.btn-danger { background: #d63b5c; color: #fff; box-shadow: 0 0 0 1px rgba(255, 115, 147, 0.35), 0 6px 22px -8px rgba(255, 115, 147, 0.6); }
[data-theme="light"] .btn-danger { background: var(--tone-cancelled); }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }

.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 11px; color: var(--text-2);
  transition: background var(--dur-2), color var(--dur-2), transform 0.4s var(--spring);
}
.icon-btn-sm { width: 30px; height: 30px; border-radius: 9px; }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn.is-active { background: var(--ecto-soft); color: var(--ecto-text); }
.icon-btn:active:not(:disabled) { transform: scale(0.9); transition-duration: 0.1s; }
.icon-btn:disabled { opacity: 0.4; }
.icon-btn-secondary { border: 1px solid var(--border-strong); background: var(--surface-glass); }
.icon-btn-badge {
  position: absolute; top: 3px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--r-full); background: var(--tone-alerts); color: #1a0b00;
  font: 700 10px/16px var(--font); text-align: center;
  box-shadow: 0 0 0 2px var(--bg); animation: pop-in 0.4s var(--spring) both;
}
[data-theme="light"] .icon-btn-badge { color: #fff; }
.copy-btn.is-done { color: var(--success); }

/* Spinner / Kbd */
.spinner { animation: spin 0.75s linear infinite; }
.kbd-group { display: inline-flex; gap: 3px; }
.kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 22px; padding: 0 6px;
  border-radius: 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px;
  background: var(--surface-2); color: var(--text-3);
  font: 600 11px/1 var(--font-mono);
}

/* ============================================================
   Card + HUD corner ticks
   ============================================================ */
.card {
  position: relative; min-width: 0;
  background: var(--surface-glass);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
}
/* .hud on any positioned surface draws the 4 instrument corner ticks. */
.hud::after {
  content: ""; position: absolute; inset: 7px; pointer-events: none; border-radius: 12px; z-index: 1;
  background:
    linear-gradient(var(--tick), var(--tick)) left top / 9px 1px no-repeat,
    linear-gradient(var(--tick), var(--tick)) left top / 1px 9px no-repeat,
    linear-gradient(var(--tick), var(--tick)) right top / 9px 1px no-repeat,
    linear-gradient(var(--tick), var(--tick)) right top / 1px 9px no-repeat,
    linear-gradient(var(--tick), var(--tick)) left bottom / 9px 1px no-repeat,
    linear-gradient(var(--tick), var(--tick)) left bottom / 1px 9px no-repeat,
    linear-gradient(var(--tick), var(--tick)) right bottom / 9px 1px no-repeat,
    linear-gradient(var(--tick), var(--tick)) right bottom / 1px 9px no-repeat;
  opacity: 0.55;
}
.card-interactive { transition: border-color var(--dur-2), transform 0.45s var(--spring), box-shadow var(--dur-2); cursor: pointer; }
.card-interactive:hover { border-color: color-mix(in srgb, var(--ecto) 30%, var(--border-strong)); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); padding: 20px 22px 0; }
.card-head-text { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.card-eyebrow { font-size: 10px; }
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; display: flex; align-items: center; gap: 8px; color: var(--text); }
.card-title .icon { color: var(--ecto-text); }
.card-subtitle { color: var(--text-3); font-size: var(--fs-sm); }
.card-actions { display: flex; align-items: center; gap: var(--s-1); flex-shrink: 0; }
.card-body.is-padded { padding: 20px 22px; }
.card-head + .card-body.is-padded { padding-top: var(--s-4); }
.card-head + .card-body.is-flush { margin-top: var(--s-4); }
.card-foot { padding: var(--s-3) 22px; border-top: 1px solid var(--border); }
.link { color: var(--ecto-text); font-size: 12.5px; font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 640px) {
  .card { border-radius: 16px; }
  .card-head { padding: var(--s-4) var(--s-4) 0; }
  .card-body.is-padded { padding: var(--s-4); }
}

/* ============================================================
   Stat (KPI card): mono label, Bahnschrift value, sparkline bleed
   ============================================================ */
.stat {
  position: relative; display: flex; flex-direction: column; gap: 0; text-align: left; min-width: 0;
  padding: 18px 20px 18px; overflow: hidden; min-height: 150px;
  background: var(--surface-glass); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
}
.stat.has-spark { padding-bottom: 0; }
.stat-clickable { cursor: pointer; transition: border-color var(--dur-2), transform 0.45s var(--spring); }
.stat-clickable:hover { border-color: color-mix(in srgb, var(--ecto) 30%, var(--border-strong)); transform: translateY(-2px); }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); min-height: 26px; }
.stat-label {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  font: 600 10.5px/1.2 var(--font-mono); letter-spacing: var(--eyebrow-track); text-transform: uppercase; color: var(--text-3);
}
.stat-label-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex: none;
  border-radius: 8px; border: 1px solid var(--border);
}
.stat-value {
  margin-top: 14px; font: 600 var(--fs-kpi)/1 var(--font-display); letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; min-height: 40px; color: var(--text);
}
/* "No data" (A4): the big-number slot stays, the value reads as unknown, not a fact. */
.stat.is-unknown .stat-value { color: var(--text-3); }
.stat-cur { font-size: 0.55em; font-weight: 600; opacity: 0.62; margin-right: 0.06em; vertical-align: 0.62em; letter-spacing: 0; }
.stat-foot { display: flex; align-items: center; gap: 8px; min-height: 18px; margin-top: 8px; font-size: 12.5px; flex-wrap: wrap; }
.stat-sub { color: var(--text-2); }
.stat-trend { display: inline-flex; align-items: center; gap: 3px; height: 20px; padding: 0 7px; border-radius: 6px; font: 600 11px var(--font-mono); flex: none; }
.stat-trend.is-good { color: var(--tone-alive); background: var(--tone-alive-bg); }
.stat-trend.is-bad { color: var(--tone-cancelled); background: var(--tone-cancelled-bg); }
.stat-trend.is-flat { color: var(--text-3); background: var(--surface-2); }
.stat-spark { margin: auto -20px 0; padding-top: 10px; }
.stat-spark .sparkline-end { display: none; }
.stat.has-side { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto auto 1fr; column-gap: 14px; }
.stat.has-side > :not(.stat-side) { grid-column: 1; }
.stat-side { grid-column: 2; grid-row: 1 / -1; align-self: center; }
@media (max-width: 759px) {
  .stat { min-height: 130px; padding: 14px 14px 14px; }
  .stat.has-spark { padding-bottom: 0; }
  .stat-label { font-size: 9.5px; letter-spacing: 0.1em; gap: 6px; }
  .stat-icon { display: none; }
  .stat-value { font-size: 30px; margin-top: 10px; min-height: 30px; }
  .stat-foot { font-size: 11.5px; gap: 4px 6px; }
  .stat-spark { margin: auto -14px 0; }
  .stat-side { display: none; }
}

/* KPI strip — status counters with a glowing tone bar */
.kpi-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 0;
  background: var(--surface-glass); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.kpi {
  position: relative; display: flex; flex-direction: column; gap: 6px; text-align: left;
  padding: 14px 18px 17px; min-width: 0;
  border-right: 1px solid var(--border);
  transition: background var(--dur-2), opacity var(--dur-2);
  --kpi-c: var(--tone-neutral);
}
.kpi:last-child { border-right: 0; }
.kpi-label {
  display: flex; align-items: center; gap: 7px;
  font: 700 10.5px/1.2 var(--font-mono); letter-spacing: var(--eyebrow-track); text-transform: uppercase; color: var(--kpi-c);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--kpi-c); box-shadow: 0 0 8px var(--kpi-c); flex: none; }
.kpi-value { font: 600 28px/1 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--text); }
.kpi-sub { font: 500 11px var(--font-mono); color: var(--text-3); }
.kpi-line { position: absolute; left: 18px; right: 18px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--surface-3); overflow: hidden; }
.kpi-line-fill { display: block; height: 100%; background: var(--kpi-c); box-shadow: 0 0 10px var(--kpi-c); transition: width var(--dur-slow) var(--ease-out); }
.kpi-clickable { cursor: pointer; }
.kpi-clickable:hover { background: var(--ecto-softer); }
.kpi.is-active { background: color-mix(in srgb, var(--kpi-c) 9%, transparent); }
.kpi.is-dim { opacity: 0.55; }
.kpi.is-dim:hover { opacity: 1; }
.kpi-tone-alive { --kpi-c: var(--tone-alive); }
.kpi-tone-preorder { --kpi-c: var(--tone-preorder); }
.kpi-tone-confirmed { --kpi-c: var(--tone-confirmed); }
.kpi-tone-shipped { --kpi-c: var(--tone-shipped); }
.kpi-tone-arriving { --kpi-c: var(--tone-arriving); }
.kpi-tone-delivered { --kpi-c: var(--tone-delivered); }
.kpi-tone-cancelled { --kpi-c: var(--tone-cancelled); }
.kpi-tone-refunded { --kpi-c: var(--tone-refunded); }
.kpi-tone-alerts { --kpi-c: var(--tone-alerts); }
.kpi-tone-accent { --kpi-c: var(--ecto-text); }
.kpi-tone-neutral { --kpi-c: var(--tone-neutral); }
@media (max-width: 640px) {
  .kpi-strip { display: flex; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; }
  .kpi-strip::-webkit-scrollbar { display: none; }
  .kpi { flex: 0 0 auto; min-width: 104px; scroll-snap-align: start; padding: 12px 12px 14px; }
  .kpi-value { font-size: 22px; }
  .kpi-line { left: 10px; right: 10px; }
}

/* ============================================================
   Tones (soft bg + fg) — Badge, Stat icon, notif icon…
   ============================================================ */
.tone-bg-alive { color: var(--tone-alive); background: var(--tone-alive-bg); --tone-bd: var(--tone-alive-bd); }
.tone-bg-preorder { color: var(--tone-preorder); background: var(--tone-preorder-bg); --tone-bd: var(--tone-preorder-bd); }
.tone-bg-confirmed { color: var(--tone-confirmed); background: var(--tone-confirmed-bg); --tone-bd: var(--tone-confirmed-bd); }
.tone-bg-shipped { color: var(--tone-shipped); background: var(--tone-shipped-bg); --tone-bd: var(--tone-shipped-bd); }
.tone-bg-arriving { color: var(--tone-arriving); background: var(--tone-arriving-bg); --tone-bd: var(--tone-arriving-bd); }
.tone-bg-delivered { color: var(--tone-delivered); background: var(--tone-delivered-bg); --tone-bd: var(--tone-delivered-bd); }
.tone-bg-cancelled { color: var(--tone-cancelled); background: var(--tone-cancelled-bg); --tone-bd: var(--tone-cancelled-bd); }
.tone-bg-refunded { color: var(--tone-refunded); background: var(--tone-refunded-bg); --tone-bd: var(--tone-refunded-bd); }
.tone-bg-alerts { color: var(--tone-alerts); background: var(--tone-alerts-bg); --tone-bd: var(--tone-alerts-bd); }
.tone-bg-neutral { color: var(--tone-neutral); background: var(--tone-neutral-bg); --tone-bd: var(--tone-neutral-bd); }
.tone-bg-accent { color: var(--tone-accent); background: var(--tone-accent-bg); --tone-bd: var(--tone-accent-bd); }

/* Badge (generic soft label) */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: var(--r-full); font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1;
  box-shadow: inset 0 0 0 1px var(--tone-bd, transparent);
}
.badge-sm { height: 19px; padding: 0 7px; font-size: var(--fs-xs); gap: 5px; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent); }
.badge-sm .badge-dot { width: 5px; height: 5px; box-shadow: none; }

/* "Soul" status pill — shape + hue + mono label */
.soul {
  --c: var(--tone-neutral); --b: var(--tone-neutral-bg);
  display: inline-flex; align-items: center; gap: 7px; height: 24px; padding: 0 10px 0 8px; border-radius: var(--r-full);
  background: var(--b); color: var(--c); font: 700 10.5px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--c) 22%, transparent);
}
.soul::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent), 0 0 8px var(--c);
}
.soul-sm { height: 20px; padding: 0 8px 0 6px; gap: 6px; font-size: 9.5px; }
.soul-sm::before { width: 5px; height: 5px; }
.soul-alive { --c: var(--tone-alive); --b: var(--tone-alive-bg); }
.soul-alive::before { animation: soul 2.4s ease-in-out infinite; }
.soul-preorder { --c: var(--tone-preorder); --b: var(--tone-preorder-bg); }
.soul-confirmed { --c: var(--tone-confirmed); --b: var(--tone-confirmed-bg); }
.soul-shipped { --c: var(--tone-shipped); --b: var(--tone-shipped-bg); }
.soul-arriving { --c: var(--tone-arriving); --b: var(--tone-arriving-bg); }
.soul-delivered { --c: var(--tone-delivered); --b: var(--tone-delivered-bg); }
.soul-alerts { --c: var(--tone-alerts); --b: var(--tone-alerts-bg); }
.soul-alerts::before { border-radius: 1px; width: 0; height: 0; background: transparent; box-shadow: none; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 7px solid var(--c); }
.soul-accent { --c: var(--tone-accent); --b: var(--tone-accent-bg); }
.soul-cancelled { --c: var(--tone-cancelled); --b: var(--tone-cancelled-bg); }
.soul-cancelled::before { box-shadow: none; border-radius: 1px; transform: rotate(45deg); }
.soul-refunded { --c: var(--tone-refunded); --b: var(--tone-refunded-bg); }
.soul-refunded::before { box-shadow: none; background: transparent; border: 1.5px solid var(--c); width: 4px; height: 4px; }
.soul-neutral::before { box-shadow: none; }
[data-theme="light"] .soul::before { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 15%, transparent); }
[data-theme="light"] .soul-cancelled::before, [data-theme="light"] .soul-refunded::before, [data-theme="light"] .soul-alerts::before { box-shadow: none; }

/* Delta chip / tone tag */
.delta { display: inline-flex; align-items: center; gap: 3px; height: 20px; padding: 0 7px; border-radius: 6px; font: 600 11px var(--font-mono); white-space: nowrap; }
.delta.is-up { color: var(--tone-alive); background: var(--tone-alive-bg); }
.delta.is-down { color: var(--tone-cancelled); background: var(--tone-cancelled-bg); }
.delta.is-flat { color: var(--text-3); background: var(--surface-2); }
.tone-tag { display: inline-flex; align-items: center; font: 700 10px var(--font-mono); letter-spacing: 0.1em; padding: 3px 7px; border-radius: 6px; text-transform: uppercase; }

/* Copyable mono ID chip */
.id-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0;
  font: 500 12px var(--font-mono); letter-spacing: -0.01em; color: var(--text-2);
  border-radius: 6px; padding: 3px 6px; margin: -3px -6px;
  transition: background var(--dur-1), color var(--dur-1), filter var(--dur-3);
}
.id-chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.id-chip-icon { opacity: 0; color: var(--text-3); transition: opacity var(--dur-1); }
.id-chip:hover { background: var(--surface-3); color: var(--text); }
.id-chip:hover .id-chip-icon, .id-chip:focus-visible .id-chip-icon, .id-chip.is-done .id-chip-icon { opacity: 1; }
.id-chip.is-done .id-chip-icon { color: var(--success); }
.id-chip.is-private .id-chip-text { filter: blur(5px); transition: filter var(--dur-3) 0.4s; }
/* Strict privacy (Settings → Privacy): no hover reveal at all. */
:root:not(.privacy-strict) .id-chip.is-private:hover .id-chip-text { filter: none; }

/* Countdown */
.countdown { font: 600 22px/1 var(--font-mono); color: var(--ecto-text); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; text-shadow: 0 0 18px color-mix(in srgb, var(--ecto) 45%, transparent); white-space: nowrap; }

/* Pill (filter toggle) */
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px;
  border-radius: var(--r-full); border: 1px solid var(--border);
  background: transparent; color: var(--text-2); font-size: 12.5px; font-weight: 600; white-space: nowrap;
  transition: transform 0.4s var(--spring), background var(--dur-2), border-color var(--dur-2), color var(--dur-2);
}
.pill:hover { background: var(--surface-2); color: var(--text); }
.pill:active { transform: scale(0.92); transition-duration: 0.1s; }
.pill.is-active { background: var(--ecto-soft); border-color: color-mix(in srgb, var(--ecto) 45%, transparent); color: var(--ecto-text); }
.pill-count { font: 600 11px var(--font-mono); color: var(--text-3); }
.pill.is-active .pill-count { color: var(--ecto-text); }
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--pill-c, var(--text-3)); box-shadow: 0 0 6px color-mix(in srgb, var(--pill-c, transparent) 70%, transparent); }
.pill-tone-alive { --pill-c: var(--tone-alive); }
.pill-tone-preorder { --pill-c: var(--tone-preorder); }
.pill-tone-confirmed { --pill-c: var(--tone-confirmed); }
.pill-tone-shipped { --pill-c: var(--tone-shipped); }
.pill-tone-arriving { --pill-c: var(--tone-arriving); }
.pill-tone-delivered { --pill-c: var(--tone-delivered); }
.pill-tone-cancelled { --pill-c: var(--tone-cancelled); }
.pill-tone-refunded { --pill-c: var(--tone-refunded); }
.pill-tone-alerts { --pill-c: var(--tone-alerts); }
.pill-tone-accent { --pill-c: var(--ecto); }
.pill-tone-neutral { --pill-c: var(--tone-neutral); }

/* Filter chip */
.filter-chip {
  display: inline-flex; align-items: center; height: 28px; border-radius: 9px;
  border: 1px dashed var(--border-strong); background: transparent; color: var(--text-2); font-size: var(--fs-sm);
  animation: pop-in 0.35s var(--spring) both;
}
.filter-chip.is-active { border-style: solid; border-color: color-mix(in srgb, var(--ecto) 35%, var(--border-strong)); background: var(--ecto-softer); }
.filter-chip-main { display: inline-flex; align-items: center; gap: 5px; height: 100%; padding: 0 6px 0 10px; border-radius: 9px; }
.filter-chip-main:disabled { cursor: default; }
.filter-chip-label { color: var(--text-3); }
.filter-chip-value { color: var(--text); font-weight: 600; }
.filter-chip-x { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-right: 3px; border-radius: 6px; color: var(--text-3); }
.filter-chip-x:hover { background: var(--surface-3); color: var(--text); }

/* Avatar */
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 30%; color: #fff; font-weight: 650; overflow: hidden; flex-shrink: 0; letter-spacing: 0.02em; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Privacy: blur, hover (held) reveals — except in strict mode (html.privacy-strict), where nothing un-blurs. */
.privacy-text { transition: filter var(--dur-3) ease-out; }
.privacy-text.is-private, .privacy-on .privacy-blur, .privacy-on .pv { filter: blur(5px); user-select: none; }
:root:not(.privacy-strict) .privacy-text.is-private:hover,
:root:not(.privacy-strict).privacy-on .privacy-blur:hover,
:root:not(.privacy-strict).privacy-on .pv:hover { filter: none; transition-delay: 0.45s; }

/* Skeleton — mint shimmer */
.skeleton {
  display: block; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 0%, color-mix(in srgb, var(--ecto) 10%, var(--surface-3)) 40%, var(--surface-2) 80%);
  background-size: 800px 100%;
  animation: shimmer 1.6s linear infinite;
}

/* Empty state — the ghost's brand moment */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: var(--s-9) var(--s-5); gap: 6px; }
.empty-compact { padding: var(--s-7) var(--s-4); }
.empty-ghost { position: relative; margin-bottom: var(--s-2); }
.empty-ghost::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 70px; height: 70px; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(circle, var(--ecto-soft), transparent 70%); z-index: -1; }
.empty-icon {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 54px; height: 54px; margin-bottom: var(--s-2); border-radius: 16px;
  color: var(--ecto-text); background: var(--ecto-softer); border: 1px solid var(--border);
}
.empty-icon::after { content: ""; position: absolute; inset: -9px; border-radius: 22px; border: 1px dashed var(--border); }
.empty-compact .empty-icon { width: 42px; height: 42px; border-radius: 12px; }
.empty-compact .empty-icon::after { display: none; }
.empty-title { font: 600 17px/1.25 var(--font-display); color: var(--text); }
.empty-body { color: var(--text-3); max-width: 420px; font-size: var(--fs-md); }
.empty-action { margin-top: var(--s-3); }

/* ============================================================
   Tooltip / Popover / Menu
   ============================================================ */
.tooltip-anchor { display: inline-flex; max-width: 100%; }
.tooltip {
  position: fixed; top: -9999px; left: -9999px; z-index: var(--z-tooltip);
  padding: 5px 9px; max-width: 280px;
  border-radius: 8px; background: var(--surface-3); color: var(--text);
  font-size: 12px; font-weight: 600; line-height: 1.35; pointer-events: none;
  box-shadow: var(--shadow-md), inset 0 0 0 1px var(--border-strong);
  opacity: 0;
}
[data-theme="light"] .tooltip { background: #0f1a2f; color: #e9f2ff; box-shadow: var(--shadow-md); }
.tooltip[data-placed] { animation: pop-in 0.25s var(--spring) forwards; }

.popover {
  position: fixed; top: -9999px; left: -9999px; z-index: var(--z-dropdown);
  min-width: 180px; max-width: calc(100vw - 16px);
  padding: 6px; border-radius: var(--r-lg);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  opacity: 0; transform-origin: top;
}
[data-theme="light"] .popover { background: var(--surface-1); }
.popover:focus { outline: none; }
.popover[data-placed] { animation: pop-in 0.3s var(--spring) forwards; }
.popover[data-up="1"] { transform-origin: bottom; }
.popover.is-closing { animation: fade-out var(--dur-1) ease-in forwards !important; }
.dropdown-anchor { display: inline-flex; }
.menu-inner { display: flex; flex-direction: column; outline: none; max-height: min(420px, 70vh); overflow-y: auto; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px;
  border-radius: 8px; color: var(--text-2); font-size: var(--fs-md); text-align: left; white-space: nowrap;
}
.menu-item .icon { color: var(--text-3); }
.menu-item.is-active { background: var(--surface-3); color: var(--text); }
.menu-item.is-active .icon { color: var(--ecto-text); }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger .icon { color: var(--danger); }
.menu-item.is-danger.is-active { background: var(--danger-bg); }
.menu-item:disabled { opacity: 0.45; }
.menu-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.menu-hint { color: var(--text-4); font: 500 11px var(--font-mono); }
.menu-check { width: 15px; display: inline-flex; color: var(--ecto-text); }
.menu-divider { height: 1px; background: var(--border); margin: 5px -6px; }
.menu-header { padding: 7px 10px 5px; font: 600 10px var(--font-mono); letter-spacing: var(--eyebrow-track); text-transform: uppercase; color: var(--text-3); }

/* ============================================================
   Modal / Drawer
   ============================================================ */
.modal-root, .drawer-root, .palette-root { position: fixed; inset: 0; z-index: var(--z-modal); }
.drawer-root { z-index: var(--z-drawer); }
.modal-backdrop, .drawer-backdrop, .palette-backdrop {
  position: absolute; inset: 0; background: var(--scrim);
  animation: fade-in 0.4s ease-out both;
}
.modal-backdrop, .palette-backdrop { backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.is-closing > .modal-backdrop, .is-closing > .drawer-backdrop, .is-closing > .palette-backdrop { animation: fade-out var(--dur-2) ease-in both; }
.modal-root { display: flex; align-items: center; justify-content: center; padding: var(--s-5); overflow-y: auto; }
.modal {
  position: relative; width: 100%; max-height: calc(100dvh - 40px);
  display: flex; flex-direction: column;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--r-2xl);
  box-shadow: var(--shadow-xl);
  animation: modal-in 0.55s var(--spring) both;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(0.96); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
.modal::before { /* spectral top edge */
  content: ""; position: absolute; left: 40px; right: 40px; top: -1px; height: 2px; border-radius: 2px; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--ecto-1), var(--ecto-2), transparent); opacity: 0.7;
}
.modal:focus { outline: none; }
.modal-root.is-closing .modal { animation: fade-out var(--dur-2) ease-in both; }
.modal-sm { max-width: 420px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 1040px; }
.modal-head { display: flex; align-items: flex-start; gap: var(--s-3); padding: 22px 22px 0; }
.modal-head-text { flex: 1; min-width: 0; padding-top: 2px; }
.modal-icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0; box-shadow: inset 0 0 0 1px var(--tone-bd, transparent); }
.modal-title { font: 600 19px/1.2 var(--font-display); }
.modal-subtitle { color: var(--text-3); margin-top: 3px; }
.modal-close { margin: -4px -6px 0 0; }
.modal-body { padding: var(--s-4) 22px 22px; overflow-y: auto; min-height: 0; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: var(--s-2); padding: 14px 22px; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface-0) 50%, transparent); border-radius: 0 0 var(--r-2xl) var(--r-2xl); }
.confirm-body { color: var(--text-2); }
@media (max-width: 640px) {
  .modal-root { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 26px 26px 0 0; animation: slide-in-bottom 0.6s var(--spring) both; padding-bottom: env(safe-area-inset-bottom); }
  .modal-foot { border-radius: 0; }
  .modal-foot .btn { flex: 1; }
}

/* Drawer: floating panel, spectral gradient edge, ghost peeking from behind */
.drawer {
  position: absolute; z-index: 1; top: 12px; bottom: 12px; right: 12px;
  width: min(var(--drawer-w, 500px), calc(100vw - 24px));
  display: flex; flex-direction: column;
  background: var(--surface-1); border-radius: var(--r-2xl);
  box-shadow: var(--shadow-drawer);
  animation: slide-in-right 0.75s var(--spring) both;
  transition: transform var(--dur-3) var(--ease-out);
}
.drawer::before { /* spectral edge */
  content: ""; position: absolute; left: -1px; top: 40px; bottom: 40px; width: 2px; border-radius: 2px; pointer-events: none;
  background: linear-gradient(transparent, var(--ecto-1), var(--ecto-2), transparent); opacity: 0.7; filter: blur(0.5px);
}
.drawer:focus { outline: none; }
.drawer-peek {
  position: absolute; top: 132px; left: -34px; width: 46px; z-index: -1; pointer-events: none;
  transform: rotate(-14deg); animation: drawer-peek 1.1s 0.6s var(--spring) both;
}
@keyframes drawer-peek { from { transform: translateX(30px) rotate(0deg); opacity: 0; } }
.drawer-grabber { display: none; }
.drawer-left .drawer { right: auto; left: 0; top: 0; bottom: 0; border-radius: 0 var(--r-2xl) var(--r-2xl) 0; background: var(--surface-0); animation: slide-in-left 0.45s var(--ease-out) both; }
.drawer-left .drawer::before { left: auto; right: -1px; }
.drawer-bottom .drawer { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 88dvh; border-radius: 26px 26px 0 0; animation: slide-in-bottom 0.7s var(--spring) both; }
.drawer-bottom .drawer::before { left: 40px; right: 40px; top: -1px; bottom: auto; width: auto; height: 2px; background: linear-gradient(90deg, transparent, var(--ecto-1), var(--ecto-2), transparent); }
.drawer-bottom .drawer-grabber { display: flex; }
.drawer-bottom .drawer-peek { left: auto; right: 34px; top: -34px; transform: none; animation-name: drawer-peek-up; }
@keyframes drawer-peek-up { from { transform: translateY(26px); opacity: 0; } }
.drawer-root.is-closing .drawer { transform: translateX(calc(100% + 24px)); transition: transform var(--dur-3) var(--ease-in-out); animation: none; }
.drawer-left.is-closing .drawer { transform: translateX(-100%); }
.drawer-bottom.is-closing .drawer { transform: translateY(100%); }
.drawer-grabber { justify-content: center; padding: 9px 0 3px; cursor: grab; touch-action: none; flex: none; }
.drawer-grabber span { width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); padding: 20px 22px 16px; border-bottom: 1px solid var(--border); }
.drawer-title { font: 600 19px/1.2 var(--font-display); }
.drawer-subtitle { color: var(--text-3); font-size: var(--fs-sm); margin-top: 3px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px 22px; }
.drawer-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--s-2); padding: 14px 22px; border-top: 1px solid var(--border); border-radius: 0 0 var(--r-2xl) var(--r-2xl); background: var(--surface-1); }
.nav-drawer .drawer-body { padding: 0; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
@media (max-width: 759px) {
  /* Right drawers become a bottom sheet at 72dvh so the top of the list stays visible. */
  .drawer-right .drawer {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 72dvh; max-height: calc(100dvh - 40px);
    border-radius: 26px 26px 0 0; animation: slide-in-bottom 0.8s var(--spring) both;
  }
  .drawer-right .drawer::before { left: 40px; right: 40px; top: -1px; bottom: auto; width: auto; height: 2px; background: linear-gradient(90deg, transparent, var(--ecto-1), var(--ecto-2), transparent); }
  .drawer-right .drawer-grabber { display: flex; }
  .drawer-right .drawer-peek { left: auto; right: 34px; top: -34px; transform: none; animation-name: drawer-peek-up; }
  /* Pages that pass side="bottom" on phones (order/sale detail) get the same sheet height. */
  .drawer-bottom .drawer { height: 72dvh; max-height: calc(100dvh - 40px); }
  .drawer-right.is-closing .drawer { transform: translateY(100%); }
  .drawer-head { padding: 10px 16px 12px; }
  .drawer-body { padding: 14px 16px 18px; }
  .drawer-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-radius: 0; }
  .drawer-body:last-child { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
}

/* ============================================================
   Toasts — bottom-right; clear of an open right drawer; top on phones
   ============================================================ */
.toaster {
  position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: var(--z-toast);
  display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-2);
  pointer-events: none; width: min(400px, calc(100vw - 24px));
  transition: right 0.5s var(--spring);
}
.toaster.is-beside-drawer { right: calc(var(--toast-right, 0px) + 16px); }
.toast {
  pointer-events: auto; position: relative; display: flex; align-items: flex-start; gap: 10px; width: 100%;
  padding: 12px 10px 12px 14px; border-radius: var(--r-lg);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.55s var(--spring) both;
  overflow: hidden;
}
[data-theme="light"] .toast { background: var(--surface-1); }
.toast::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--toast-c, var(--ecto)); box-shadow: 0 0 10px var(--toast-c, var(--ecto)); }
.toast.is-leaving { animation: fade-out var(--dur-2) ease-in both; }
.toast-success { --toast-c: var(--success); }
.toast-error { --toast-c: var(--danger); }
.toast-warning { --toast-c: var(--warning); }
.toast-info { --toast-c: var(--ecto-text); }
.toast-icon { display: inline-flex; color: var(--toast-c); margin-top: 1px; }
.toast-text { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; margin-bottom: 1px; }
.toast-msg { color: var(--text-2); font-size: var(--fs-md); overflow-wrap: anywhere; }
.toast-title + .toast-msg { color: var(--text-3); font-size: var(--fs-sm); }
.toast-action { color: var(--ecto-text); font-weight: 600; font-size: var(--fs-sm); padding: 2px 6px; border-radius: 6px; white-space: nowrap; }
.toast-action:hover { background: var(--ecto-soft); }
.toast-close { display: inline-flex; color: var(--text-4); padding: 3px; border-radius: 5px; }
.toast-close:hover { color: var(--text); background: var(--surface-3); }
@media (max-width: 759px) {
  .toaster { left: 50%; right: auto; transform: translateX(-50%); align-items: stretch; bottom: calc(var(--bottomnav-h) + 14px + env(safe-area-inset-bottom)); }
  /* With a bottom sheet open the sticky actions own the bottom edge → toasts drop from the top. */
  .toaster.is-beside-drawer { right: auto; bottom: auto; top: calc(10px + env(safe-area-inset-top)); flex-direction: column-reverse; }
}

/* ============================================================
   Forms
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-inline { flex-direction: row; align-items: center; justify-content: space-between; }
.field-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.field-hint { font-size: var(--fs-xs); color: var(--text-3); }
.field-error { font-size: var(--fs-xs); color: var(--danger); animation: fade-down var(--dur-2) ease-out both; }

.input-wrap, .select-wrap { position: relative; display: inline-flex; align-items: center; width: 100%; min-width: 0; }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px;
  border-radius: 11px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font-size: 13.5px;
  transition: border-color var(--dur-2), box-shadow 0.3s, background var(--dur-1);
  -webkit-appearance: none; appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--ecto) 25%, var(--border-strong)); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 4px var(--ecto-softer); }
.input:disabled, .select:disabled { opacity: 0.55; cursor: not-allowed; }
.input-sm .input, .input-sm .select { height: 32px; font-size: var(--fs-sm); padding: 0 10px; border-radius: 9px; }
.input-lg .input { height: 46px; font-size: var(--fs-lg); padding: 0 14px; border-radius: 13px; }
.has-icon .input, .has-icon .select { padding-left: 36px; }
.input-lg.has-icon .input { padding-left: 42px; }
.has-suffix .input { padding-right: 40px; }
.input-icon { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; transition: color var(--dur-2); }
.input-lg .input-icon { left: 15px; }
.input-wrap:focus-within .input-icon, .select-wrap:focus-within .input-icon { color: var(--ecto-text); }
.input-suffix { position: absolute; right: 8px; display: inline-flex; align-items: center; color: var(--text-3); }
.input-clear { position: absolute; right: 6px; display: inline-flex; padding: 5px; border-radius: 6px; color: var(--text-3); }
.input-suffix .input-clear { position: static; }
.input-clear:hover { color: var(--text); background: var(--surface-3); }
.is-invalid .input { border-color: var(--danger); }
.is-invalid .input:focus { box-shadow: 0 0 0 4px var(--danger-bg); }
.search-input .input::-webkit-search-cancel-button { display: none; }
.search-input .input { padding-right: 38px; background: var(--surface-glass); border-color: var(--border); }
.select { padding-right: 32px; cursor: pointer; }
.input-sm .select { padding-right: 28px; } /* the sm shorthand above would otherwise run text under the chevron */
.input-sm .select-chevron { right: 9px; }
.select-chevron { position: absolute; right: 10px; color: var(--text-3); pointer-events: none; }
.select option { background: var(--surface-1); color: var(--text); }
.textarea { height: auto; padding: 10px 12px; line-height: 1.5; resize: vertical; min-height: 80px; }
input[type="date"].input { color-scheme: inherit; }
@media (max-width: 899px) {
  /* 16px stops iOS zooming into focused inputs. */
  .input, .select, .textarea, .palette-input { font-size: 16px; }
}

/* Checkbox — springy mint check */
.checkbox { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; vertical-align: middle; }
.checkbox input { position: absolute; opacity: 0; width: 18px; height: 18px; margin: 0; cursor: pointer; }
.checkbox-box {
  display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; flex-shrink: 0;
  border-radius: 5px; border: 1.5px solid var(--border-strong); background: var(--surface-2); color: transparent;
  transition: background var(--dur-1), border-color var(--dur-1), box-shadow var(--dur-2), transform 0.35s var(--spring);
}
.checkbox:hover .checkbox-box { border-color: color-mix(in srgb, var(--ecto) 45%, var(--border-strong)); }
.checkbox input:checked + .checkbox-box, .checkbox input:indeterminate + .checkbox-box {
  background: var(--ecto); border-color: var(--ecto); color: var(--ecto-ink); transform: scale(1.08);
  box-shadow: 0 0 10px color-mix(in srgb, var(--ecto) 50%, transparent);
}
.checkbox input:active + .checkbox-box { transform: scale(0.88); }
.checkbox input:focus-visible + .checkbox-box { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.checkbox-label { font-size: var(--fs-md); color: var(--text-2); }
.checkbox.is-disabled { opacity: 0.5; cursor: not-allowed; }

/* Toggle (switch) */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); cursor: pointer; }
.toggle-text { display: flex; flex-direction: column; min-width: 0; }
.toggle-text:empty { display: none; }
.toggle-label { font-weight: 600; color: var(--text); }
.toggle-desc { font-size: var(--fs-sm); color: var(--text-3); }
.toggle-ctl { position: relative; display: inline-flex; flex-shrink: 0; }
.toggle-ctl input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.toggle-track { width: 36px; height: 21px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; transition: background 0.25s, border-color 0.25s; }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: var(--text-3); transition: transform 0.45s var(--spring), background var(--dur-2), box-shadow var(--dur-2); }
.toggle-ctl input:checked + .toggle-track { background: var(--ecto-soft); border-color: color-mix(in srgb, var(--ecto) 50%, transparent); }
.toggle-ctl input:checked + .toggle-track .toggle-thumb { transform: translateX(15px); background: var(--ecto); box-shadow: 0 0 8px var(--ecto); }
.toggle-ctl input:focus-visible + .toggle-track { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.toggle-sm .toggle-track { width: 32px; height: 18px; }
.toggle-sm .toggle-thumb { width: 12px; height: 12px; }
.toggle-sm .toggle-ctl input:checked + .toggle-track .toggle-thumb { transform: translateX(14px); }
.toggle.is-disabled { opacity: 0.5; cursor: not-allowed; }

/* Tabs — pill container with a sliding raised thumb */
.tabs {
  position: relative; display: inline-flex; gap: 2px; padding: 3px; max-width: 100%;
  border-radius: 12px; background: var(--surface-glass); border: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px;
  border-radius: 9px; color: var(--text-3); font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: color var(--dur-2);
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); }
.tab-count { font: 600 11px var(--font-mono); color: var(--text-3); }
.tab.is-active .tab-count { color: var(--ecto-text); }
.tabs-indicator {
  position: absolute; left: 0; z-index: 0; border-radius: 9px;
  background: var(--surface-3); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 0 0 1px var(--border);
  transition: transform 0.55s var(--spring), width 0.55s var(--spring);
}
[data-theme="light"] .tabs-indicator { background: var(--surface-1); box-shadow: var(--shadow-xs), 0 0 0 1px var(--border-strong); }

/* Segmented control — mono labels, sliding ectoplasm thumb */
.segmented {
  position: relative; display: inline-flex; padding: 3px; gap: 0;
  border-radius: 12px; background: var(--surface-glass); border: 1px solid var(--border);
  width: fit-content; max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segment {
  position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: 9px; white-space: nowrap;
  color: var(--text-3); font: 600 12px var(--font-mono); transition: color var(--dur-2);
}
.segment:hover:not(.is-active) { color: var(--text); }
.segment.is-active { color: var(--ecto-ink); }
.segmented-sm .segment { height: 26px; padding: 0 10px; font-size: 11.5px; }
@media (max-width: 899px) { .segmented-sm .segment { height: 32px; padding: 0 10px; } }
.segmented-indicator {
  position: absolute; left: 0; z-index: 0; border-radius: 9px;
  background: var(--ecto-grad); box-shadow: 0 4px 16px -4px rgba(62, 224, 255, 0.6);
  transition: transform 0.55s var(--spring), width 0.55s var(--spring);
}

/* Inline edit */
.inline-edit {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 26px;
  /* Hover chrome bleeds 6px past the text without shrinking the intrinsic width
     (negative side margins made table cells / stacks truncate the value). */
  position: relative; left: -6px; margin: -3px 0; padding: 3px 6px; border-radius: 7px; color: inherit; text-align: left;
  transition: background var(--dur-1), box-shadow var(--dur-1);
}
.inline-edit:hover:not(:disabled) { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-strong); }
.inline-edit-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-edit.is-empty .inline-edit-value { color: var(--text-4); font-style: italic; }
.inline-edit-icon { color: var(--text-4); opacity: 0; transition: opacity var(--dur-1); }
.inline-edit:hover .inline-edit-icon, .inline-edit:focus-visible .inline-edit-icon { opacity: 1; }
.inline-edit.is-right { left: 6px; }
.inline-edit.is-editing { margin: -3px 0; padding: 0 6px; background: var(--surface-2); border-radius: 7px; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ecto) 60%, transparent), 0 0 0 3px var(--ecto-softer); }
.inline-edit.is-editing:hover { background: var(--surface-2); }
.inline-edit-prefix { color: var(--text-3); }
.inline-edit-input { width: 100%; min-width: 60px; height: 26px; border: 0; background: transparent; padding: 0; outline: none; font-variant-numeric: tabular-nums; }

/* Date range */
.date-range { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.date-range .select-wrap { width: auto; }
.date-range-pop { padding: var(--s-4); width: 320px; }
.date-range-custom .btn.is-active { border-color: color-mix(in srgb, var(--ecto) 40%, transparent); background: var(--ecto-soft); color: var(--ecto-text); }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; font-size: 12.5px; }
.pagination-info { color: var(--text-3); }
.pagination-info b, .pagination-info .num { color: var(--text); }
.pagination-ctl { display: flex; align-items: center; gap: 4px; }
.pagination-size { width: auto; margin-right: 6px; }
.pagination-pages { display: inline-flex; gap: 4px; }
.pagination-page { min-width: 30px; height: 28px; padding: 0 6px; border-radius: 8px; border: 1px solid var(--border); color: var(--text-2); font: 600 12px var(--font-mono); transition: transform 0.35s var(--spring), background var(--dur-1); }
.pagination-page:hover { background: var(--surface-2); color: var(--text); }
.pagination-page:active { transform: scale(0.9); }
.pagination-page.is-active { background: var(--ecto-soft); color: var(--ecto-text); border-color: color-mix(in srgb, var(--ecto) 40%, transparent); }
.pagination-gap { width: 20px; text-align: center; color: var(--text-4); line-height: 28px; }
.pagination-mini { padding: 0 8px; color: var(--text-2); font-family: var(--font-mono); }

/* ============================================================
   Table — sticky mono header, status aura edge, dim cancelled
   ============================================================ */
.table-shell {
  position: relative; min-width: 0;
  background: var(--surface-glass); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.card .table-shell { border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.table-wrap { overflow: auto; overscroll-behavior-x: contain; }
.table { width: 100%; font-size: 13px; border-collapse: separate; border-spacing: 0; }
.table th {
  position: sticky; top: 0; z-index: 2;
  height: 40px; padding: 0 12px; text-align: left; white-space: nowrap;
  font: 600 10.5px var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3);
  background: color-mix(in srgb, var(--surface-1) 96%, transparent);
  border-bottom: 1px solid var(--border-strong);
}
.table td { height: 52px; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
.table-dense td { height: 40px; padding: 5px 12px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur-2); }
.table tbody tr td { transition: background 0.18s; }
.table tbody tr:not(.is-skeleton):not(.table-empty-row):hover td { background: var(--ecto-softer); }
.table-clickable tbody tr:not(.is-skeleton):not(.table-empty-row) { cursor: pointer; }
.table tbody tr:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
.table tbody tr.is-selected td { background: var(--ecto-soft); }
.table tbody tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--ecto); }
.table tbody tr.has-aura td:first-child { box-shadow: inset 2px 0 0 var(--aura); }
.table tbody tr.has-aura.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--ecto); }
/* Cancelled: dim the row (tinted, sunk background; greyed photos/logos), never
   the text: reasons, amounts and dates must stay readable (ideas menu F6). */
.table tbody tr.is-cancelled td { background: color-mix(in srgb, var(--tone-cancelled) 4%, color-mix(in srgb, var(--bg) 35%, transparent)); }
.table tbody tr.is-cancelled :is(.item-thumb, .retailer-logo, .biz-thumb),
.table-card.is-cancelled :is(.item-thumb, .retailer-logo, .biz-thumb) { filter: grayscale(0.85); opacity: 0.55; }
.table tbody tr.is-cancelled .row-name, .table-card.is-cancelled .row-name { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--tone-cancelled) 60%, transparent); }
.table .align-right { text-align: right; }
.table .align-center { text-align: center; }
.table th.align-right .th-sort { flex-direction: row-reverse; }
.table-check-col { width: 44px; padding-right: 0 !important; }
.th-sort { display: inline-flex; align-items: center; gap: 6px; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; height: 100%; }
.th-sort:hover { color: var(--text); }
.table th.is-sorted { color: var(--ecto-text); }
.sort-ind { display: inline-flex; color: var(--text-4); }
.sort-ind path { fill: currentColor; opacity: 0.45; transition: opacity var(--dur-1), fill var(--dur-1); }
.sort-ind.is-asc .up, .sort-ind.is-desc .down { opacity: 1; fill: var(--ecto-text); }
.sort-ind.is-asc .down, .sort-ind.is-desc .up { opacity: 0.2; }
.table-empty-row td { border-bottom: 0; }
.table-shell.is-loading tbody { opacity: 0.6; transition: opacity var(--dur-2); }
.table-progress { position: absolute; top: 0; left: 0; right: 0; height: 2px; z-index: 3; overflow: hidden; }
.table-progress::after { content: ""; position: absolute; top: 0; bottom: 0; width: 35%; background: var(--ecto-grad); box-shadow: 0 0 10px var(--ecto); animation: indeterminate 1.1s var(--ease-in-out) infinite; }
@keyframes indeterminate { 0% { left: -35%; } 100% { left: 100%; } }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 12.5px; }

.table-cards { display: flex; flex-direction: column; gap: 8px; }
.table-cards.is-loading { opacity: 0.6; }
.table-card {
  position: relative; padding: 12px 14px; min-width: 0; overflow: hidden;
  background: var(--surface-glass); border: 1px solid var(--border); border-radius: 16px;
  transition: border-color var(--dur-1), transform 0.35s var(--spring);
}
.table-card.has-aura::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--aura); box-shadow: 0 0 10px var(--aura); }
.table-card.is-cancelled { background: color-mix(in srgb, var(--tone-cancelled) 4%, var(--surface-glass)); border-style: dashed; }
.table-card.is-clickable { cursor: pointer; }
.table-card.is-clickable:active { transform: scale(0.985); }
.table-card.is-selected { border-color: color-mix(in srgb, var(--ecto) 50%, transparent); background: color-mix(in srgb, var(--ecto) 7%, var(--surface-1)); }
.table-card-check { position: absolute; top: 12px; right: 12px; z-index: 1; }
.table-card-empty { background: var(--surface-glass); border: 1px solid var(--border); border-radius: 16px; }
.table-cards-foot { padding: var(--s-2) 0; }
.card .table-cards { padding: var(--s-3); }
.card .table-card { background: var(--surface-2); }

/* ============================================================
   Charts — dashed recessive grid, mono axes, crosshair band
   ============================================================ */
.chart { position: relative; min-width: 0; }
.chart-canvas { position: relative; width: 100%; }
.chart-svg { display: block; overflow: visible; touch-action: pan-y; }
.chart-grid line { stroke: var(--grid-line); stroke-width: 1; stroke-dasharray: 2 4; shape-rendering: crispEdges; }
.chart-grid line:first-child { stroke: var(--border-strong); stroke-dasharray: none; }
.chart-axis text { fill: var(--text-3); font: 500 10.5px var(--font-mono); font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.4s 0.25s var(--ease-out) forwards; }
.chart-area { opacity: 0; animation: fade-in 0.9s 0.45s ease-out forwards; }
.chart-dot { stroke: var(--surface-1); stroke-width: 2; }
.chart-crosshair { stroke: color-mix(in srgb, var(--ecto) 55%, transparent); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-hover-dot { stroke: var(--surface-1); stroke-width: 2.5; }
.chart-band { fill: var(--ecto-softer); animation: fade-in 0.15s ease-out both; }
.chart-bar-group { transform-origin: bottom; transform-box: fill-box; animation: grow-y 0.9s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 18ms + 200ms); transition: opacity var(--dur-2); }
.chart-bar-group.is-dim { opacity: 0.5; }
.chart-peak path { stroke: var(--text-3); stroke-dasharray: 2 2; fill: none; }
.chart-peak text { fill: var(--text-2); font: 600 10.5px var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: var(--s-3); }
.chart-legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); padding: 2px 4px; border-radius: 6px; }
.chart-legend-item:not(:disabled):hover { background: var(--surface-2); }
.chart-legend-item:disabled { cursor: default; }
.chart-legend-item.is-off { opacity: 0.4; }
.chart-legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.chart-tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 160px;
  padding: 10px 12px; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: 0 14px 30px -10px rgba(0, 0, 0, 0.6);
  font-size: 12px; white-space: nowrap;
  animation: pop-in 0.25s var(--spring) both;
}
[data-theme="light"] .chart-tooltip { background: var(--surface-1); box-shadow: var(--shadow-lg); }
.chart-tooltip-title { font: 600 10.5px var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); margin-bottom: 6px; }
.chart-tooltip-row { display: flex; align-items: center; gap: 8px; line-height: 1.7; }
.chart-tooltip-swatch { width: 8px; height: 8px; border-radius: 2px; }
.chart-tooltip-label { color: var(--text-2); flex: 1; }
.chart-tooltip-value { color: var(--text); font-weight: 600; }
.chart-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--text-3); font-size: var(--fs-sm); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); }

.donut { display: flex; align-items: center; gap: var(--s-6); min-width: 0; }
.donut-legend-bottom { flex-direction: column; gap: var(--s-4); }
.donut-figure { position: relative; flex-shrink: 0; }
.donut-figure svg { display: block; }
.donut-track { stroke: var(--surface-3); }
.donut-seg { transition: stroke-dasharray 1.2s var(--ease-out), stroke-width 0.35s var(--spring), opacity var(--dur-2); cursor: pointer; }
.donut-seg.is-dim { opacity: 0.4; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.donut-center-value { font: 600 var(--fs-2xl) var(--font-display); letter-spacing: -0.01em; }
.donut-center-label { font: 600 10px var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; width: 100%; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 7px; font-size: var(--fs-sm); transition: background var(--dur-1); }
.donut-legend-item.is-active { background: var(--surface-2); }
.donut-legend-label { flex: 1; color: var(--text-2); }
.donut-legend-value { color: var(--text); font-weight: 600; font-family: var(--font-display); }
.donut-legend-pct { color: var(--text-3); width: 40px; text-align: right; font: 500 11px var(--font-mono); }
@media (max-width: 520px) { .donut-legend-right { flex-direction: column; gap: var(--s-4); } }

.sparkline { width: 100%; }
.sparkline svg { display: block; overflow: visible; }
.sparkline-line { stroke-width: 2; }
.sparkline-end { stroke: var(--surface-1); stroke-width: 1.5; }

.progress { display: flex; flex-direction: column; gap: 6px; min-width: 0; --pc: var(--ecto); }
.progress-head { display: flex; justify-content: space-between; gap: var(--s-2); font-size: var(--fs-sm); }
.progress-label { color: var(--text-2); }
.progress-value { color: var(--text); font: 600 12px var(--font-mono); }
.progress-track { position: relative; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-xs .progress-track { height: 2px; }
.progress-sm .progress-track { height: 4px; }
.progress-lg .progress-track { height: 10px; }
.progress-fill { height: 100%; width: 0; border-radius: inherit; background: var(--pc); transition: width 1.1s var(--ease-out); }
.progress-tone-accent .progress-fill { background: var(--ecto-grad); box-shadow: 0 0 10px color-mix(in srgb, var(--ecto) 60%, transparent); }
.progress-tone-alive { --pc: var(--tone-alive); }
.progress-tone-preorder { --pc: var(--tone-preorder); }
.progress-tone-confirmed { --pc: var(--tone-confirmed); }
.progress-tone-shipped { --pc: var(--tone-shipped); }
.progress-tone-arriving { --pc: var(--tone-arriving); }
.progress-tone-delivered { --pc: var(--tone-delivered); }
.progress-tone-cancelled { --pc: var(--tone-cancelled); }
.progress-tone-refunded { --pc: var(--tone-refunded); }
.progress-tone-alerts { --pc: var(--tone-alerts); }
.progress-tone-neutral { --pc: var(--tone-neutral); }
.progress.is-striped .progress-fill { background-image: linear-gradient(45deg, rgba(255,255,255,.18) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.18) 50%, rgba(255,255,255,.18) 75%, transparent 75%); background-size: 14px 14px; animation: progress-stripes 0.8s linear infinite; }
.progress.is-indeterminate .progress-fill { position: absolute; width: 35%; animation: indeterminate 1.2s var(--ease-in-out) infinite; }

/* ============================================================
   Retailer badge
   ============================================================ */
.retailer-logo {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden;
  background: var(--rl-bg); color: var(--rl-fg);
  font-weight: 800; letter-spacing: -0.03em; line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.25);
}
.retailer-logo::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 55%); pointer-events: none; }
.retailer-logo.has-accent::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 14%; background: var(--rl-accent); }
.retailer-logo-mono { position: relative; z-index: 1; }
.retailer-chip { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.retailer-chip-name { font-weight: 600; color: var(--text); }

/* ============================================================
   Notifications
   ============================================================ */
.notif-list { display: flex; flex-direction: column; gap: 2px; margin: 0 calc(var(--s-3) * -1); }
.notif-item { position: relative; display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 10px var(--s-3); border-radius: 12px; text-align: left; transition: background var(--dur-1), transform 0.35s var(--spring); }
button.notif-item:hover { background: var(--surface-2); transform: translateX(2px); }
.notif-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0; }
.notif-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.notif-title { font-weight: 550; color: var(--text-2); }
.notif-item.is-unread .notif-title { color: var(--text); font-weight: 600; }
.notif-body { font-size: var(--fs-sm); color: var(--text-3); }
.notif-time { font: 500 11px var(--font-mono); color: var(--text-3); margin-top: 2px; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ecto); margin-top: 6px; box-shadow: 0 0 8px var(--ecto); }

/* ============================================================
   Command palette
   ============================================================ */
.palette-root { z-index: var(--z-palette); display: flex; justify-content: center; align-items: flex-start; padding: 12vh var(--s-4) var(--s-4); }
.palette {
  position: relative; width: 100%; max-width: 640px; max-height: 70vh; display: flex; flex-direction: column;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0, 0, 0, 0.2), 0 0 80px -30px color-mix(in srgb, var(--ecto) 50%, transparent);
  animation: modal-in 0.45s var(--spring) both; overflow: hidden;
}
.palette::before { content: ""; position: absolute; left: 40px; right: 40px; top: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--ecto-1), var(--ecto-2), transparent); opacity: 0.7; }
.palette:focus { outline: none; }
.palette-root.is-closing .palette { animation: fade-out var(--dur-1) ease-in both; }
.palette-input-row { display: flex; align-items: center; gap: 10px; padding: 0 var(--s-4); height: 56px; border-bottom: 1px solid var(--border); color: var(--ecto-text); }
.palette-input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none; font-size: var(--fs-lg); color: var(--text); }
.palette-input::placeholder { color: var(--text-3); }
.palette-list { flex: 1; overflow-y: auto; padding: 6px; }
.palette-group + .palette-group { margin-top: 6px; }
.palette-group-title { padding: 8px 10px 5px; font: 600 10px var(--font-mono); letter-spacing: var(--eyebrow-track); text-transform: uppercase; color: var(--text-3); }
.palette-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 42px; padding: 0 10px; border-radius: 10px; text-align: left; color: var(--text-2); }
.palette-item.is-active { background: var(--ecto-softer); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ecto) 25%, transparent); }
.palette-item-icon { display: inline-flex; width: 24px; justify-content: center; color: var(--text-3); }
.palette-item.is-active .palette-item-icon { color: var(--ecto-text); }
.palette-item-label { flex: 1; }
.palette-item-label strong { color: var(--text); font-weight: 600; }
.palette-item-hint { display: inline-flex; align-items: center; gap: 8px; color: var(--text-3); font: 500 11px var(--font-mono); }
.palette-empty { padding: var(--s-7) var(--s-4); text-align: center; color: var(--text-3); }
.palette-foot { display: flex; gap: var(--s-4); padding: 8px var(--s-4); border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-3); background: color-mix(in srgb, var(--surface-0) 60%, transparent); }
.palette-foot span { display: inline-flex; align-items: center; gap: 5px; }
.palette-foot .kbd { height: 18px; min-width: 18px; font-size: 10px; }
@media (max-width: 640px) {
  .palette-root { padding: calc(8px + env(safe-area-inset-top)) 8px 8px; }
  .palette { max-height: 80dvh; }
  .palette-foot { display: none; }
}

/* ============================================================
   Phone tab bar with the raised "+" (Add order)
   ============================================================ */
.mobile-nav { display: none; }
@media (max-width: 759px) {
  .mobile-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-topbar);
    display: flex; align-items: center; justify-content: space-around;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface-0) 88%, transparent);
    backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
    border-top: 1px solid var(--border);
  }
  .mobile-tab {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    width: 62px; height: 50px; border-radius: 14px;
    color: var(--text-3); font-size: 10.5px; font-weight: 600;
    transition: color var(--dur-1), background var(--dur-2), transform 0.35s var(--spring);
  }
  .mobile-tab:active { transform: scale(0.92); }
  .mobile-tab.is-active { color: var(--ecto-text); background: var(--ecto-soft); }
  .mobile-tab.is-active::before {
    content: ""; position: absolute; top: -9px; left: 20px; right: 20px; height: 3px; border-radius: 0 0 3px 3px;
    background: var(--ecto-grad); box-shadow: 0 0 12px var(--ecto); animation: pop-in 0.4s var(--spring) both;
  }
  .mobile-fab {
    display: grid; place-items: center; width: 58px; height: 58px; margin-top: -28px; flex: none;
    border-radius: 20px; background: var(--ecto-grad); color: var(--ecto-ink);
    box-shadow: var(--ecto-glow), 0 0 0 5px var(--bg);
    transition: transform 0.4s var(--spring);
  }
  .mobile-fab:active { transform: scale(0.9); }
  .mobile-fab.is-active { box-shadow: var(--ecto-glow), 0 0 0 5px var(--bg), 0 0 0 7px color-mix(in srgb, var(--ecto) 45%, transparent); }
}

/* ============================================================
   Login + splash
   ============================================================ */
.login { position: relative; min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--s-5); overflow: hidden; }
.login-glow {
  position: absolute; width: 720px; height: 720px; border-radius: 50%; top: 50%; left: 50%; transform: translate(-50%, -62%);
  background: radial-gradient(closest-side, color-mix(in srgb, var(--ecto) 22%, transparent), color-mix(in srgb, var(--ecto-2) 6%, transparent) 55%, transparent 72%);
  filter: blur(10px); pointer-events: none; animation: fade-in 1.2s ease-out both;
}
.login-card {
  position: relative; width: 100%; max-width: 390px; display: flex; flex-direction: column; gap: var(--s-4);
  padding: var(--s-7) var(--s-6) var(--s-6);
  background: var(--surface-glass);
  border: 1px solid var(--border-strong); border-radius: var(--r-2xl);
  box-shadow: var(--shadow-xl);
  animation: apparition 0.9s var(--ease-out) backwards;
}
.login-card.is-shake { animation: shake 380ms var(--ease-out); }
@keyframes shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }
.login-logo { display: flex; justify-content: center; }
.login-eyebrow { text-align: center; margin-bottom: -8px; }
.login-title { text-align: center; font: 600 26px/1.1 var(--font-display); }
.login-sub { text-align: center; color: var(--text-2); margin-top: -10px; margin-bottom: var(--s-2); }
.login-discord { display: flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; background: #5865f2; color: #fff; border: 1px solid rgba(255,255,255,.12); border-radius: var(--r-md, 10px); min-height: 44px; font-weight: 600; transition: filter 160ms var(--ease-out), transform 160ms var(--ease-out); }
.login-discord:hover { filter: brightness(1.08); }
.login-discord:active { transform: translateY(1px); }
.login-or { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; }
.login-or::before, .login-or::after { content: ''; flex: 1; height: 1px; background: var(--border, rgba(255,255,255,.08)); }
.login-error-solo { text-align: center; }
.login-foot { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--text-3); font-size: var(--fs-xs); margin-top: var(--s-1); }

.splash { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-5); padding: var(--s-5); text-align: center; }
.splash-logo { filter: drop-shadow(0 0 18px color-mix(in srgb, #5ef3d6 50%, transparent)); }
.splash-logo.is-pulsing { animation: pulse 1.4s ease-in-out infinite; }
.splash-bar { width: 120px; height: 2px; border-radius: 2px; background: var(--surface-3); position: relative; overflow: hidden; }
.splash-bar span { position: absolute; top: 0; bottom: 0; width: 40%; background: var(--ecto-grad); animation: indeterminate 1s var(--ease-in-out) infinite; }
.splash-error { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); animation: apparition 0.8s var(--ease-out) backwards; }
.splash-title { font: 600 var(--fs-xl) var(--font-display); }
.splash-body { color: var(--text-3); max-width: 380px; margin-bottom: var(--s-3); }

/* ============================================================
   Tonight band (components/phantom.js TonightBand) — container-query driven
   ============================================================ */
.tonight-wrap { container-type: inline-size; min-width: 0; }
.tonight {
  position: relative; overflow: hidden; padding: 20px 26px 34px;
  display: grid; grid-template-columns: minmax(280px, 1.25fr) repeat(3, minmax(0, 0.8fr)) minmax(250px, 1.2fr);
  align-items: center;
  background:
    radial-gradient(120% 180% at 0% 0%, rgba(125, 255, 198, 0.16), transparent 45%),
    radial-gradient(90% 160% at 100% 100%, rgba(62, 224, 255, 0.12), transparent 55%),
    var(--surface-1);
  border-radius: 22px 22px 0 0;
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 12px) no-repeat,
                radial-gradient(circle at 50% 0, #000 11.5px, transparent 12px) bottom left / 24px 12px repeat-x;
          mask: linear-gradient(#000 0 0) top / 100% calc(100% - 12px) no-repeat,
                radial-gradient(circle at 50% 0, #000 11.5px, transparent 12px) bottom left / 24px 12px repeat-x;
}
[data-theme="light"] .tonight {
  background:
    radial-gradient(120% 180% at 0% 0%, rgba(0, 200, 140, 0.14), transparent 45%),
    radial-gradient(90% 160% at 100% 100%, rgba(0, 160, 230, 0.12), transparent 55%),
    #ffffff;
}
.tonight::before { /* sweeping wisp */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 35%, color-mix(in srgb, var(--ecto-1) 10%, transparent) 48%, transparent 60%);
  animation: wisp 7s ease-in-out infinite;
}
.is-hidden .tonight::before { animation-play-state: paused; }
.tonight > * { position: relative; }
.tonight-hero { display: flex; align-items: center; gap: 16px; padding-right: 20px; min-width: 0; }
.tonight-title { margin: 0; font: 600 20px/1.15 var(--font-display); }
.tonight-sub { margin: 4px 0 0; color: var(--text-2); font-size: 13px; }
.tonight-stat { padding: 2px 22px; border-left: 1px dashed var(--border-strong); min-width: 0; }
.tonight-v { font: 600 30px/1 var(--font-display); letter-spacing: -0.01em; display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.tonight-v small { font: 600 11px var(--font-mono); color: var(--tone-alive); }
.tonight-l { margin-top: 6px; font-size: 12.5px; color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.tonight-l .icon { color: var(--text-3); }
.tonight-side { margin-left: 18px; min-width: 0; }
.tonight-drop {
  margin-left: 18px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--surface-2) 75%, transparent);
  border: 1px solid var(--border); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 5px 12px; align-items: center;
}
.tonight-drop-logo { grid-column: 1; grid-row: 1 / 3; border-radius: 9px; }
.tonight-drop-ico { width: 32px; height: 32px; display: grid; place-items: center; background: var(--ecto-soft); color: var(--ecto-text); }
.tonight-drop-eb { grid-column: 2; grid-row: 1; font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tonight-drop-name { grid-column: 2; grid-row: 2; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tonight-drop-cd { grid-column: 3; grid-row: 1 / 3; }
@container (max-width: 1240px) {
  .tonight { grid-template-columns: minmax(240px, 1.2fr) repeat(3, minmax(0, 0.8fr)); }
  .tonight-drop, .tonight-side { grid-column: 1 / -1; margin: 14px 0 0; }
}
@container (max-width: 820px) {
  .tonight { grid-template-columns: repeat(3, 1fr); padding: 16px 16px 30px; border-radius: 20px 20px 0 0; align-items: start; }
  .tonight-hero { grid-column: 1 / -1; padding: 0 0 14px; }
  .tonight-title { font-size: 18px; }
  .tonight-stat { padding: 0 10px; }
  .tonight-hero + .tonight-stat { border-left: 0; padding-left: 0; }
  .tonight-v { font-size: 24px; }
  .tonight-v small { display: none; }
  .tonight-l { font-size: 11.5px; }
  .tonight-drop-cd { font-size: 18px; }
}

/* Touch targets ≥ 40px on touch-size screens (contract §5). */
@media (max-width: 899px) {
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn-sm { width: 36px; height: 36px; }
  .sidebar.is-mobile .kbd-group { display: none; }
  .btn { min-height: 38px; }
  .btn-sm { min-height: 34px; }
  .menu-item { height: 42px; }
}

/* Density: compact (Settings → Appearance; <html data-density="compact">).
   Desktop only — touch targets stay ≥ 40px on phones. */
@media (min-width: 900px) {
  [data-density="compact"] .table td { height: 40px; padding: 4px 12px; }
  [data-density="compact"] .table th { height: 34px; }
  [data-density="compact"] .card-body.is-padded { padding: var(--s-4); }
  [data-density="compact"] .card-head { padding: var(--s-3) var(--s-4) 0; }
  [data-density="compact"] .card-head + .card-body.is-padded { padding-top: var(--s-3); }
  [data-density="compact"] .stat { padding: var(--s-3) var(--s-4); min-height: 0; }
  [data-density="compact"] .stat-value { font-size: 32px; margin-top: 10px; }
  [data-density="compact"] .page-header { margin-bottom: var(--s-3); }
  [data-density="compact"] .stack { gap: var(--s-2); }
  [data-density="compact"] .grid, [data-density="compact"] .grid-2, [data-density="compact"] .grid-3,
  [data-density="compact"] .grid-4, [data-density="compact"] .grid-auto, [data-density="compact"] .grid-12 { gap: var(--s-3); }
}

/* ---------- Product photos on dark (ideas menu F1) ----------
 * Retailer product shots come on pure white. On the dark UI a #fff square
 * glares, so every product thumbnail sits on a soft, slightly dimmed plate
 * inside a hairline frame. Light theme keeps plain white. */
:root, [data-theme="dark"] {
  --photo-plate: linear-gradient(160deg, #e3e8ef 0%, #cdd5e0 100%);
  --photo-dim: brightness(0.9) saturate(1.05);
  --photo-frame: color-mix(in srgb, var(--ecto) 14%, var(--border));
}
[data-theme="light"] {
  --photo-plate: #fff;
  --photo-dim: none;
  --photo-frame: var(--border);
}

/* ---------- Shared order bits (components/order-bits.js) ---------- */
.item-thumb {
  position: relative; display: inline-grid; place-items: center; flex: none; overflow: hidden;
  border-radius: 10px; background: var(--photo-plate); border: 1px solid var(--photo-frame);
}
.item-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; filter: var(--photo-dim); }
.item-thumb.is-empty { background: var(--surface-2); color: var(--text-3); border-color: var(--border); }
[data-theme="light"] .item-thumb.is-empty { background: var(--surface-3); }

.house-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 180px; min-width: 0;
  height: 18px; padding: 0 6px; border-radius: 5px; font-size: 10.5px; font-weight: 600; line-height: 1;
  color: var(--text-2); background: var(--surface-3); border: 1px solid var(--border);
}
.house-chip.is-sm { height: 17px; font-size: 10px; padding: 0 5px; }
.house-chip-dot { width: 6px; height: 6px; border-radius: 2px; background: var(--house); flex: none; box-shadow: 0 0 6px color-mix(in srgb, var(--house) 60%, transparent); }
.house-chip .privacy-text, .house-chip-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Phones: readable small text + thumb-sized controls (ideas menu F6) ----------
 * Small buttons were 30px and status micro-labels 9.5px; on a phone during a
 * drop or a house run they need to be tappable and legible. */
@media (max-width: 759px) {
  .btn-sm { height: 36px; padding: 0 12px; font-size: 13px; }
  .btn-icon-only.btn-sm, .icon-btn-sm { width: 36px; height: 36px; }
  .soul { font-size: 11px; }
  .soul-sm { height: 22px; font-size: 10.5px; }
  .house-chip.is-sm { height: 20px; font-size: 11px; }
  .text-xs { font-size: max(var(--fs-xs), 12px); }
}

/* "Why is this spend different?" (components/spend-why.js) */
.spend-why-icon { display: inline-flex; align-items: center; vertical-align: middle; margin-left: 4px; color: var(--text-3); cursor: help; border-radius: 999px; }
.spend-why-icon:hover, .spend-why-icon:focus-visible { color: var(--ecto, var(--accent)); outline: none; }
.tooltip:has(.spend-why) { max-width: 340px; font-weight: 500; padding: 9px 11px; }
.spend-why { display: flex; flex-direction: column; gap: 6px; }
.spend-why-others { color: var(--text-2); font-size: 11.5px; }
