/* =====================================================================
   Miftah — The core loop: match cards, explanations, next action,
   activity timeline, weight sliders, funnel.
   Colour appears only where it carries a reading: score, state, tone.
   ===================================================================== */

/* --- Score ------------------------------------------------------------- */
.score-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}
.score-bar .track {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}
.score-bar .track i { display: block; height: 100%; border-radius: 3px; background: var(--data-1); }
.score-bar.hi .track i { background: var(--good-mark); }
.score-bar .val {
  font-family: var(--mono, ui-monospace, monospace);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 12.5px;
  min-width: 34px;
  text-align: end;
}

/* --- Match card ---------------------------------------------------------
   Each match is its own card: white, a hairline, a corner radius, on a
   recessed tray inside the panel and a beat apart from the next, so the
   eye can tell where one match ends and the next begins. "New" is the
   status badge's job; tinting every new row turned a list of new matches
   into one green block. */
.mcard {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px 14px;
  align-items: start;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.mcard:hover { border-color: var(--border-strong); }

/* The list around the cards */
.panel-body:has(> .mcard),
.modal-body:has(> .mcard) { display: grid; gap: 10px; align-content: start; }
.panel-body-flush:has(> .mcard) { padding: 12px; background: var(--canvas); }
.mcard-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; min-width: 0; }
.mcard-head .name { font-weight: 600; font-size: 14px; }
.mcard-head .meta { font-size: 12px; color: var(--ink-3); }
.mcard-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.mcard-why { display: flex; flex-wrap: wrap; gap: 4px 5px; margin-top: 7px; }
.mcard-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.mcard-actions .row { gap: 5px; }

/* Why-chips: tone carried by a glyph, never colour alone */
.why {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px 2px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--ink-2);
  background: var(--surface);
  max-width: 100%;
}
.why b { font-family: var(--mono, monospace); font-weight: 600; font-size: 11px; }
.why-strong b { color: var(--good-ink); }
.why-partial b { color: var(--warn-ink); }
.why-missing b { color: var(--crit-ink); }
.why-strong { border-color: color-mix(in srgb, var(--good-mark) 35%, var(--border)); }
.why-partial { border-color: color-mix(in srgb, var(--warn-mark) 45%, var(--border)); }
.why-missing { border-color: color-mix(in srgb, var(--crit-mark) 35%, var(--border)); }

/* --- Breakdown table --------------------------------------------------- */
.brk { display: grid; gap: 6px; }
.brk-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 8px 10px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.brk-row:last-child { border-bottom: 0; }
.brk-row .g { font-family: var(--mono, monospace); font-weight: 700; font-size: 13px; text-align: center; }
.brk-strong .g { color: var(--good-ink); }
.brk-partial .g { color: var(--warn-ink); }
.brk-missing .g { color: var(--crit-ink); }
.brk-na .g, .brk-na .k, .brk-na .n { color: var(--ink-3); }
.brk-row .k { font-size: 13px; font-weight: 600; }
.brk-row .n { display: block; font-size: 12px; color: var(--ink-2); margin-top: 1px; }
.brk-row .p {
  font-family: var(--mono, monospace);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.brk-row .p small { font-weight: 400; color: var(--ink-3); }
.brk-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  margin-top: 4px;
  border-top: 2px solid var(--ink);
  font-weight: 700;
}
.brk-total .mono { font-size: 18px; }

/* --- Next action --------------------------------------------------------- */
.next {
  display: grid;
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--data-1);
  border-radius: var(--r);
  background: var(--surface-2);
}
.next .lbl { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.next .txt { font-size: 14px; font-weight: 600; line-height: 1.35; }
.next .btns { display: flex; flex-wrap: wrap; gap: 6px; }
.next.is-done { border-inline-start-color: var(--border-strong); }
.next.is-done .txt { color: var(--ink-3); font-weight: 500; }

/* --- Activity timeline -------------------------------------------------- */
.act {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 0 12px;
  position: relative;
}
.act-row { display: contents; }
.act-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  z-index: 1;
}
.act-line {
  position: relative;
  padding: 4px 0 18px;
  min-width: 0;
}
.act-row:not(:last-child) .act-mark::after {
  content: "";
  position: absolute;
  top: 28px;
  bottom: -30px;
  inset-inline-start: 13px;
  width: 1px;
  background: var(--border);
}
.act-line .h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.act-line .h b { font-size: 13px; font-weight: 600; }
.act-line .h .when { font-family: var(--mono, monospace); font-size: 11px; color: var(--ink-3); }
.act-line .b { font-size: 13px; color: var(--ink-2); margin-top: 2px; line-height: 1.45; }
.act-line .ref { display: inline-block; margin-top: 4px; }

/* --- Weight sliders ------------------------------------------------------ */
.wrow {
  display: grid;
  grid-template-columns: minmax(110px, 160px) 1fr 52px 44px;
  gap: 12px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.wrow:last-child { border-bottom: 0; }
.wrow label { font-size: 13px; font-weight: 600; }
.wrow input[type="range"] { width: 100%; accent-color: var(--accent); }
.wrow .v {
  font-family: var(--mono, monospace);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: end;
}
.wrow.is-off label, .wrow.is-off .v { color: var(--ink-3); }
.wtotal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  margin-top: 6px;
  border-top: 2px solid var(--ink);
  font-weight: 700;
}
.wtotal .mono { font-size: 18px; }
.wtotal.is-bad .mono { color: var(--crit-ink); }

/* --- Funnel --------------------------------------------------------------- */
.funnel { display: grid; gap: 7px; }
.funnel-row {
  display: grid;
  grid-template-columns: minmax(96px, 130px) 1fr 40px;
  gap: 10px;
  align-items: center;
  font-size: 12.5px;
}
.funnel-row .bar { height: 14px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.funnel-row .bar i { display: block; height: 100%; background: var(--data-1); border-radius: 3px; }
.funnel-row .n { font-family: var(--mono, monospace); font-variant-numeric: tabular-nums; text-align: end; font-weight: 600; }

/* --- Request summary line ------------------------------------------------ */
.rq { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; font-size: 12.5px; color: var(--ink-2); }
.rq .sep { color: var(--border-strong); }

/* --- Price echo under the price field ------------------------------------ */
.price-echo { display: block; margin-top: 4px; color: var(--ink-3); min-height: 14px; }

/* --- Dashboard lead card ------------------------------------------------- */
.lead-card { border-color: var(--accent-soft-2); box-shadow: 0 0 0 3px var(--accent-soft); }
.lead-card .panel-head h3 { display: flex; align-items: center; gap: 8px; }
.lead-num {
  font-family: var(--mono, monospace);
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1;
}

/* --- Tabs used by the hub ------------------------------------------------ */
.hub-tabs { margin-bottom: 14px; }

@media (max-width: 640px) {
  .mcard { grid-template-columns: 38px minmax(0, 1fr); padding: 12px; }
  .panel-body-flush:has(> .mcard) { padding: 8px; gap: 8px; }
  .mcard-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .wrow { grid-template-columns: 1fr 52px 44px; }
  .wrow label { grid-column: 1 / -1; }
}
