/* Self-hosted variable fonts (SIL Open Font License, see fonts/). Each family is
   split into Latin and Latin Extended files; the browser only downloads the
   ones the page uses. Latin Extended holds the rupee sign. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("./fonts/playfair-display-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("./fonts/playfair-display-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;
  --ink: #1c1613;
  --muted: #6f655a;
  --line: #ece3d7;
  --surface: #ffffff;
  --soft: #faf5ec;
  --card: rgba(255, 255, 255, 0.86);
  --field: #ffffff;
  --accent: #b8324a;
  --accent-2: #0f8b8d;
  --gold: #c7922f;
  --green: #267a55;
  --blue: #3366cc;
  --shadow: 0 22px 60px rgba(38, 26, 16, 0.1);
  --shadow-soft: 0 14px 42px rgba(24, 32, 42, 0.06);
  --spot: rgba(199, 146, 47, 0.13);
  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --card-radius: 18px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f3ede3;
  --muted: #a89e91;
  --line: #2e2721;
  --surface: #1a1512;
  --soft: #211b17;
  --card: rgba(26, 21, 18, 0.86);
  --field: #1a1512;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.5);
  --shadow-soft: 0 14px 42px rgba(0, 0, 0, 0.28);
  --spot: rgba(243, 201, 103, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(15, 139, 141, 0.07), transparent 30rem),
    radial-gradient(circle at 10% 10%, rgba(199, 146, 47, 0.06), transparent 26rem),
    linear-gradient(135deg, #fffdfa 0%, #f7f1e6 100%);
  background-attachment: fixed;
  transition: background 180ms ease, color 180ms ease;
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at top right, rgba(15, 139, 141, 0.14), transparent 30rem),
    radial-gradient(circle at 10% 10%, rgba(199, 146, 47, 0.08), transparent 26rem),
    linear-gradient(135deg, #100c0a 0%, #191410 100%);
  background-attachment: fixed;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

/* ---------- Scroll progress ---------- */

.scroll-progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 60;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--gold), var(--accent-2));
  transform: scaleX(0);
  transform-origin: 0 50%;
  pointer-events: none;
}

@supports (animation-timeline: scroll()) {
  .scroll-progress {
    animation: progress-grow linear both;
    animation-timeline: scroll(root);
  }
}

@keyframes progress-grow {
  to {
    transform: scaleX(1);
  }
}

/* ---------- Layout and sidebar ---------- */

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 22px;
  background:
    radial-gradient(circle at 0% 0%, rgba(184, 50, 74, 0.28), transparent 18rem),
    radial-gradient(circle at 100% 100%, rgba(15, 139, 141, 0.22), transparent 16rem),
    #111820;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  box-shadow: 0 10px 24px rgba(184, 50, 74, 0.35);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
}

.brand div > strong,
.brand div > span {
  display: block;
}

.brand strong {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.brand div > span {
  color: #abb4c0;
  font-size: 13px;
  margin-top: 2px;
}

.palette-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 10px 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  font-size: 13px;
  text-align: left;
  transition: background 180ms ease, border-color 180ms ease;
}

.palette-trigger:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.24);
}

.palette-trigger svg {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.palette-trigger span {
  flex: 1;
}

kbd {
  padding: 2px 7px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.nav-list {
  position: relative;
  display: grid;
  gap: 6px;
}

.nav-indicator {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(184, 50, 74, 0.38), rgba(255, 255, 255, 0.08));
  box-shadow: inset 3px 0 0 #f2c46b;
  pointer-events: none;
}

.nav-list.ready .nav-indicator {
  transition: transform 420ms var(--ease-out), width 420ms var(--ease-out), height 420ms var(--ease-out);
}

.nav-list a {
  position: relative;
  z-index: 1;
  color: #cbd5e1;
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 10px;
  transition: color 180ms ease;
}

.nav-list a:hover,
.nav-list a.active {
  color: #fff;
}

.theme-toggle {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #e8edf4;
  font-size: 13px;
  font-weight: 700;
  transition: background 180ms ease, transform 180ms ease;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 500ms var(--ease-spring), opacity 300ms ease;
}

.theme-toggle .icon-sun,
:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
  animation: spin-in 600ms var(--ease-spring);
}

