/* Supplier Intake Pipeline: one stylesheet for the overview page and the documentation.
   Colour carries meaning only: teal = main flow, amber = feedback loop, blue = a person decides, red = stopped, green = nothing to create. */
:root {
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #eaf0f4;
  --ink: #122230;
  --muted: #53687a;
  --line: #d5dfe6;
  --flow: #0d6b7a;
  --flow-soft: #e3f1f3;
  --loop: #b3590a;
  --loop-soft: #fdf0e1;
  --human: #2c5fd0;
  --human-soft: #e6eefc;
  --stop: #b3261e;
  --stop-soft: #fbe9e7;
  --ok: #1c7d4d;
  --ok-soft: #e3f4ea;
  --font-display: "Manrope", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1a24; --surface: #152633; --surface-2: #1b3040; --ink: #e6eef4; --muted: #93a8b8; --line: #2a4153;
    --flow: #4cc3d4; --flow-soft: #12343c; --loop: #f0a35a; --loop-soft: #3a2713;
    --human: #7fa6ff; --human-soft: #1c2d52; --stop: #ff8b80; --stop-soft: #3d1c19;
    --ok: #5bd394; --ok-soft: #14352a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1a24; --surface: #152633; --surface-2: #1b3040; --ink: #e6eef4; --muted: #93a8b8; --line: #2a4153;
  --flow: #4cc3d4; --flow-soft: #12343c; --loop: #f0a35a; --loop-soft: #3a2713;
  --human: #7fa6ff; --human-soft: #1c2d52; --stop: #ff8b80; --stop-soft: #3d1c19;
  --ok: #5bd394; --ok-soft: #14352a; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-display); font-size: 16px; line-height: 1.55; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; margin: 0; }
p { margin: 0; }
a { color: var(--flow); }
:focus-visible { outline: 2px solid var(--human); outline-offset: 2px; border-radius: 3px; }

/* top bar */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1120px; margin-inline: auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.top-sep { width: 1px; height: 22px; background: var(--line); }
.brand { font-weight: 800; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }

/* The P99 wordmark, as on p-99.ai: JetBrains Mono bold, white "P99", neon-green underscore that blinks like a terminal cursor.
   The brand's own colors are fixed on purpose (white needs a dark ground), so the mark sits on its own near-black chip and
   looks the same in the light and the dark theme. */
.p99 { display: inline-flex; align-items: baseline; padding: 2px 11px 4px; border-radius: 6px; background: #050505; color: #ffffff;
       font: 700 20px/28px "JetBrains Mono", ui-monospace, Consolas, monospace; letter-spacing: -0.05em; white-space: nowrap; }
.p99-cursor { color: #00ff41; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.wrap { max-width: 1120px; margin-inline: auto; padding: 40px 16px 56px; display: flex; flex-direction: column; gap: 44px; }
.eyebrow { font: 500 12px/1 var(--font-mono); letter-spacing: .09em; text-transform: uppercase; color: var(--flow); }
h1 { font-size: clamp(2rem, 4.4vw, 3.1rem); font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; }
.lede { font-size: 1.1rem; color: var(--muted); max-width: 68ch; }
.head { display: flex; flex-direction: column; gap: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: 500 12px/1 var(--font-mono); padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted); }
.sec { display: flex; flex-direction: column; gap: 16px; }
.cap { color: var(--muted); max-width: 74ch; }

/* flow diagram */
.diagram { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px 4px; }
.scroll { overflow-x: auto; }
.scroll svg { display: block; width: 100%; min-width: 980px; height: auto; }
.hint { display: none; font: 400 12px var(--font-mono); color: var(--muted); padding: 6px 10px 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 10px 12px 14px; border-top: 1px solid var(--line); margin-top: 6px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 18px; height: 0; border-top: 3px solid; display: inline-block; }
.legend i.dia { width: 11px; height: 11px; border: 2px solid var(--ink); transform: rotate(45deg); }
.lg-flow { border-color: var(--flow); } .lg-loop { border-color: var(--loop); border-top-style: dashed; } .lg-human { border-color: var(--human); }
.lg-stop { border-color: var(--stop); } .lg-ok { border-color: var(--ok); }

.n { fill: var(--surface); stroke-width: 1.6; }
.n-flow { stroke: var(--flow); } .n-stop { stroke: var(--stop); fill: var(--stop-soft); } .n-human { stroke: var(--human); fill: var(--human-soft); } .n-ok { stroke: var(--ok); fill: var(--ok-soft); }
.gate { fill: var(--surface); stroke: var(--ink); stroke-width: 2.2; }
.ln { fill: none; stroke-width: 2; }
.ln-flow { stroke: var(--flow); } .ln-loop { stroke: var(--loop); stroke-dasharray: 6 4; } .ln-human { stroke: var(--human); } .ln-stop { stroke: var(--stop); } .ln-ok { stroke: var(--ok); }
.mk-flow { fill: var(--flow); } .mk-loop { fill: var(--loop); } .mk-human { fill: var(--human); } .mk-stop { fill: var(--stop); } .mk-ok { fill: var(--ok); }
.t { fill: var(--ink); font: 700 14px var(--font-display); }
.t-lead { font-weight: 600; font-size: 13.5px; }
.s { fill: var(--muted); font: 400 11.5px var(--font-display); }
.g { fill: var(--ink); font: 600 12px var(--font-mono); letter-spacing: .04em; }
.l { font: 500 11px var(--font-mono); }
.l-flow { fill: var(--flow); } .l-loop { fill: var(--loop); } .l-human { fill: var(--human); } .l-stop { fill: var(--stop); } .l-ok { fill: var(--ok); }
.band { fill: var(--flow-soft); stroke: var(--flow); stroke-width: 1.4; stroke-dasharray: 7 5; }

/* live animation: driven by web/static/flow.js, which only toggles the is-active / is-done classes */
.flow-status { display: flex; align-items: center; gap: 10px; margin: 0; padding: 4px 10px 8px; font: 500 13px var(--font-mono); color: var(--muted); }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.flow-status.is-live .live-dot { background: var(--ok); animation: pulse 1.6s ease-in-out infinite; }
.flow-status.is-working { color: var(--ink); }
.lg-active { border-color: var(--flow); border-top-style: dashed; }

/* a working step: the solid border turns into dashes that circulate around it */
.node.is-active .n, .node.is-active .gate { stroke-dasharray: 9 6; stroke-width: 2.8; animation: march 1s linear infinite; }
.node.is-done .n, .node.is-done .gate { stroke-width: 2.8; }
.node.is-done .n-flow, .node.is-done .gate { fill: var(--flow-soft); }

/* an arrow between a finished step and the next one that has not started yet: dashes run along it, in its own direction */
.ln.is-active { stroke-width: 3.2; stroke-dasharray: 8 6; animation: flow .7s linear infinite; }

@keyframes march { to { stroke-dashoffset: -30; } }
@keyframes flow { to { stroke-dashoffset: -28; } }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) {
  .node.is-active .n, .node.is-active .gate, .ln.is-active, .flow-status.is-live .live-dot, .p99-cursor { animation: none; }
}

