/* =====================================================================
   EP Base UI · CHARTS — pure CSS/JS (no chart library).
   Ported from Acreon: conic-gradient donut, width-% bars, funnel bars,
   inline-SVG trend, plus mini-stat tiles and the order stage stepper.
   Assumes tokens.css + components.css loaded first.
   ===================================================================== */

/* ---------- Donut (conic-gradient) ---------- */
.ac-donut-wrap { display: flex; align-items: center; gap: 22px; }
.ac-donut { width: 150px; height: 150px; border-radius: 50%; flex-shrink: 0; position: relative;
  box-shadow: 0 8px 20px -8px rgba(15,23,42,.18); }
.ac-hole { position: absolute; inset: 20%; background: var(--color-card); border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 4px 6px; overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--color-border); }
.ac-hole b { font-family: var(--font-serif); font-size: 24px; color: var(--color-slate-900); line-height: 1; }
.ac-hole span { max-width: 100%; font-size: 9px; color: var(--color-slate-500); text-transform: uppercase;
  letter-spacing: .02em; line-height: 1.15; margin-top: 3px; }
.ac-legend { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.ac-li { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 9px; cursor: pointer;
  border: 1px solid transparent; transition: background .12s, border-color .12s, transform .1s; }
.ac-li:hover { background: var(--color-slate-50); border-color: var(--color-border); transform: translateX(2px); }
.ac-dot { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.ac-name { flex: 1; font-size: 13px; color: var(--color-slate-700); font-weight: 500; }
.ac-val { font-size: 13.5px; font-weight: 700; color: var(--color-slate-900); font-variant-numeric: tabular-nums; }
.ac-pct { font-size: 11.5px; color: var(--color-slate-500); font-variant-numeric: tabular-nums; margin-left: 4px; }

/* ---------- Horizontal bars (top products / sources) ---------- */
.ac-bar-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.ac-bar-label { width: 150px; font-size: 12.5px; color: var(--color-slate-600); flex-shrink: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-track { flex: 1; height: 22px; background: var(--color-slate-100); border-radius: 6px; overflow: hidden; }
.ac-fill { height: 100%; border-radius: 6px; display: flex; align-items: center; justify-content: flex-end;
  padding-right: 8px; transition: width .8s cubic-bezier(.22,1,.36,1); min-width: 28px; }
.ac-fill span { font-size: 11px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }

/* ---------- Funnel (pipeline) — centered tapering bars + legend ---------- */
.funnel-wrap { display: flex; align-items: stretch; gap: 12px; height: 100%; min-height: 220px; }
.funnel-bars { flex: 0 0 auto; width: 38%; display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; gap: 9px; }
.funnel-bar { height: 30px; border-radius: 8px; min-width: 34%;
  box-shadow: 0 2px 6px -2px rgba(15,23,42,.22); transition: width .6s cubic-bezier(.22,1,.36,1); }
.funnel-legend { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 9px; }
.funnel-li { display: flex; align-items: center; font-size: 11.5px; }
.funnel-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-right: 7px; }
.funnel-lname { font-weight: 600; color: var(--color-slate-700); flex: 1; min-width: 0; padding-right: 8px; }
.funnel-lval { font-family: var(--font-mono); font-weight: 700; color: var(--color-slate-900); flex-shrink: 0; }
.funnel-lpct { margin-left: 5px; color: var(--color-slate-400); font-size: 10.5px; font-family: var(--font-mono); flex-shrink: 0; }

/* ---------- Mini-stat tiles (revenue / stock) ---------- */
.mini-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.mini-grid.mini-3 { grid-template-columns: repeat(3, 1fr); }
.mini-stat { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 12px 14px; background: var(--color-slate-50); }
.mini-label { font-size: 11px; font-weight: 600; color: var(--color-slate-500); text-transform: uppercase; letter-spacing: .05em; }
.mini-value { font-family: var(--font-serif); font-size: 21px; font-weight: 700; color: var(--color-slate-900); margin-top: 4px; line-height: 1; }
.mini-meta { font-size: 11.5px; color: var(--color-slate-500); margin-top: 5px; }
.mini-up { color: var(--color-emerald-600); font-weight: 600; }
.mini-down { color: var(--color-red-600); font-weight: 600; }

/* ---------- Trend SVG ---------- */
.trend-wrap { width: 100%; }
.trend-wrap svg { width: 100%; height: auto; display: block; overflow: visible; }
.trend-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.trend-leg { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--color-slate-600); font-weight: 500; }
.trend-leg .dotc { width: 10px; height: 10px; border-radius: 50%; }

/* ---------- List rows (recent enquiries / activity / customers) ---------- */
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--color-slate-100); }
.list-row:last-child { border-bottom: 0; }
.list-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0;
  font-size: 14px; background: var(--color-slate-100); color: var(--color-slate-600); }