:root:not([data-theme="dark"]) .theme-toggle .icon-moon {
  animation: spin-in 600ms var(--ease-spring);
}

.story-card {
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--card-radius);
  background: rgba(255, 255, 255, 0.06);
}

.story-card span,
.eyebrow,
.panel-head > div > span,
.kpi-card > span {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 12px;
  font-weight: 800;
}

.story-card span {
  color: #f2c46b;
}

.story-card p {
  color: #d6dde7;
  line-height: 1.55;
  margin: 10px 0 0;
  font-size: 14px;
}

.main {
  padding: 32px;
  display: grid;
  gap: 22px;
  min-width: 0;
}

/* ---------- Hero ---------- */

.hero {
  --px: 0;
  --py: 0;
  position: relative;
  isolation: isolate;
  min-height: 340px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  align-items: end;
  gap: 24px;
  padding: 38px;
  border-radius: var(--card-radius);
  overflow: hidden;
  background: #111820;
  color: white;
  box-shadow: var(--shadow);
  animation: rise 620ms var(--ease-out) both;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -24px;
  z-index: -2;
  background: url("./hero-textile.jpg") center/cover;
  transform: translate(calc(var(--px) * -14px), calc(var(--py) * -10px)) scale(1.06);
  transition: transform 600ms var(--ease-out);
  animation: drift 26s ease-in-out infinite alternate;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(100deg, rgba(17, 24, 32, 0.92) 0%, rgba(17, 24, 32, 0.66) 48%, rgba(60, 14, 24, 0.35) 100%);
}

/* A slow band of light sweeping across, like sheen on silk. */
.hero-sheen {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(115deg, transparent 32%, rgba(255, 228, 180, 0.16) 44%, rgba(255, 255, 255, 0.07) 50%, transparent 62%);
  background-size: 260% 100%;
  mix-blend-mode: screen;
  pointer-events: none;
  animation: sheen 8s ease-in-out 1.2s infinite;
}

.hero-text {
  min-width: 0;
}

.eyebrow {
  color: #f3c967;
  margin: 0 0 14px;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  max-width: 880px;
  margin: 0;
  font-size: clamp(32px, 5vw, 60px);
  line-height: 1.08;
  letter-spacing: 0.2px;
}

.hero h1 .word {
  display: inline-block;
  animation: word-in 900ms var(--ease-out) both;
  animation-delay: calc(var(--i) * 70ms + 150ms);
}

.hero-copy {
  max-width: 760px;
  color: #e8edf4;
  line-height: 1.6;
  margin: 18px 0 0;
  font-size: 17px;
  animation: fade-up 800ms var(--ease-out) 650ms both;
}

.data-note {
  display: inline-block;
  margin: 16px 0 0;
  padding: 6px 12px;
  border: 1px solid rgba(243, 201, 103, 0.55);
  border-radius: 999px;
  background: rgba(17, 24, 32, 0.45);
  color: #f3c967;
  font-size: 13px;
  font-weight: 600;
  animation: fade-up 800ms var(--ease-out) 800ms both;
}

.hero-panel {
  position: relative;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--card-radius);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(14px);
  transform: translate(calc(var(--px) * 10px), calc(var(--py) * 8px));
  transition: transform 600ms var(--ease-out);
  animation: fade-up 800ms var(--ease-out) 500ms both;
}

.ring {
  width: 150px;
  height: 150px;
  transform: rotate(-90deg);
}

.ring circle {
  fill: none;
  stroke-width: 9;
}

.ring-track {
  stroke: rgba(255, 255, 255, 0.14);
}

.ring-fill {
  --value: 0;
  stroke: #5ff0a8;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - var(--value));
  filter: drop-shadow(0 0 6px rgba(95, 240, 168, 0.55));
  transition: stroke-dashoffset 1600ms var(--ease-out) 600ms;
}