/* rules */
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.rules { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.rules h3 { font-size: 1.1rem; font-weight: 700; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rules h3 small { font: 500 12px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.rules ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.rules li { padding-left: 18px; position: relative; }
.rules li::before { content: ""; position: absolute; left: 0; top: .6em; width: 7px; height: 7px; border-radius: 50%; background: var(--flow); }
.rules .after { color: var(--muted); font-size: .95rem; border-top: 1px solid var(--line); padding-top: 14px; }

/* results */
.results { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 22px; }
.runmeta { font: 400 13px var(--font-mono); color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { display: flex; flex-direction: column; gap: 4px; padding-left: 14px; border-left: 3px solid var(--flow); }
.kpi b { font: 600 1.7rem/1.1 var(--font-mono); font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: .9rem; }
.barsvg { display: block; border-radius: 8px; overflow: hidden; }
.bar-t { fill: #fff; font: 500 12px var(--font-mono); }
.seg-matched { fill: var(--flow); } .seg-new { fill: var(--ok); } .seg-rejected { fill: var(--stop); } .seg-pending { fill: var(--human); }
.barkey { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 13px; color: var(--muted); margin-top: -10px; }
.empty { border: 1px dashed var(--line); border-radius: 10px; padding: 18px; color: var(--muted); }
.empty code { font-family: var(--font-mono); font-size: .9em; color: var(--ink); }
.stopped-title { font: 500 12px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: -12px; }
.stopped { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: .94rem; }
.stopped li { display: grid; grid-template-columns: minmax(0, 18rem) minmax(0, 1fr); gap: 4px 16px; }
.stopped b { font: 500 12.5px var(--font-mono); overflow-wrap: anywhere; }
.stopped span { color: var(--muted); overflow-wrap: anywhere; }
.found { display: flex; flex-direction: column; gap: 14px; }
.found h3 { font-size: 1.05rem; font-weight: 700; }
.found ol { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 10px; max-width: 80ch; }
.found li::marker { font-family: var(--font-mono); color: var(--loop); font-weight: 600; }
.note { font-size: .92rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; }

.needs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 24px; margin: 0; padding: 0; list-style: none; }
.needs li { padding-top: 12px; border-top: 2px solid var(--line); }
.needs b { display: block; margin-bottom: 2px; }
.needs span { color: var(--muted); font-size: .94rem; }
.foot { color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); padding-top: 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; }
.foot-by { display: inline-flex; align-items: center; gap: 8px; }
.p99-sm { font-size: 14px; line-height: 20px; padding: 1px 8px 3px; border-radius: 5px; }

@media (max-width: 860px) {
  .two { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .needs { grid-template-columns: minmax(0, 1fr); }
  .stopped li { grid-template-columns: minmax(0, 1fr); }
  .hint { display: block; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
