/* ============================================================
   disc-v2.css — Discrepancies list upgrades
   - Recovery overview strip
   - Reason mini-distribution viz
   - SLA chip with progress bar
   - Settlement-mode tag
   - Linked notes (CN/DN) chips
   - Reason icons (12px glyph)
   - Left-edge priority accent on rows
   - KPI sparklines
   - Bulk-actions toolbar
   ============================================================ */

/* ---------- Recovery overview strip (above KPI segbar) ---------- */
.disc-recovery {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr 1.2fr;
  gap: 0;
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: var(--sd-radius-lg);
  margin-bottom: 12px;
  overflow: hidden;
}
.disc-recovery__cell {
  padding: 14px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}
.disc-recovery__cell + .disc-recovery__cell { border-left: 1px solid var(--sd-line-100); }
.disc-recovery__caps {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  color: var(--sd-ink-500);
}
.disc-recovery__amount {
  font-family: var(--sd-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--sd-ink-900);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  letter-spacing: -0.005em;
}
.disc-recovery__amount .cur {
  font-size: 13px;
  color: var(--sd-ink-500);
  margin-right: 3px;
  font-weight: 500;
}
.disc-recovery__amount .unit {
  font-size: 11px;
  color: var(--sd-ink-500);
  margin-left: 2px;
  font-weight: 500;
  letter-spacing: 0;
}
.disc-recovery__sub {
  font-size: 11.5px;
  color: var(--sd-ink-500);
}
.disc-recovery__sub strong { color: var(--sd-ink-900); font-weight: 500; }
.disc-recovery__sub .delta-up   { color: var(--sd-red-600); font-weight: 500; }
.disc-recovery__sub .delta-down { color: var(--sd-green-600); font-weight: 500; }
.disc-recovery__cell--leading {
  background: linear-gradient(180deg, #FEF2F2 0%, #fff 100%);
}
.disc-recovery__cell--leading .disc-recovery__amount { color: var(--sd-red-600); }

/* Gauge in last cell — circular */
.disc-recovery__gauge {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 14px;
  align-items: center;
}
.disc-recovery__gauge-ring {
  width: 56px; height: 56px;
  position: relative;
}
.disc-recovery__gauge-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.disc-recovery__gauge-ring__pct {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--sd-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--sd-ink-900);
  font-variant-numeric: tabular-nums;
}
.disc-recovery__gauge-text {
  display: flex; flex-direction: column; gap: 2px;
}