.ring-label {
  position: absolute;
  top: 22px;
  width: 150px;
  height: 150px;
  display: grid;
  place-content: center;
  text-align: center;
}

.ring-label strong {
  font-family: var(--font-display);
  font-size: 38px;
  line-height: 1;
}

.ring-label span {
  max-width: 110px;
  margin-top: 4px;
  color: #e8edf4;
  font-size: 11px;
  line-height: 1.3;
}

/* ---------- Filters ---------- */

.filters {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: var(--card-radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.filter-fields {
  display: grid;
  grid-template-columns: repeat(6, minmax(125px, 1fr)) auto;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  padding: 0 12px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

input:hover,
select:hover {
  border-color: color-mix(in srgb, var(--accent-2) 45%, var(--line));
}

input:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.18);
}

#resetFilters {
  align-self: end;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid #111820;
  border-radius: 10px;
  background: #111820;
  color: #fff;
  font-weight: 700;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

#resetFilters:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(17, 24, 32, 0.18);
}

:root[data-theme="dark"] #resetFilters {
  border-color: var(--gold);
  background: var(--gold);
  color: #1a1512;
}

.filter-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.presets {
  position: relative;
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
}

.presets button {
  position: relative;
  z-index: 1;
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  transition: color 200ms ease;
}

.presets button[aria-pressed="true"] {
  color: #fff;
}

.preset-pill {
  position: absolute;
  top: 4px;
  left: 0;
  height: calc(100% - 8px);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #8e2438);
  box-shadow: 0 6px 16px rgba(184, 50, 74, 0.3);
  opacity: 0;
}

.preset-pill.visible {
  opacity: 1;
}

.presets.ready .preset-pill {
  transition: transform 420ms var(--ease-out), width 420ms var(--ease-out), opacity 200ms ease;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 8px 0 12px;
  border: 1px solid color-mix(in srgb, var(--accent-2) 35%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-2) 10%, var(--surface));
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  animation: chip-in 380ms var(--ease-spring) both;
  transition: background 180ms ease, border-color 180ms ease;
}

.chip span {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent-2) 18%, transparent);
  font-size: 14px;
  line-height: 1;
}

.chip:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.filter-hint {
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.filters.has-chips .filter-hint {
  display: none;
}

/* ---------- Cards ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.kpi-card,
.panel {
  position: relative;
  isolation: isolate;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-soft);
  transition:
    transform 420ms var(--ease-out),
    box-shadow 420ms var(--ease-out),
    opacity 620ms var(--ease-out),
    background 180ms ease;
  transition-delay: 0ms, 0ms, var(--reveal-delay, 0ms), 0ms;
}

/* Cursor spotlight */
.kpi-card::before,
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: radial-gradient(380px circle at var(--mx, 50%) var(--my, 50%), var(--spot), transparent 45%);
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
}

.kpi-card:hover::before,
.panel:hover::before {
  opacity: 1;
}

.kpi-card:hover,
.panel:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 52px rgba(38, 26, 16, 0.12);
}

.reveal:not(.in-view) {
  opacity: 0;
  transform: translateY(22px) scale(0.985);
  /* Pure-CSS safety net: if IntersectionObserver never fires (e.g. page
     loaded in a backgrounded tab), force the card visible after 2.5s so
     content can never be stuck invisible with no JS involved. */
  animation: reveal-fallback 1ms 2.5s forwards;
}

.kpi-card {
  container-type: inline-size;
  padding: 20px;
  min-height: 172px;
  display: grid;
  align-content: space-between;
  gap: 6px;
  overflow: hidden;
}

.kpi-card::after {
  content: "";
  position: absolute;
  inset: auto 16px 0 auto;
  width: 72px;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px 99px 0 0;
}

.kpi-card > span,
.panel-head > div > span {
  color: var(--muted);
}

.kpi-card strong {
  font-family: var(--font-display);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: clamp(24px, 14cqi, 42px);
  line-height: 1.15;
  letter-spacing: 0;
  white-space: nowrap;
}

