/* ==========================================================================
   Live demo: integration conveyor (ERP hub + systems) and the analytics dashboard.
   Each system has its own colour (--sys-* in tokens.css), set per card as --c.
   ========================================================================== */
.demo { position: relative; overflow: hidden; }
.demo__glow {
  position: absolute;
  inset: 18% -10% auto;
  height: 70%;
  background:
    radial-gradient(40% 50% at 50% 50%, rgba(250, 204, 21, 0.07), transparent 70%),
    radial-gradient(50% 60% at 30% 40%, rgba(139, 92, 246, 0.14), transparent 70%),
    radial-gradient(40% 50% at 75% 60%, rgba(42, 171, 238, 0.08), transparent 70%);
  pointer-events: none;
}
.demo .container { position: relative; }
.demo__head { margin-bottom: clamp(1.8rem, 1.2rem + 2vw, 2.8rem); }
.demo__head .h2 { max-width: 22ch; }
.demo__head .lead { max-width: 62ch; margin: 1rem auto 0; }
.demo__note { margin-top: 1.2rem; text-align: center; font-size: var(--fs-label); color: var(--text-dim); }

/* plain buttons and lists inside the demo */
.demo__tabs button, .flow__node, .flow__pp { margin: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.flow__track, .flow__track li, .chevrons, .funnel, .leaders { list-style: none; margin: 0; padding: 0; }

/* ---------- tabs ---------- */
.demo__tabs {
  display: flex;
  gap: 0.3rem;
  width: max-content;
  max-width: 100%;
  margin: 0 auto 1.6rem;
  padding: 0.3rem;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: rgba(17, 16, 25, 0.7);
}
.demo__tabs button {
  position: relative;
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  font: 600 var(--fs-small) / 1 var(--font-display);
  color: var(--text-muted);
  transition: color var(--t-fast), background var(--t-fast);
}
.demo__tabs button:hover { color: var(--text); }
.demo__tabs button[aria-selected="true"] {
  color: #fff;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.55), rgba(96, 165, 250, 0.35));
  box-shadow: 0 0 0 1px rgba(196, 181, 253, 0.3) inset, var(--glow-violet);
}
.demo__tab-dot {
  position: absolute;
  top: 0.35rem;
  right: 0.45rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chart-3);
  box-shadow: 0 0 10px var(--chart-3);
}

/* ==========================================================================
   Conveyor
   ========================================================================== */
.flow__stage {
  position: relative;
  display: grid;
  gap: 1rem;
}
.flow__wires { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; display: none; }

/* ---------- glass station ---------- */
.station {
  --c: var(--sys-crm);
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0.85rem 0.95rem 0.8rem;
  border-radius: var(--radius);
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--c) 9%, transparent), transparent 45%),
    linear-gradient(155deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015));
  border: 1px solid color-mix(in srgb, var(--c) 22%, rgba(225, 215, 255, 0.1));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.07) inset, 0 24px 50px -30px rgba(0, 0, 0, 0.9);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  cursor: pointer;
  outline: none;
  transition: border-color var(--t) var(--ease-out), box-shadow var(--t) var(--ease-out), transform var(--t) var(--ease-out), opacity var(--t);
}
.station::before { /* glass edge highlight */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.35), transparent 35%, transparent 70%, color-mix(in srgb, var(--c) 45%, transparent));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.station--email { --c: var(--sys-email); }
.station--excel { --c: var(--sys-excel); }
.station--crm { --c: var(--sys-crm); }
.station--erp { --c: var(--sys-erp); }
.station--stock { --c: var(--sys-stock); }
.station--np { --c: var(--sys-np); }
.station--tg { --c: var(--sys-tg); }

.station.is-active {
  border-color: color-mix(in srgb, var(--c) 70%, transparent);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.1) inset,
    0 0 0 1px color-mix(in srgb, var(--c) 35%, transparent),
    0 0 34px -4px color-mix(in srgb, var(--c) 45%, transparent),
    0 30px 60px -30px rgba(0, 0, 0, 0.9);
  cursor: default;
}
.station:focus-visible { box-shadow: 0 0 0 2px var(--c); }