/* ---------- Reason distribution mini-viz (above table) ---------- */
.disc-distrib {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--sd-bg-softer);
  border: 1px solid var(--sd-line-200);
  border-radius: var(--sd-radius-md);
  margin-top: 10px;
  margin-bottom: 10px;
}
.disc-distrib__title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  color: var(--sd-ink-500);
  white-space: nowrap;
  flex-shrink: 0;
}
.disc-distrib__bar {
  flex: 1;
  display: flex;
  height: 10px;
  background: var(--sd-line-100);
  border-radius: 3px;
  overflow: hidden;
  min-width: 0;
}
.disc-distrib__seg {
  height: 100%;
  display: block;
  position: relative;
  border-right: 1px solid #fff;
}
.disc-distrib__seg:last-child { border-right: 0; }
.disc-distrib__seg--damage { background: var(--sd-red-600); }
.disc-distrib__seg--ship   { background: #B47200; }
.disc-distrib__seg--paper  { background: #5B3F92; }
.disc-distrib__seg--data   { background: #225d83; }
.disc-distrib__seg--other  { background: #6B5C3A; }
.disc-distrib__legend {
  display: flex;
  gap: 14px;
  flex-shrink: 0;
}
.disc-distrib__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--sd-ink-700);
}
.disc-distrib__legend-dot {
  width: 8px; height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.disc-distrib__legend-pct {
  font-family: var(--sd-mono);
  font-size: 10.5px;
  color: var(--sd-ink-500);
  font-variant-numeric: tabular-nums;
}


/* ---------- KPI sparkline ---------- */
.kpiseg__spark {
  position: absolute;
  bottom: 8px;
  right: 12px;
  width: 64px;
  height: 22px;
  pointer-events: none;
  opacity: .85;
}
.kpiseg__spark path {
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.kpiseg__spark .fill { fill: currentColor; opacity: .12; stroke: none; }
.kpiseg__spark .line { stroke: currentColor; }
.kpiseg--red    .kpiseg__spark { color: var(--sd-red-600); }
.kpiseg--amber  .kpiseg__spark { color: var(--sd-amber-500); }
.kpiseg--green  .kpiseg__spark { color: var(--sd-green-600); }
.kpiseg--neutral .kpiseg__spark { color: var(--sd-ink-500); }


/* ---------- Reason icon (12px glyph beside reason chip) ---------- */
.disc-reason svg.disc-reason__icon {
  width: 11px;
  height: 11px;
  margin-right: 4px;
  flex-shrink: 0;
  color: currentColor;
}
/* Hide the now-redundant dot when an icon is present */
.disc-reason svg.disc-reason__icon + .disc-reason__dot,
.disc-reason svg.disc-reason__icon ~ .disc-reason__dot { display: none; }


/* ---------- SLA chip with progress bar (replaces aging text) ---------- */
.disc-sla {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  min-width: 86px;
}
.disc-sla__head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--sd-ink-700);
}
.disc-sla__head .age {
  font-family: var(--sd-mono);
  font-size: 11px;
  color: var(--sd-ink-500);
  font-variant-numeric: tabular-nums;
}
.disc-sla__head .left {
  font-family: var(--sd-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.disc-sla__bar {
  width: 100%;
  height: 4px;
  background: var(--sd-line-100);
  border-radius: 999px;
  overflow: hidden;
}
.disc-sla__fill {
  display: block;
  height: 100%;
  background: var(--sd-green-600);
  border-radius: 999px;
}
.disc-sla.is-ok       .disc-sla__head .left { color: var(--sd-green-600); }
.disc-sla.is-warn     .disc-sla__fill       { background: var(--sd-amber-500); }
.disc-sla.is-warn     .disc-sla__head .left { color: var(--sd-amber-text); }
.disc-sla.is-bad      .disc-sla__fill       { background: var(--sd-red-600); }
.disc-sla.is-bad      .disc-sla__head .left { color: var(--sd-red-600); }
.disc-sla.is-breached .disc-sla__fill       { background: var(--sd-red-600); }
.disc-sla.is-breached .disc-sla__head .left { color: var(--sd-red-600); }
.disc-sla.is-breached .disc-sla__head .age::before {
  content: '!';
  display: inline-block;
  background: var(--sd-red-600);
  color: #fff;
  font-family: var(--sd-font);
  font-weight: 700;
  font-size: 9px;
  width: 12px; height: 12px;
  line-height: 12px;
  text-align: center;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.disc-sla.is-closed .disc-sla__head { color: var(--sd-ink-400); }
.disc-sla.is-closed .disc-sla__fill { background: var(--sd-line-300); }
.disc-sla.is-closed .disc-sla__head .left { color: var(--sd-ink-400); }


/* ---------- Settlement-mode tag (column) ---------- */
.disc-settle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 6px;
  border-radius: var(--sd-radius-sm);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}
.disc-settle svg { width: 11px; height: 11px; flex-shrink: 0; }
.disc-settle--cn-pending   { background: var(--sd-amber-100); color: var(--sd-amber-text); border-color: #EBC07B; }
.disc-settle--cn-issued    { background: var(--sd-green-100); color: var(--sd-green-600); border-color: #c4dfcf; }
.disc-settle--dn-pending   { background: var(--sd-amber-100); color: var(--sd-amber-text); border-color: #EBC07B; }
.disc-settle--dn-issued    { background: var(--sd-blue-100);  color: var(--sd-blue-700);   border-color: #B7CEDF; }
.disc-settle--replace      { background: var(--sd-teal-050);  color: var(--sd-teal-600);   border-color: rgba(23,162,184,.35); }
.disc-settle--writeoff     { background: var(--sd-line-100);  color: var(--sd-ink-700);    border-color: var(--sd-line-300); }
.disc-settle--rejected     { background: var(--sd-red-100);   color: #A8273F;              border-color: #E1A6B3; }
.disc-settle--tba          { background: transparent; color: var(--sd-ink-400); border: 1px dashed var(--sd-line-300); font-weight: 500; letter-spacing: 0; text-transform: none; padding: 3px 8px; }


/* ---------- Linked CN / DN notes chip ---------- */
.disc-notes {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--sd-mono);
  font-size: 11px;
  line-height: 1.4;
}
.disc-notes__chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--sd-bg-soft);
  border: 1px solid var(--sd-line-200);
  border-radius: 3px;
  padding: 1px 6px;
  text-decoration: none;
  color: var(--sd-ink-700);
  font-variant-numeric: tabular-nums;
}
.disc-notes__chip:hover {
  background: var(--sd-blue-050);
  border-color: var(--sd-blue-600);
  color: var(--sd-blue-700);
}
.disc-notes__chip-kind {
  font-family: var(--sd-font);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--sd-ink-500);
}
.disc-notes--none {
  font-family: var(--sd-font);
  color: var(--sd-ink-300);
  font-size: 11px;
  font-style: italic;
}


/* ---------- Priority left-edge accent on rows ---------- */
.cons[data-module="disc"] .row[data-prio="p1"] {
  box-shadow: inset 3px 0 0 var(--sd-red-600);
}
.cons[data-module="disc"] .row[data-prio="p2"] {
  box-shadow: inset 2px 0 0 var(--sd-amber-500);
}
.cons[data-module="disc"] .row[data-prio="p1"]:hover {
  background: rgba(220, 53, 69, .04);
}


/* ---------- Reset column widths for disc table ----------
   New order (left → right):
   ☐ · Disc no · Priority · Reason · Source · Branch · SLA · Owner ·
   Settlement · Linked notes · Net value · → */
.cons[data-module="disc"] .cons__head .th--prio,
.cons[data-module="disc"] .row         .td--prio,
.cons[data-module="disc"] .cons__totals .td--prio   { flex: 0 0 60px; }

.cons[data-module="disc"] .cons__head .th--sla,
.cons[data-module="disc"] .row         .td--sla,
.cons[data-module="disc"] .cons__totals .td--sla    { flex: 0 0 130px; }

.cons[data-module="disc"] .cons__head .th--settle,
.cons[data-module="disc"] .row         .td--settle,
.cons[data-module="disc"] .cons__totals .td--settle { flex: 0 0 130px; }

.cons[data-module="disc"] .cons__head .th--notes,
.cons[data-module="disc"] .row         .td--notes,
.cons[data-module="disc"] .cons__totals .td--notes  { flex: 0 0 120px; }

/* Tighten supplier/branch col since we have more columns now */
.cons[data-module="disc"] .cons__head .th--supplier,
.cons[data-module="disc"] .row         .td--supplier,
.cons[data-module="disc"] .cons__totals .td--supplier { flex: 0 0 132px; }

/* Owner col can be a little narrower now that settlement is split out */
.cons[data-module="disc"] .cons__head .th--status,
.cons[data-module="disc"] .row         .td--status,
.cons[data-module="disc"] .cons__totals .td--status   { flex: 0 0 168px; }


/* ---------- Owner cell: simplified now that settlement is its own column ---------- */
.cons[data-module="disc"] .disc-owner__team {
  font-size: 10.5px;
  color: var(--sd-ink-500);
}


/* ---------- Bulk actions bar (slides in when ≥1 row selected) ---------- */
.disc-bulkbar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: none;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--sd-ink-900);
  color: #fff;
  border-radius: var(--sd-radius-md);
  box-shadow: 0 6px 14px rgba(15, 28, 46, .22);
}
.disc-bulkbar.is-on { display: flex; }
.disc-bulkbar__sel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
}
.disc-bulkbar__sel .cnt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: rgba(255, 255, 255, .14);
  border-radius: 999px;
  font-family: var(--sd-mono);
  font-size: 11px;
  font-weight: 600;
}
.disc-bulkbar__sub {
  font-size: 11px;
  color: rgba(255, 255, 255, .56);
}
.disc-bulkbar__spacer { flex: 1; }
.disc-bulkbar__btn {
  appearance: none;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .22);
  color: #fff;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: var(--sd-radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.disc-bulkbar__btn:hover { background: rgba(255, 255, 255, .09); border-color: rgba(255, 255, 255, .42); }
.disc-bulkbar__btn svg { width: 12px; height: 12px; }
.disc-bulkbar__btn--danger { border-color: rgba(220, 53, 69, .55); color: #FFB8C0; }
.disc-bulkbar__btn--danger:hover { background: rgba(220, 53, 69, .12); border-color: rgba(220, 53, 69, .8); color: #fff; }
.disc-bulkbar__btn--primary {
  background: var(--sd-teal-600);
  border-color: var(--sd-teal-600);
  color: #fff;
  font-weight: 600;
}
.disc-bulkbar__btn--primary:hover { background: #138498; border-color: #138498; }
.disc-bulkbar__close {
  appearance: none; background: transparent; border: 0;
  color: rgba(255, 255, 255, .6); padding: 4px;
  cursor: pointer;
  border-radius: 4px;
}
.disc-bulkbar__close:hover { color: #fff; background: rgba(255, 255, 255, .08); }


/* ============================================================
   v3 — KPI bar with embedded ₹ + trend tile (was disc-recovery strip)
   Folds the standalone recovery overview into the KPI segments
   plus a 5th non-interactive trend tile.
   ============================================================ */

/* Segbar: when paired with the trend tile, last column is narrower */
.cons__segbar--with-trend {
  grid-template-columns: repeat(4, 1fr) 240px;
}
@media (max-width: 1280px) {
  .cons__segbar--with-trend { grid-template-columns: repeat(4, 1fr) 200px; }
}

/* Each kpiseg now leads with count + ₹ amount stacked right */
.kpiseg__value {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  line-height: 1;
}
.kpiseg__value-amt {
  font-family: var(--sd-mono);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--sd-ink-900);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}
.kpiseg__value-cap {
  font-size: 10px;
  font-weight: 500;
  color: var(--sd-ink-500);
  text-transform: lowercase;
  letter-spacing: 0;
}
.kpiseg__value--good .kpiseg__value-amt { color: var(--sd-green-600); }
.kpiseg.is-active .kpiseg__value-amt { color: rgba(255,255,255,.92); }
.kpiseg.is-active .kpiseg__value-cap { color: rgba(255,255,255,.6); }
.kpiseg.is-active .kpiseg__value--good .kpiseg__value-amt { color: rgba(255,255,255,.92); }

/* ---- Trend tile (5th column) ------------------------------ */
.cons__trend {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--sd-bg-softer);
  border-left: 1px solid var(--sd-line-200);
  min-width: 0;
}
.cons__trend-ring {
  width: 52px;
  height: 52px;
  position: relative;
  flex-shrink: 0;
}
.cons__trend-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.cons__trend-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sd-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--sd-ink-900);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}
.cons__trend-pct .u {
  font-size: 9px;
  color: var(--sd-ink-500);
  margin-left: 1px;
  font-weight: 500;
}
.cons__trend-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.cons__trend-caps {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--sd-ink-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cons__trend-sub {
  font-size: 11.5px;
  color: var(--sd-ink-700);
  font-variant-numeric: tabular-nums;
}
.cons__trend-sub strong { font-weight: 600; color: var(--sd-ink-900); }
.cons__trend-delta {
  font-size: 11px;
  color: var(--sd-green-600);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ---- Trends drawer affordance in toolbar ------------------ */
.cons__chip.cons__chip--trends {
  color: var(--sd-blue-700);
  border-style: dashed;
  border-color: var(--sd-blue-100);
  background: var(--sd-blue-050);
}
.cons__chip.cons__chip--trends:hover {
  border-style: solid;
  border-color: var(--sd-blue-600);
  background: var(--sd-blue-100);
}
.cons__chip.cons__chip--trends svg { color: var(--sd-blue-600); }

/* ---- Toolbar layout: allow chips to wrap when truly tight - */
.cons__toolbar {
  flex-wrap: wrap;
  row-gap: 8px;
}
.cons__toolbar .view-chip__sep {
  height: 22px;
}