.kpi-card strong.bump {
  animation: bump 650ms var(--ease-out);
}

.spark {
  width: 100%;
  height: 36px;
  overflow: visible;
  color: var(--accent-2);
}

.kpi-card:nth-child(2) .spark {
  color: var(--accent);
}

.kpi-card:nth-child(3) .spark {
  color: var(--gold);
}

.kpi-card:nth-child(4) .spark {
  color: var(--blue);
}

.spark-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.spark-dot {
  fill: currentColor;
  stroke: var(--surface);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.spark.draw {
  animation: spark-reveal 1100ms var(--ease-out) both;
}

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

.kpi-card small {
  color: var(--muted);
}

.delta {
  flex: none;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.delta:empty {
  display: none;
}

.delta.up {
  color: #17613f;
  background: #dbf5e8;
}

.delta.down {
  color: #8c2638;
  background: #ffe1e7;
}

.delta.flat {
  color: var(--muted);
  background: var(--soft);
}

:root[data-theme="dark"] .delta.up {
  color: #7fe0ae;
  background: rgba(38, 122, 85, 0.22);
}

:root[data-theme="dark"] .delta.down {
  color: #ff9db0;
  background: rgba(184, 50, 74, 0.22);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  min-width: 0;
  padding: 20px;
}

.wide {
  width: 100%;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 14px;
}

.panel-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 4px 0 0;
  font-size: 21px;
  letter-spacing: 0;
}

.click-hint {
  flex: none;
  padding: 4px 10px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 250ms ease, transform 250ms ease;
}

.panel:hover .click-hint {
  opacity: 1;
  transform: none;
}

.chart-wrap {
  position: relative;
  height: 310px;
  min-height: 250px;
}

.chart-wrap.tall {
  height: 350px;
}

/* ---------- Live pipeline ---------- */

.pipeline-callout {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.pipeline-callout strong {
  color: var(--accent);
}

.pulse-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(184, 50, 74, 0.6);
  animation: pulse-accent 1.8s infinite;
}

.pipeline {
  --orb: 72px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 0;
  padding: 10px 0 4px;
  list-style: none;
}

/* The track, with dashes flowing toward delivery. */
.pipeline::before {
  content: "";
  position: absolute;
  top: calc(10px + 22px + var(--orb) / 2);
  left: 6%;
  right: 6%;
  height: 4px;
  border-radius: 99px;
  background:
    repeating-linear-gradient(90deg, var(--accent-2) 0 10px, transparent 10px 24px),
    color-mix(in srgb, var(--accent-2) 14%, transparent);
  background-size: 24px 100%, 100% 100%;
  animation: flow 1.1s linear infinite;
}

.stage {
  position: relative;
  min-width: 0;
  animation: pop-in 620ms var(--ease-spring) both;
  animation-delay: calc(var(--i) * 60ms);
}

.stage-node {
  display: grid;
  justify-items: center;
  gap: 6px;
  width: 100%;
  padding: 0 4px 6px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  text-align: center;
}

button.stage-node:hover .stage-orb {
  transform: translateY(-4px) scale(1.06);
}

.stage-index {
  display: grid;
  place-items: center;
  width: 22px;
  height: 16px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.stage-orb {
  --fill: 0;
  position: relative;
  display: grid;
  place-items: center;
  width: var(--orb);
  height: var(--orb);
  overflow: hidden;
  border: 2px solid color-mix(in srgb, var(--accent-2) 40%, var(--line));
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(15, 139, 141, 0.12);
  transition: transform 400ms var(--ease-spring), box-shadow 300ms ease;
}

/* Liquid fill, proportional to the stage's share of active orders. */
.stage-orb::before {
  content: "";
  position: absolute;
  inset: auto -20% 0;
  height: calc(var(--fill) * 100%);
  min-height: 0;
  background: linear-gradient(180deg, rgba(15, 139, 141, 0.3), rgba(15, 139, 141, 0.55));
  border-radius: 40% 45% 0 0;
  animation: wave 4s ease-in-out infinite;
  transition: height 900ms var(--ease-out);
}

.stage-orb b {
  position: relative;
  font-family: var(--font-display);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.stage-name {
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.25;
}

.stage-wait {
  color: var(--muted);
  font-size: 11.5px;
}

.stage.empty .stage-orb {
  border-style: dashed;
  opacity: 0.7;
}

.stage.bottleneck .stage-orb {
  border-color: var(--accent);
  box-shadow: 0 0 0 0 rgba(184, 50, 74, 0.5), 0 12px 28px rgba(184, 50, 74, 0.25);
  animation: pulse-accent 2.2s infinite;
}

.stage.bottleneck .stage-orb::before {
  background: linear-gradient(180deg, rgba(184, 50, 74, 0.32), rgba(184, 50, 74, 0.6));
}

.stage.bottleneck .stage-name {
  color: var(--accent);
}

.stage.final .stage-orb {
  border-color: var(--green);
  background: linear-gradient(135deg, #2f8f63, var(--green));
  color: #fff;
}

.stage.final .stage-orb::before {
  display: none;
}

.stage.selected .stage-orb {
  outline: 3px solid var(--accent-2);
  outline-offset: 4px;
}

/* ---------- Preferences ---------- */

.preference-grid {
  display: grid;
  gap: 14px;
}

.pref-block {
  padding: 14px;
  background: var(--soft);
  border-radius: var(--card-radius);
  border: 1px solid var(--line);
}

.pref-block strong {
  display: block;
  margin-bottom: 10px;
}

.pref-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  margin: 8px 0;
}

.bar {
  height: 8px;
  background: #e4e8ef;
  border-radius: 99px;
  overflow: hidden;
}

:root[data-theme="dark"] .bar {
  background: #362c25;
}

.bar i {
  display: block;
  height: 100%;
  width: var(--w);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--gold));
  transform-origin: left;
  animation: grow-x 900ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}

/* ---------- Tables ---------- */

.search {
  width: min(320px, 100%);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-secondary {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
  transition: border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.btn-secondary:hover {
  border-color: var(--accent-2);
  color: var(--accent-2);
  transform: translateY(-1px);
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.table-footer span {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f5f9;
  color: #4d5868;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

th[data-sort] {
  cursor: pointer;
  user-select: none;
}

th[data-sort]:hover {
  color: var(--ink);
}

th[data-sort]:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: -2px;
  color: var(--ink);
}

th[data-sort] .sort-arrow {
  margin-left: 5px;
  font-size: 10px;
  opacity: 0.45;
}

th[data-sort].sorted .sort-arrow {
  opacity: 1;
  color: var(--accent-2);
}

td {
  font-size: 14px;
  transition: background 150ms ease;
}

td small {
  color: var(--muted);
}

tr:hover td {
  background: #fafbfe;
}

tr.row-in {
  animation: row-in 420ms var(--ease-out) both;
  animation-delay: calc(var(--i) * 28ms);
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  white-space: normal;
}

:root[data-theme="dark"] th {
  background: #211b17;
  color: #bfb2a1;
}

:root[data-theme="dark"] tr:hover td {
  background: #211b17;
}

.order-link,
.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-weight: 800;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  transition: color 150ms ease, text-decoration-color 150ms ease;
}

.link {
  font-weight: 600;
  color: inherit;
}

.order-link:hover,
.link:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.person {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  text-align: left;
}

.person strong {
  transition: color 150ms ease;
}

.person:hover strong {
  color: var(--accent);
}

.avatar {
  --h: 340;
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, hsl(var(--h) 55% 52%), hsl(calc(var(--h) + 40) 60% 42%));
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 4px 10px hsl(var(--h) 50% 40% / 0.3);
}

.avatar.large {
  width: 64px;
  height: 64px;
  font-size: 22px;
}

.cell-num {
  display: inline-block;
  min-width: 38px;
}

.mini-bar {
  display: inline-block;
  width: 60px;
  height: 6px;
  margin-left: 8px;
  vertical-align: middle;
  border-radius: 99px;
  background: var(--soft);
  overflow: hidden;
}

.mini-bar i {
  display: block;
  height: 100%;
  width: var(--w);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--gold));
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.progress::before {
  animation: blink 1.6s ease-in-out infinite;
}

.badge.delivered {
  color: #17613f;
  background: #dbf5e8;
}

.badge.progress {
  color: #8a5a00;
  background: #fff1cd;
}

.badge.hold,
.badge.cancelled {
  color: #8c2638;
  background: #ffe1e7;
}

:root[data-theme="dark"] .badge.delivered {
  color: #7fe0ae;
  background: rgba(38, 122, 85, 0.22);
}

:root[data-theme="dark"] .badge.progress {
  color: #f3c967;
  background: rgba(199, 146, 47, 0.18);
}

:root[data-theme="dark"] .badge.hold,
:root[data-theme="dark"] .badge.cancelled {
  color: #ff9db0;
  background: rgba(184, 50, 74, 0.22);
}

.data-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.data-strip div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--surface);
  transition: opacity 620ms var(--ease-out), transform 620ms var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