.station__head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.65rem; }
.station__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 30%, transparent) inset;
}
.station.is-active .station__icon { box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 60%, transparent) inset, 0 0 18px color-mix(in srgb, var(--c) 55%, transparent); }
.station__icon svg, .flow__node svg, .station__cta svg, .chat__ava svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.station__name { font: 700 0.95rem / 1.1 var(--font-display); color: var(--text); letter-spacing: 0.01em; }
.station__state { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: rgba(196, 181, 253, 0.2); }
.station.is-active .station__state { background: var(--c); box-shadow: 0 0 10px var(--c); animation: blink 1.1s ease-in-out infinite; }
.station.is-done .station__state { background: var(--good); box-shadow: 0 0 8px rgba(74, 222, 128, 0.6); }

.station__body { flex: 1; min-height: 0; font-size: 0.76rem; color: var(--text-muted); }
.station__done {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.55rem;
  font-size: 0.72rem;
  color: var(--good);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--t), transform var(--t) var(--ease-out);
}
.station__done svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.station.is-done .station__done { opacity: 1; transform: none; }

/* rows "fill in" one after another when the station becomes active */
.station__body.is-filling .r,
.station__body.is-filling tr.r > * { animation-delay: calc(var(--i, 0) * 110ms + 120ms); }
.station__body.is-filling .r:not(tr) { animation-name: rowIn, rowFlash; animation-duration: 0.5s, 1s; animation-timing-function: var(--ease-out), ease-out; animation-fill-mode: both; }
.station__body.is-filling tr.r { animation: rowIn 0.5s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 110ms + 120ms); }
.station__body.is-filling tr.r > * { animation: rowFlash 1s ease-out both; animation-delay: calc(var(--i, 0) * 110ms + 120ms); }
@keyframes rowIn { from { opacity: 0; transform: translateX(-8px); } }
@keyframes rowFlash { from { box-shadow: inset 0 0 0 999px color-mix(in srgb, var(--c) 30%, transparent); } }
@keyframes blink { 50% { opacity: 0.35; } }

/* ---------- body pieces ---------- */
.kv { display: grid; gap: 1px; border-radius: 10px; overflow: hidden; background: rgba(196, 181, 253, 0.07); }
.kv > div { display: grid; grid-template-columns: minmax(5.5rem, 38%) 1fr; gap: 0.6rem; align-items: center; padding: 0.38rem 0.6rem; background: rgba(12, 11, 18, 0.72); }
.kv dt { color: var(--text-dim); }
.kv dd { color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv--totals { margin-top: 0.4rem; }
.kv .r--total dt, .kv .r--total dd { color: #fff; font-weight: 700; }
.kv .r--total dd { color: var(--c); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.95em; letter-spacing: 0.02em; }
.ok { color: var(--good); }
.chip { display: inline-block; padding: 0.1rem 0.45rem; border-radius: 6px; font-size: 0.92em; }
.chip--excel { color: var(--sys-excel); background: rgba(34, 197, 94, 0.12); box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.3) inset; }
.meter { display: inline-block; width: 4.2rem; height: 6px; margin-right: 0.35rem; border-radius: 3px; background: rgba(196, 181, 253, 0.12); vertical-align: middle; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--chart-1), var(--chart-2)); }