.list-ico svg { width: 15px; height: 15px; display: block; }
.list-ico-emerald { background: var(--color-emerald-100); color: var(--color-emerald-600); }
.list-ico-navy    { background: var(--color-navy-50);     color: var(--color-navy-700); }
.list-ico-violet  { background: var(--color-violet-100);  color: var(--color-violet-600); }
.list-ico-amber   { background: var(--color-amber-100);   color: var(--color-amber-700); }
.list-ico-slate   { background: var(--color-slate-100);   color: var(--color-slate-600); }
.list-main { flex: 1; min-width: 0; }
.list-title { font-size: 13px; font-weight: 600; color: var(--color-slate-900); }
.list-sub { font-size: 11.5px; color: var(--color-slate-500); margin-top: 1px; }
.list-time { font-size: 11.5px; color: var(--color-slate-400); white-space: nowrap; flex-shrink: 0; }
.list-time svg { width: 16px; height: 16px; display: block; color: var(--color-slate-400); }
.list-end { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.card-foot-link { display: inline-block; margin-top: 12px; font-size: 12.5px; font-weight: 600; color: var(--color-amber-700); }

/* ---------- Top products (icon + name + bar + value) ---------- */
.prod-row { display: grid; grid-template-columns: 32px 116px 1fr auto; align-items: center; gap: 12px; padding: 8px 0; }
.prod-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--color-slate-100); color: var(--color-slate-500); }
.prod-ico svg { width: 15px; height: 15px; display: block; }
.prod-name { font-size: 12.5px; font-weight: 600; color: var(--color-slate-800);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prod-track { height: 9px; border-radius: 999px; background: var(--color-slate-100); overflow: hidden; }
.prod-fill { height: 100%; border-radius: 999px; transition: width .6s cubic-bezier(.22,1,.36,1); }
.prod-val { font-family: var(--font-mono); font-weight: 700; font-size: 12.5px; color: var(--color-slate-800);
  text-align: right; min-width: 22px; }

/* ---------- Order stage stepper ---------- */
.ol-stepper { display: flex; align-items: flex-start; padding: 6px 4px 2px; overflow-x: auto; }
.ol-step { flex: 1; min-width: 120px; display: flex; flex-direction: column; align-items: center; position: relative; text-align: center; }
.ol-step-line { position: absolute; top: 19px; left: -50%; width: 100%; height: 3px; background: var(--color-slate-200); z-index: 0; }
.ol-step:first-child .ol-step-line { display: none; }
.ol-step.is-done .ol-step-line, .ol-step.is-active .ol-step-line { background: var(--color-emerald-500); }
.ol-step-dot { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; z-index: 1;
  background: var(--color-slate-100); color: var(--color-slate-400); border: 2px solid var(--color-card);
  box-shadow: 0 0 0 1px var(--color-border); font-size: 17px; }
.ol-step.is-done .ol-step-dot { background: var(--color-emerald-500); color: #fff; box-shadow: 0 0 0 1px var(--color-emerald-500); }
.ol-step.is-active .ol-step-dot { background: var(--gold-grad); color: #1a1206; box-shadow: 0 0 0 4px var(--color-amber-50); }
.ol-step-label { font-size: 12px; font-weight: 600; color: var(--color-slate-700); margin-top: 8px; max-width: 130px; }
.ol-step.is-pending .ol-step-label { color: var(--color-slate-400); }
.ol-step-date { font-size: 11px; color: var(--color-slate-400); margin-top: 2px; }

/* ---------- Order summary strip + rails ---------- */
.ol-summary { display: grid; grid-template-columns: 1.7fr 1.1fr 1.2fr 1fr 1fr; gap: 0; }
.ol-summary > div { padding: 0 22px; }
.ol-summary > div:first-child { padding-left: 4px; }
.ol-summary > div + div { border-left: 1px solid var(--color-border); }
.ol-sum-label { font-size: 10.5px; font-weight: 600; color: var(--color-slate-500); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }
.ol-sum-line { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--color-slate-600); margin-bottom: 5px; }
.ol-sum-line svg { width: 13px; height: 13px; color: var(--color-slate-400); flex: none; }
.ol-amount { font-family: var(--font-serif); font-size: 23px; font-weight: 700; color: var(--color-slate-900); line-height: 1.1; }

/* icon tile + labelled row inside the summary strip */
.ol-tile { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.ol-tile svg { width: 18px; height: 18px; }
.ol-tile-indigo  { background: #eef0fe; color: #4f46e5; }
.ol-tile-blue    { background: #e7f0fd; color: #2563eb; }
.ol-tile-amber   { background: var(--color-amber-50); color: var(--color-amber-600); }
.ol-tile-emerald { background: var(--color-emerald-100); color: var(--color-emerald-600); }
.ol-tile-violet  { background: var(--color-violet-100); color: var(--color-violet-600); }
.ol-sum-row { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.ol-sum-k { font-size: 11px; color: var(--color-slate-500); margin-bottom: 1px; }
.ol-sum-v { font-size: 14px; font-weight: 600; color: var(--color-slate-900); }

/* stepper + summary two-column track */
.ol-track { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; margin-bottom: 20px; }
.ol-step-dot svg { width: 19px; height: 19px; }
@media (max-width: 1100px) { .ol-track { grid-template-columns: 1fr; } }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--color-slate-100); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--color-slate-500); }
.kv .v { color: var(--color-slate-900); font-weight: 600; text-align: right; }
.note-callout { background: var(--color-amber-50); border: 1px solid var(--color-amber-100); border-left: 3px solid var(--color-amber-500);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 12px 14px; font-size: 13px; color: var(--color-slate-700); line-height: 1.5; }
.totals-block { margin-left: auto; width: 320px; margin-top: 16px; }
.totals-block .kv .v { font-variant-numeric: tabular-nums; }
.totals-grand { border-top: 2px solid var(--color-border); margin-top: 4px; padding-top: 10px; }
.totals-grand .v { font-family: var(--font-serif); font-size: 18px; color: var(--color-amber-700); }

/* ---------- Toolbar (orders / reports filters) ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .field-inline { min-width: 150px; }
.toolbar input { padding: 9px 13px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; background: #fff; color: var(--color-slate-800); }
.toolbar .search-inline { flex: 1; min-width: 220px; }

/* professional custom select — kills the native OS dropdown chrome */
.toolbar select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding: 9px 40px 9px 15px;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; font-family: inherit; line-height: 1.2;
  color: var(--color-slate-800); cursor: pointer;
  background-color: #fff;
  background-image: var(--select-caret);
  background-repeat: no-repeat; background-position: right 13px center; background-size: 16px;
  box-shadow: 0 1px 2px rgba(15,23,42,.05);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.toolbar select:hover { border-color: var(--color-slate-300); background-color: #fcfcfb; }
.toolbar select:focus, .toolbar select:focus-visible {
  outline: none; border-color: var(--focus-border);
  box-shadow: 0 0 0 3px var(--focus-ring); background-color: #fff;
}
.date-pill { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border: 1px solid var(--color-border);
  border-radius: 999px; background: #fff; font-size: 12.5px; font-weight: 600; color: var(--color-slate-700); cursor: pointer; }
.date-pill svg { width: 15px; height: 15px; flex: none; color: var(--color-slate-500); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .ol-summary { grid-template-columns: 1fr 1fr; gap: 16px; }
}
@media (max-width: 900px) {
  .ac-donut-wrap { flex-direction: column; align-items: stretch; }
  .ac-donut { align-self: center; }
}
@media (max-width: 768px) {
  .ol-summary { grid-template-columns: 1fr; }
  .ac-bar-label { width: 110px; }
  .totals-block { width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar > * { width: 100%; }
}