.data-strip strong,
.data-strip span {
  display: block;
}

.data-strip strong {
  font-size: 24px;
}

.data-strip span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

/* ---------- Drawer ---------- */

dialog {
  color: var(--ink);
}

.drawer {
  width: min(480px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -30px 0 80px rgba(17, 24, 32, 0.25);
}

.drawer[open] {
  animation: drawer-in 480ms var(--ease-out);
}

.drawer.closing {
  animation: drawer-out 260ms ease-in forwards;
}

.drawer::backdrop,
.palette::backdrop {
  background: rgba(17, 24, 32, 0.42);
  backdrop-filter: blur(4px);
  animation: fade-in 300ms ease;
}

.drawer.closing::backdrop,
.palette.closing::backdrop {
  animation: fade-out 240ms ease forwards;
}

.drawer-inner {
  position: relative;
  height: 100%;
  overflow-y: auto;
  padding: 28px 26px 40px;
}

.drawer-close {
  position: sticky;
  top: 0;
  float: right;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: -6px -8px 0 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  transition: transform 300ms var(--ease-spring), border-color 180ms ease;
}

.drawer-close:hover {
  transform: rotate(90deg);
  border-color: var(--accent);
}

.drawer-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.drawer-head .eyebrow {
  color: var(--accent);
  margin-bottom: 8px;
}

.drawer-head h2:focus {
  outline: none;
}

.drawer-head h2 {
  margin: 0 40px 12px 0;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.15;
}

.person-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tag.accent {
  border-color: color-mix(in srgb, var(--green) 40%, transparent);
  color: var(--green);
}

:root[data-theme="dark"] .tag.accent {
  color: #7fe0ae;
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 22px 0 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--line);
}