table.doc, .sheet table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
table.doc th, table.doc td { padding: 0.32rem 0.45rem; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.doc thead th { font-weight: 600; font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase; color: color-mix(in srgb, var(--c) 75%, white); background: color-mix(in srgb, var(--c) 13%, transparent); }
table.doc thead th:first-child { border-radius: 8px 0 0 8px; width: 46%; }
table.doc thead th:last-child { border-radius: 0 8px 8px 0; }
table.doc tbody td { border-bottom: 1px solid rgba(196, 181, 253, 0.07); color: var(--text); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.r--more td { color: var(--text-dim); text-align: center; border: 0 !important; }
.doc-title { margin-bottom: 0.45rem; color: var(--text-muted); }
.doc-title b { color: #fff; font-family: ui-monospace, Consolas, monospace; }
.doc-title span { color: var(--text-dim); }

/* Excel sheet (green glass) */
.sheet { border-radius: 10px; overflow: hidden; box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.25) inset; background: rgba(6, 20, 12, 0.35); }
.sheet__letters, .sheet table tr { display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) 3.3rem 3.6rem 4.3rem; }
.sheet__letters { background: rgba(34, 197, 94, 0.2); color: #bbf7d0; font-size: 0.64rem; font-weight: 600; text-align: center; }
.sheet__letters span { padding: 0.18rem 0; border-right: 1px solid rgba(34, 197, 94, 0.2); }
.sheet table th, .sheet table td { padding: 0.24rem 0.4rem; border-right: 1px solid rgba(34, 197, 94, 0.13); border-bottom: 1px solid rgba(34, 197, 94, 0.13); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sheet thead th { color: #dcfce7; font-weight: 600; font-size: 0.68rem; background: rgba(34, 197, 94, 0.1); text-align: left; }
.sheet tbody th, .sheet thead th:first-child, .sheet tfoot th { color: rgba(187, 247, 208, 0.55); font-weight: 500; text-align: center; font-size: 0.66rem; background: rgba(34, 197, 94, 0.06); }
.sheet tbody td { color: var(--text-muted); }
.sheet tbody tr.is-on td { color: var(--text); }
.sheet tbody tr.is-on .sheet__qty { box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.55); }
.sheet tfoot td { color: #fff; font-weight: 700; background: rgba(34, 197, 94, 0.12); }
.sheet tfoot td:first-of-type { grid-column: span 3; }
.sheet__qty { padding: 0 !important; }
.sheet__qty input {
  width: 100%;
  height: 100%;
  min-height: 1.5rem;
  padding: 0 0.4rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: right;
  -moz-appearance: textfield;
}
.sheet__qty input::-webkit-outer-spin-button, .sheet__qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sheet__qty input:focus { outline: 2px solid var(--sys-excel); outline-offset: -2px; background: rgba(34, 197, 94, 0.12); color: #fff; }

/* CRM stage chevrons */
.chevrons { display: flex; gap: 2px; margin-bottom: 0.55rem; }
.chevrons li {
  flex: 1;
  min-width: 0;
  padding: 0.3rem 0.35rem 0.3rem 0.6rem;
  font-size: 0.62rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-dim);
  background: rgba(196, 181, 253, 0.08);
  clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 50%, calc(100% - 7px) 100%, 0 100%, 7px 50%);
}
.chevrons li:first-child { clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 50%, calc(100% - 7px) 100%, 0 100%); border-radius: 6px 0 0 6px; }
.chevrons li.is-past { color: #ede9fe; background: rgba(139, 92, 246, 0.35); }
.chevrons li.is-now { color: #fff; background: linear-gradient(90deg, var(--chart-1), var(--chart-2)); }

/* Telegram chat */
.chat { padding: 0.6rem; border-radius: 12px; background: rgba(14, 30, 44, 0.55); box-shadow: 0 0 0 1px rgba(42, 171, 238, 0.18) inset; }
.chat__from { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.45rem; color: var(--sys-tg); font-weight: 600; }
.chat__ava { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; background: var(--sys-tg); }
.chat__ava svg { width: 13px; height: 13px; }
.chat__bubble { position: relative; padding: 0.5rem 0.65rem 0.95rem; border-radius: 4px 12px 12px 12px; background: rgba(42, 171, 238, 0.16); color: var(--text); line-height: 1.45; }
.chat__bubble time { position: absolute; right: 0.55rem; bottom: 0.25rem; font-size: 0.62rem; color: var(--text-dim); }
.station__cta { width: 100%; justify-content: center; gap: 0.5rem; margin-top: 0.6rem; background: linear-gradient(135deg, #2AABEE, #1D8FD0) !important; box-shadow: 0 0 24px -6px rgba(42, 171, 238, 0.7) !important; }
.station__cta svg { width: 16px; height: 16px; }
.station__msg { margin-top: 0.45rem; min-height: 1em; font-size: 0.72rem; color: var(--text-muted); line-height: 1.4; }
.station__msg:empty { display: none; }

/* ---------- the ERP hub ---------- */
.flow__hub { position: relative; display: grid; align-content: center; }
.station--hub { padding: 1.1rem 1.15rem 1rem; }
.station--hub .station__icon { width: 38px; height: 38px; border-radius: 11px; }
.station--hub .station__icon svg { width: 21px; height: 21px; }
.station--hub .station__name { font-size: 1.15rem; }
.station--hub.is-pulse { animation: hubPulse 0.7s var(--ease-out); }
@keyframes hubPulse {
  40% { box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.6), 0 0 60px -4px rgba(250, 204, 21, 0.55), 0 30px 60px -30px rgba(0, 0, 0, 0.9); }
}
.flow__platform { display: none; }

/* ---------- wires + packet (desktop) ---------- */
.wire__base { fill: none; stroke: color-mix(in srgb, var(--wc) 35%, transparent); stroke-width: 1.4; }
.wire__flow { fill: none; stroke: var(--wc); stroke-width: 1.8; stroke-linecap: round; stroke-dasharray: 1.5 14; opacity: 0.85; animation: wireFlow 1.6s linear infinite; filter: drop-shadow(0 0 3px var(--wc)); }
.wire__end { fill: var(--wc); filter: drop-shadow(0 0 4px var(--wc)); }
.wire--email { --wc: var(--sys-email); } .wire--excel { --wc: var(--sys-excel); } .wire--crm { --wc: var(--sys-crm); }
.wire--stock { --wc: var(--sys-stock); } .wire--np { --wc: var(--sys-np); } .wire--tg { --wc: var(--sys-tg); }
@keyframes wireFlow { to { stroke-dashoffset: -31; } }
.flow.is-paused .wire__flow { animation-play-state: paused; }
.packet__halo { fill: var(--c); opacity: 0.25; filter: blur(4px); }
.packet__core { fill: #fff; filter: drop-shadow(0 0 6px var(--c)) drop-shadow(0 0 12px var(--c)); }
.packet__tail { fill: var(--c); opacity: 0.6; }

/* ---------- track (all sizes) ---------- */
.flow__bar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.6rem 1.2rem;
  margin-top: 1.1rem;
}
.flow__track { position: relative; display: flex; justify-content: space-between; gap: 0.25rem; }
.flow__track::before { /* the line under the nodes */
  content: "";
  position: absolute;
  left: 22px;
  right: 22px;
  top: 21px;
  height: 1px;
  background: linear-gradient(90deg, var(--sys-email), var(--sys-excel), var(--sys-crm), var(--sys-erp), var(--sys-stock), var(--sys-np), var(--sys-tg));
  opacity: 0.45;
}
.flow__node {
  --c: var(--sys-crm);
  position: relative;
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  min-width: 44px;
  color: var(--text-dim);
  font-size: 0.7rem;
  font-weight: 600;
  transition: color var(--t-fast);
}
.flow__node svg {
  box-sizing: content-box;
  width: 18px;
  height: 18px;
  padding: 11px;
  border-radius: 50%;
  color: var(--c);
  background: var(--graphite);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 35%, transparent) inset;
  transition: box-shadow var(--t), background var(--t);
}
.flow__node:hover { color: var(--text); }
.flow__node.is-done svg { background: color-mix(in srgb, var(--c) 14%, var(--graphite)); }
.flow__node.is-active { color: #fff; }
.flow__node.is-active svg { background: color-mix(in srgb, var(--c) 22%, var(--graphite)); box-shadow: 0 0 0 1.5px var(--c) inset, 0 0 22px color-mix(in srgb, var(--c) 60%, transparent); }
.flow__node--email { --c: var(--sys-email); } .flow__node--excel { --c: var(--sys-excel); } .flow__node--crm { --c: var(--sys-crm); }
.flow__node--erp { --c: var(--sys-erp); } .flow__node--stock { --c: var(--sys-stock); } .flow__node--np { --c: var(--sys-np); } .flow__node--tg { --c: var(--sys-tg); }
.flow__packet {
  --c: var(--sys-email);
  position: absolute;
  left: -5px;
  top: -5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px 2px var(--c), 0 0 22px 6px color-mix(in srgb, var(--c) 50%, transparent);
  pointer-events: none;
  opacity: 0;
  transition: transform 0.62s var(--ease-in-out), box-shadow var(--t);
}
.flow:not(.is-paused) .flow__packet { opacity: 1; }
.flow__controls { display: flex; align-items: center; gap: 0.5rem; }
.flow__pp {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line-strong) !important;
  color: var(--text);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.flow__pp:hover { border-color: var(--amethyst); background: rgba(139, 92, 246, 0.12); }
.flow__pp svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.flow__pp .i-play { display: none; fill: currentColor; }
.flow.is-paused .flow__pp .i-play { display: block; }
.flow.is-paused .flow__pp .i-pause { display: none; }
.flow__status { grid-column: 1 / -1; min-height: 1.4em; font-size: var(--fs-small); color: var(--text-muted); text-align: center; }

/* ---------- desktop: hub in the middle, systems around, wires ---------- */
@media (min-width: 1080px) {
  .flow__stage { grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr) minmax(0, 1fr); gap: 4.2rem; align-items: stretch; }
  .flow__wires { display: block; }
  .flow__col { position: relative; z-index: 1; display: grid; grid-auto-rows: minmax(0, auto); gap: 1rem; align-content: space-between; }
  .flow__hub { z-index: 1; }
  .flow__platform {
    display: block;
    position: absolute;
    left: 6%;
    right: 6%;
    bottom: 6%;
    height: 42%;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(250, 204, 21, 0.28), rgba(250, 204, 21, 0.06) 60%, transparent);
    filter: blur(14px);
    transform: translateY(40%) scaleY(0.5);
    pointer-events: none;
  }
  .station--hub { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 0 0 1px rgba(250, 204, 21, 0.18), 0 0 50px -16px rgba(250, 204, 21, 0.35), 0 40px 80px -40px rgba(0, 0, 0, 0.95); }
  .flow__col { gap: 0.8rem; }
  .flow__col .station { min-height: 0; padding: 0.7rem 0.8rem 0.75rem; }
  .flow__col .station__body { font-size: 0.74rem; }
  .flow__col .station__head { margin-bottom: 0.5rem; }
  .flow__col .station__icon { width: 26px; height: 26px; border-radius: 8px; }
  /* compact rows so the whole conveyor fits a laptop screen; "done" texts go to the status line */
  .flow__col .station__done { display: none; }
  .flow__col .kv > div { padding: 0.26rem 0.55rem; }
  .flow__col .sheet table th, .flow__col .sheet table td { padding-block: 0.13rem; }
  .flow__col .sheet__qty input { min-height: 1.25rem; }
  .flow__col table.doc th, .flow__col table.doc td { padding-block: 0.26rem; }
  .flow__col .chevrons { margin-bottom: 0.45rem; }
  .flow__col .chat { padding: 0.5rem; }
  .flow__col .chat__from { margin-bottom: 0.3rem; }
  .flow__track { max-width: 780px; }
}

/* ---------- tablet & phone: one station at a time, the track drives it ---------- */
@media (max-width: 1079.98px) {
  /* All stations share one grid cell: the stage keeps the height of the tallest card,
     so switching stations never shifts the page under the visitor's finger. */
  .flow__stage { display: grid; grid-template-columns: minmax(0, 1fr); }
  .flow__col, .flow__hub { display: contents; }
  .station { grid-area: 1 / 1; visibility: hidden; opacity: 0; pointer-events: none; cursor: default; }
  .station.is-active { visibility: visible; opacity: 1; pointer-events: auto; animation: cardIn 0.45s var(--ease-out); }
  /* short Telegram card in the tall shared frame: chat on top, the button at the bottom, like a messenger */
  .station--tg .station__body { display: flex; flex-direction: column; }
  .station--tg .station__cta { margin-top: auto; }
  .station__body { font-size: 0.82rem; }
  .kv dd { white-space: normal; overflow-wrap: anywhere; }
  .flow__bar { grid-template-columns: 1fr; order: -1; }
  .flow { display: flex; flex-direction: column; }
  .flow__bar { margin: 0 0 1rem; }
  .flow__controls { justify-content: center; }
  .flow__status { min-height: 2.8em; }
  .sheet__letters, .sheet table tr { grid-template-columns: 1.6rem minmax(0, 1fr) 3.4rem 3.7rem 4.6rem; }
  .sheet__qty input { min-height: 2.1rem; font-size: 16px; } /* 16 px: no zoom on iOS */
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@media (max-width: 600px) {
  .flow__node span { display: none; }
  .flow__node { min-width: 0; }
  .flow__node svg { width: 16px; height: 16px; padding: 10px; }
  .flow__track::before { top: 18px; left: 18px; right: 18px; }
  .demo__tabs button { padding: 0.55rem 1rem; }
  .sheet__letters, .sheet table tr { grid-template-columns: 1.4rem minmax(0, 1fr) 2.8rem 3.8rem 4.2rem; }
  .sheet table th, .sheet table td { padding-inline: 0.3rem; }
  .kv > div { grid-template-columns: minmax(4.6rem, 36%) 1fr; }
}

/* ==========================================================================
   Dashboard
   ========================================================================== */
.dash {
  position: relative;
  padding: clamp(1rem, 0.6rem + 1.4vw, 1.6rem);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(60% 50% at 20% 0%, rgba(139, 92, 246, 0.16), transparent 70%),
    radial-gradient(50% 50% at 90% 100%, rgba(96, 165, 250, 0.1), transparent 70%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.012));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.dash__head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; margin-bottom: 1rem; }
.dash__title { font: 700 1.15rem / 1.2 var(--font-display); color: var(--text); }
.dash__live { display: inline-flex; align-items: center; gap: 0.4rem; font-size: var(--fs-label); color: var(--good); }
.dash__live i { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); animation: blink 1.6s ease-in-out infinite; }
.dash__badge { margin-left: auto; padding: 0.25rem 0.6rem; border-radius: 999px; font-size: var(--fs-label); font-weight: 600; color: var(--lavender); border: 1px dashed var(--line-strong); }

.dash__grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.5fr) minmax(0, 0.95fr);
  grid-template-areas:
    "funnel revenue retention"
    "funnel pulse leaders";
}
.dcard {
  position: relative;
  min-width: 0;
  padding: 1rem 1.05rem;
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.015));
  border: 1px solid rgba(225, 215, 255, 0.1);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
}
.dcard--funnel { grid-area: funnel; display: flex; flex-direction: column; }
.dcard--revenue { grid-area: revenue; }
.dcard--retention { grid-area: retention; text-align: center; }
.dcard--pulse { grid-area: pulse; }
.dcard--leaders { grid-area: leaders; }
.dcard__title { display: flex; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.8rem; font: 600 0.88rem / 1.25 var(--font-display); color: var(--text); }
.dcard__title small { font-weight: 500; font-size: 0.72rem; color: var(--text-dim); }
.dcard__k { font-size: 0.72rem; color: var(--text-dim); }