.facts div {
  padding: 12px 14px;
  background: var(--surface);
}

.facts dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.facts dd {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 600;
}

.drawer-section {
  margin: 28px 0 14px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
}

.drawer-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.timeline {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The connecting line draws downward as the drawer opens. */
.timeline::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 10px;
  width: 2px;
  background: linear-gradient(var(--accent-2), var(--gold));
  transform-origin: top;
  animation: grow-y 1200ms var(--ease-out) 200ms both;
}

.timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 14px;
  padding: 0 0 18px;
  animation: fade-up 520ms var(--ease-out) both;
  animation-delay: calc(var(--i) * 90ms + 200ms);
}

.timeline .dot {
  position: relative;
  z-index: 1;
  width: 22px;
  height: 22px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 2px var(--accent-2);
}

.timeline li > div {
  display: grid;
  gap: 2px;
  font-size: 13px;
}

.timeline strong {
  font-size: 15px;
}

.timeline span,
.timeline time {
  color: var(--muted);
}

.timeline em {
  justify-self: start;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--soft);
  color: var(--ink);
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
}

.timeline .next .dot {
  background: var(--gold);
  box-shadow: 0 0 0 2px var(--gold);
  animation: pulse-gold 1.6s infinite;
}

.timeline .next strong {
  color: var(--gold);
}

.timeline .todo {
  opacity: 0.45;
}

.timeline .todo .dot {
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--line);
}

.timeline .cancelled .dot,
.timeline .hold .dot {
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.timeline .cancelled em,
.timeline .hold em {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.stat-row div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--soft);
}

.stat-row b {
  display: block;
  font-family: var(--font-display);
  font-size: 20px;
}

.stat-row span {
  color: var(--muted);
  font-size: 12px;
}

.stage-bars .pref-row {
  grid-template-columns: 140px minmax(0, 1fr) 40px;
}

.recent-orders {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recent-orders button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  transition: border-color 180ms ease, transform 250ms var(--ease-out);
}

.recent-orders button:hover {
  border-color: var(--accent-2);
  transform: translateX(4px);
}

.recent-orders span:not(.badge) {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Command palette ---------- */

.palette {
  width: min(640px, calc(100vw - 32px));
  max-height: min(560px, 80vh);
  margin: 12vh auto auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 40px 100px rgba(17, 24, 32, 0.35);
}

.palette[open] {
  animation: palette-in 320ms var(--ease-spring);
}

.palette.closing {
  animation: palette-out 200ms ease-in forwards;
}

.palette-input {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--line);
}

.palette-input svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
}

.palette-input input {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 17px;
}

.palette-input input:focus-visible {
  box-shadow: none;
}

.palette-input kbd {
  border-color: var(--line);
  color: var(--muted);
}

.palette-list {
  max-height: min(460px, 64vh);
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  list-style: none;
}

.palette-group {
  padding: 10px 10px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.palette-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.palette-option small {
  color: var(--muted);
  white-space: nowrap;
}

.palette-option[aria-selected="true"] {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  box-shadow: inset 3px 0 0 var(--accent);
}

.palette-empty {
  padding: 28px 12px;
  color: var(--muted);
  text-align: center;
}

/* ---------- Theme switch ---------- */

.theme-transition * {
  transition: none !important;
}

.theme-transition::view-transition-old(root),
.theme-transition::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

.theme-transition::view-transition-new(root) {
  animation: theme-reveal 700ms cubic-bezier(0.65, 0, 0.35, 1);
}

/* ---------- Keyframes ---------- */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

@keyframes word-in {
  from {
    opacity: 0;
    transform: translateY(0.45em) rotate(2deg);
    filter: blur(8px);
  }
}

@keyframes drift {
  to {
    background-position: 60% 40%;
    scale: 1.05;
  }
}

@keyframes sheen {
  0% {
    background-position: 130% 0;
  }
  55%,
  100% {
    background-position: -30% 0;
  }
}

@keyframes pulse-accent {
  70% {
    box-shadow: 0 0 0 12px rgba(184, 50, 74, 0), 0 12px 28px rgba(184, 50, 74, 0.25);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(184, 50, 74, 0), 0 12px 28px rgba(184, 50, 74, 0.25);
  }
}

@keyframes pulse-gold {
  0% {
    box-shadow: 0 0 0 2px var(--gold), 0 0 0 2px rgba(199, 146, 47, 0.5);
  }
  70% {
    box-shadow: 0 0 0 2px var(--gold), 0 0 0 12px rgba(199, 146, 47, 0);
  }
  100% {
    box-shadow: 0 0 0 2px var(--gold), 0 0 0 2px rgba(199, 146, 47, 0);
  }
}

@keyframes reveal-fallback {
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes spark-reveal {
  from {
    clip-path: inset(-10% 100% -10% 0);
  }
  to {
    clip-path: inset(-10% -4% -10% 0);
  }
}

@keyframes bump {
  30% {
    color: var(--accent);
    transform: translateY(-2px);
  }
}

@keyframes chip-in {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
}

@keyframes flow {
  to {
    background-position: 24px 0, 0 0;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.92);
  }
}

@keyframes wave {
  50% {
    transform: translateX(6%) rotate(2deg);
  }
}

@keyframes grow-x {
  from {
    transform: scaleX(0);
  }
}

@keyframes grow-y {
  from {
    transform: scaleY(0);
  }
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes blink {
  50% {
    opacity: 0.3;
  }
}

@keyframes spin-in {
  from {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
  }
}

@keyframes drawer-in {
  from {
    transform: translateX(100%);
  }
}

@keyframes drawer-out {
  to {
    transform: translateX(100%);
  }
}

@keyframes palette-in {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.97);
  }
}