/* funnel */
.funnel { display: grid; gap: 5px; margin-bottom: 1rem; }
.dcard--funnel .funnel { flex: 1; align-content: center; gap: 8px; }
.funnel__row { display: grid; grid-template-columns: 52% 1fr auto; align-items: center; gap: 0.6rem; font-size: 0.78rem; }
.funnel__shape {
  display: grid;
  place-items: center;
  justify-self: center;
  width: calc(100% - var(--i) * 14%);
  height: 34px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 8px) 100%, 8px 100%);
  background: linear-gradient(90deg, color-mix(in srgb, var(--chart-1) calc(100% - var(--i) * 18%), var(--chart-2)), color-mix(in srgb, var(--chart-3) 40%, var(--chart-1)));
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.25);
  transform: scaleX(0.2);
  opacity: 0;
  transition: transform 0.8s var(--ease-out), opacity 0.8s;
  transition-delay: calc(var(--i) * 90ms);
}
.funnel__shape b { font: 700 0.8rem / 1 var(--font-display); color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4); }
.is-in .funnel__shape { transform: none; opacity: 1; }
.funnel__name { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.funnel__val { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.dtotals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; margin-top: auto; padding-top: 0.8rem; border-top: 1px solid var(--line); }
.dtotals__item { display: grid; gap: 0.15rem; }
.dtotals__item b { font: 700 1.05rem / 1.1 var(--font-display); color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dtotals__item--won b { color: #c4b5fd; }
.dtotals__item small { font-size: 0.68rem; color: var(--text-dim); }

/* kpis above the revenue chart */
.dkpis { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; margin: -0.3rem 0 0.4rem; }
.dkpis dt { display: flex; align-items: center; gap: 0.35rem; font-size: 0.7rem; color: var(--text-dim); }
.dkpis dd { font: 700 1.02rem / 1.2 var(--font-display); color: var(--text); font-variant-numeric: tabular-nums; }
.key { display: inline-block; width: 12px; }
.key--bar { height: 9px; border-radius: 2px; background: linear-gradient(var(--chart-2), var(--chart-1)); }
.key--line { height: 2px; background: var(--lavender); box-shadow: 0 0 4px var(--lavender); }

/* charts */
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { font: 500 10px var(--font-body); fill: var(--text-dim); }
.chart .axis--now { fill: var(--lavender); font-weight: 700; }
.chart .axis--val { fill: var(--text-muted); font-weight: 600; }
.chart rect[style*="--s"] {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: scaleY(0);
  transition: transform 0.9s var(--ease-out);
}
.is-in .chart rect[style*="--s"] { transform: scaleY(var(--s)); }
.chart .bar--plan rect { stroke: var(--chart-2); stroke-dasharray: 3 3; stroke-width: 1; opacity: 0.6; }
.chart .bar--now rect { filter: drop-shadow(0 0 8px rgba(96, 165, 250, 0.7)); }
.chart rect:hover { filter: brightness(1.25) drop-shadow(0 0 6px rgba(167, 139, 250, 0.7)); }
.chart .line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1.4s var(--ease-out) 0.3s; }
.is-in .chart .line { stroke-dashoffset: 0; }
.chart .line--target { stroke: var(--lavender); filter: drop-shadow(0 0 3px rgba(196, 181, 253, 0.6)); }
.chart .line--act { stroke: var(--chart-2); filter: drop-shadow(0 0 4px rgba(96, 165, 250, 0.7)); }
.chart .dot { fill: var(--graphite); stroke: var(--lavender); stroke-width: 2; }
.chart .dot--act { stroke: var(--chart-2); r: 4; }
.chart .dot--now { fill: #fff; filter: drop-shadow(0 0 6px var(--chart-2)); }
.chart .area { opacity: 0; transition: opacity 1s 0.6s; }
.is-in .chart .area { opacity: 1; }
.dpulse { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }

/* donut + rings */
.donut { position: relative; width: min(132px, 70%); margin: 0 auto 0.4rem; }
.donut svg { display: block; width: 100%; transform: rotate(-90deg); }
.donut__track, .ring__track { fill: none; stroke: rgba(196, 181, 253, 0.1); stroke-width: 10; }
.donut__arc { fill: none; stroke-width: 10; stroke-linecap: round; stroke-dasharray: 0 100; transition: stroke-dasharray 1.4s var(--ease-out); filter: drop-shadow(0 0 6px rgba(139, 92, 246, 0.6)); }
.is-in .donut__arc { stroke-dasharray: var(--p) 100; }
.donut__val { position: absolute; inset: 0; display: grid; place-items: center; font: 700 1.6rem / 1 var(--font-display); color: #fff; }
.chart--mini { margin-top: 0.2rem; }
.chart--mini .line { stroke-width: 1.8; }
.dlegend { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.3rem 0.9rem; margin-top: 0.4rem; font-size: 0.7rem; color: var(--text-muted); }
.dlegend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.dlegend i { width: 8px; height: 8px; border-radius: 50%; }

.dcycle { display: grid; grid-template-columns: auto 1fr; gap: 0.9rem; align-items: center; margin-bottom: 0.9rem; }
.dcycle .dcard__title { margin-bottom: 0.4rem; }
.ring { position: relative; width: 78px; }
.ring svg { display: block; width: 100%; transform: rotate(-90deg); }
.ring__track { stroke-width: 7; }
.ring__arc { fill: none; stroke: var(--chart-2); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 0 100; transition: stroke-dasharray 1.3s var(--ease-out) 0.2s; filter: drop-shadow(0 0 5px rgba(96, 165, 250, 0.6)); }
.is-in .ring__arc { stroke-dasharray: var(--p) 100; }
.ring b { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; font: 700 1.15rem / 1 var(--font-display); color: #fff; }
.ring b small { display: block; margin-top: 2px; font: 500 0.62rem / 1 var(--font-body); color: var(--text-dim); }
.ring--sm { display: inline-block; width: 46px; vertical-align: middle; }
.ring--sm b { font-size: 0.7rem; }
.ring--risk .ring__arc { stroke: var(--chart-3); filter: drop-shadow(0 0 4px rgba(244, 114, 182, 0.6)); }
.dcycle__risk { margin-left: 0.4rem; font-size: 0.7rem; color: var(--text-dim); }

/* leaderboard */
.leaders { display: grid; gap: 0.45rem; }
.leaders__row { display: grid; grid-template-columns: 1rem 24px minmax(3.5rem, auto) 1fr auto; align-items: center; gap: 0.5rem; font-size: 0.76rem; }
.leaders__rank { color: var(--text-dim); font-weight: 600; text-align: right; }
.leaders__ava { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-weight: 700; font-size: 0.7rem; color: #fff; background: linear-gradient(135deg, var(--chart-1), var(--chart-2)); }
.leaders__row:first-child .leaders__ava { box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.7), 0 0 12px rgba(250, 204, 21, 0.4); }
.leaders__name { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leaders__bar { height: 5px; border-radius: 3px; background: rgba(196, 181, 253, 0.08); overflow: hidden; }
.leaders__bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--chart-1), var(--chart-3)); transition: width 0.8s var(--ease-out); }
.leaders__val { font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* "your order was added" */
.dash__toast {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-size: var(--fs-small);
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.9), rgba(96, 165, 250, 0.85));
  box-shadow: var(--glow-violet);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t), transform var(--t) var(--ease-out);
  white-space: nowrap;
  max-width: calc(100% - 2rem);
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash__toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1079.98px) {
  .dash__grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "funnel revenue" "retention leaders" "pulse pulse";
  }
}
/* phone: cards side by side in a swipeable row — no long scroll */
@media (max-width: 700px) {
  .dash:not(.dash--stack) .dash__grid {
    display: flex;
    gap: 0.75rem;
    margin-inline: calc(-1 * clamp(1rem, 0.6rem + 1.4vw, 1.6rem));
    padding-inline: clamp(1rem, 0.6rem + 1.4vw, 1.6rem);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: clamp(1rem, 0.6rem + 1.4vw, 1.6rem);
    scrollbar-width: none;
  }
  .dash:not(.dash--stack) .dash__grid::-webkit-scrollbar { display: none; }
  .dash:not(.dash--stack) .dcard { flex: 0 0 86%; scroll-snap-align: start; }
  .dpulse { grid-template-columns: 1fr; gap: 0.6rem; }
  .dash__badge { margin-left: 0; }
}
.dash--stack .dash__grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "funnel" "revenue" "retention" "leaders" "pulse"; }

@media (prefers-reduced-motion: reduce) {
  .wire__flow, .station.is-active .station__state, .dash__live i { animation: none; }
  .station__body.is-filling .r { animation: none; }
  .funnel__shape, .chart rect[style*="--s"], .chart .line, .donut__arc, .ring__arc, .flow__packet { transition: none; }
}