@keyframes palette-out {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}

@keyframes theme-reveal {
  from {
    clip-path: circle(0 at var(--vt-x, 50%) var(--vt-y, 50%));
  }
  to {
    clip-path: circle(var(--vt-r, 150%) at var(--vt-x, 50%) var(--vt-y, 50%));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .reveal:not(.in-view) {
    opacity: 1;
    transform: none;
  }

  .hero::before,
  .hero-panel,
  .kpi-card:hover,
  .panel:hover,
  #resetFilters:hover,
  .btn-secondary:hover {
    transform: none;
  }

  .scroll-progress {
    display: none;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: static;
    min-width: 0;
    height: auto;
    overflow: visible;
  }

  .nav-list {
    min-width: 0;
  }

  .nav-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-list a {
    text-align: center;
  }

  .nav-indicator {
    box-shadow: inset 0 -3px 0 #f2c46b;
  }

  .theme-toggle {
    margin-top: 0;
  }

  .filter-fields,
  .kpi-grid,
  .data-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid.two,
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    justify-self: start;
  }

  .pipeline {
    --orb: 60px;
  }
}

@media (max-width: 680px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .hero {
    min-height: auto;
    padding: 24px;
  }

  .filter-fields,
  .kpi-grid,
  .data-strip {
    grid-template-columns: 1fr;
  }

  .sidebar {
    gap: 16px;
  }

  /* Sections become a swipeable row so the content starts sooner. */
  .nav-list {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    margin: 0 -18px;
    padding: 0 18px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-list a {
    padding: 10px 14px;
    white-space: nowrap;
  }

  .story-card p {
    font-size: 13px;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .click-hint {
    display: none;
  }

  .filter-hint {
    margin-left: 0;
  }

  .chart-wrap,
  .chart-wrap.tall {
    height: 280px;
  }

  .pref-row,
  .stage-bars .pref-row {
    grid-template-columns: 96px minmax(0, 1fr) 36px;
  }

  /* The pipeline turns into a vertical list. */
  .pipeline {
    --orb: 54px;
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .pipeline::before {
    top: 12px;
    bottom: 12px;
    left: calc(26px + var(--orb) / 2);
    right: auto;
    width: 4px;
    height: auto;
    background:
      repeating-linear-gradient(180deg, var(--accent-2) 0 10px, transparent 10px 24px),
      color-mix(in srgb, var(--accent-2) 14%, transparent);
    background-size: 100% 24px, 100% 100%;
    animation-name: flow-down;
  }

  .stage-node {
    grid-template-columns: 22px var(--orb) minmax(0, 1fr);
    grid-template-rows: auto auto;
    justify-items: start;
    align-items: center;
    column-gap: 14px;
    row-gap: 0;
    text-align: left;
  }

  .stage-index {
    grid-row: span 2;
  }

  .stage-orb {
    grid-row: span 2;
  }

  .stage-name {
    align-self: end;
    font-size: 14px;
  }

  .stage-wait {
    align-self: start;
  }

  .facts,
  .stat-row {
    grid-template-columns: 1fr 1fr;
  }

  .stat-row div:last-child {
    grid-column: span 2;
  }

  .drawer-inner {
    padding: 22px 18px 32px;
  }
}

@keyframes flow-down {
  to {
    background-position: 0 24px, 0 0;
  }
}
