/* ============================================================
   Metric detail — Paper artboard 03 (J6-0) fidelity pass.
   Sans H1 + caps-mono chip row, joined 4-cell stat strip,
   cleaned 12-month trend, LAST-5 history, review thread.
   ============================================================ */

.det-shell{ max-width:1208px; margin:0 auto; padding:32px 24px 56px; }

.det-back{
  display:inline-flex; align-items:center; gap:6px;
  font-size:12.5px; font-weight:500; color:var(--accent);
  margin-bottom:12px; cursor:pointer;
}
.det-back:hover{ color:var(--accent-ink); }
.det-back svg{ flex-shrink:0; }

.det-head{ display:flex; align-items:flex-end; justify-content:space-between; gap:24px; margin-bottom:24px; }
.det-id{ display:flex; flex-direction:column; gap:10px; min-width:0; }
h1.det-title{
  margin:0; font-family:var(--sans);
  font-size:28px; font-weight:600; letter-spacing:-0.02em; line-height:1.2;
}

/* Caps-mono chip row: status pill first, then bordered metadata chips. */
.det-chips{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.det-chip{
  display:inline-flex; align-items:center; gap:6px;
  height:24px; padding:0 10px; border-radius:12px;
  border:1px solid var(--rule-3); background:transparent;
  font-family:var(--mono); font-size:11px; line-height:14px;
  color:var(--ink-3); text-transform:uppercase; white-space:nowrap;
}
.det-chip .dot{ width:6px; height:6px; border-radius:50%; flex-shrink:0; }
.det-chip.tone{ border-color:transparent; font-weight:500; }
.det-chip.tone.ok{ background:var(--ok-soft); color:var(--ok-ink); }
.det-chip.tone.ok .dot{ background:var(--ok); }
.det-chip.tone.warn{ background:var(--warn-soft); color:var(--warn-ink); }
.det-chip.tone.warn .dot{ background:var(--warn); }
.det-chip.tone.bad{ background:var(--bad-soft); color:var(--bad-ink); }
.det-chip.tone.bad .dot{ background:var(--bad); }
.det-chip.tone.empty{ background:var(--surface-2); color:var(--ink-3); }
.det-chip.tone.empty .dot{ background:var(--ink-4); }
.det-chip.flagged{ border-color:transparent; background:var(--warn-soft); color:var(--warn-ink); font-weight:500; }
.det-chip.flagged .dot{ background:var(--warn); }

/* Header actions: Edit thresholds / Flag / (Sync) / red-outline Delete. */
.det-actions{ display:flex; align-items:center; gap:10px; flex-shrink:0; }
.det-actions .btn{ height:32px; padding:0 13px; border-radius:7px; color:var(--ink); }
.det-actions .btn.danger{ color:var(--bad-ink); border-color:var(--bad-soft); }

/* ---- Joined 4-cell stat strip (one container, internal dividers) -------- */
.kpis{
  display:grid; grid-template-columns:repeat(4, 1fr);
  background:var(--surface); border:1px solid var(--rule-2);
  border-radius:var(--radius-lg); overflow:hidden; margin-bottom:24px;
}
.kpi{ display:flex; flex-direction:column; gap:6px; padding:16px 20px; border-right:1px solid var(--rule); }
.kpi:last-child{ border-right:0; }
.kpi .lbl{
  font-family:var(--mono); font-size:10.5px; font-weight:500; line-height:14px;
  color:var(--ink-3); text-transform:uppercase; letter-spacing:0.12em;
}
.kpi .val{
  display:flex; align-items:center; gap:8px;
  font-family:var(--mono); font-size:24px; font-weight:500;
  letter-spacing:-0.02em; line-height:30px; color:var(--ink);
  font-variant-numeric:tabular-nums;
}
.kpi .val .streak-dot{ width:8px; height:8px; border-radius:50%; background:var(--ok); flex-shrink:0; }
@media (max-width:860px){
  .kpis{ grid-template-columns:repeat(2, 1fr); }
  .kpi:nth-child(2){ border-right:0; }
  .kpi:nth-child(-n+2){ border-bottom:1px solid var(--rule); }
}

/* ---- 12-month trend card ------------------------------------------------- */
.chart-card{
  display:flex; flex-direction:column; gap:14px;
  background:var(--surface); border:1px solid var(--rule-2);
  border-radius:var(--radius-lg); padding:20px 24px; margin-bottom:24px;
}
.chart-head{ display:flex; align-items:center; gap:14px; }
.chart-title{ flex:1; font-size:15px; font-weight:600; line-height:18px; color:var(--ink); }
.chart-legend{ display:flex; align-items:center; gap:14px; }
.chart-legend .li{
  display:flex; align-items:center; gap:6px;
  font-family:var(--mono); font-size:10.5px; line-height:14px;
  color:var(--ink-3); text-transform:uppercase;
}
/* Data lines are neutral slate, never accent — swatches match the line. */
.chart-legend .sw-line{ width:14px; height:2px; background:var(--chart); flex-shrink:0; }
.chart-legend .sw-dash{ width:14px; height:0; border-top:2px dashed var(--ink-4); flex-shrink:0; }

/* Sparse caps x-labels; the current period reads accent + semibold. */
.chart-x{ display:flex; justify-content:space-between; }
.chart-x span{
  font-family:var(--mono); font-size:10px; line-height:12px;
  color:var(--ink-4); text-transform:uppercase;
}
.chart-x span.cur{ color:var(--accent); font-weight:600; }

/* ---- History + thread row ------------------------------------------------ */
.det-grid{ display:grid; grid-template-columns:1.2fr 1fr; gap:24px; align-items:start; }
@media (max-width:1100px){ .det-grid{ grid-template-columns:1fr; } }

.det-grid .card-head{ padding:13px 18px; border-bottom:1px solid var(--rule); }
.det-grid .card-head h3{ font-size:14px; font-weight:600; line-height:18px; }
.det-grid .card-head .sub.caps{
  font-family:var(--mono); font-size:10.5px; line-height:14px;
  color:var(--ink-3); text-transform:uppercase; letter-spacing:0.1em;
}

/* Monthly history table: PERIOD · ACTUAL · TARGET · DELTA · NOTE. */
table.hist{ width:100%; border-collapse:separate; border-spacing:0; }
table.hist th, table.hist td{
  padding:0 12px; text-align:right; border-bottom:1px solid var(--rule);
}
table.hist th{
  height:30px; background:var(--bg);
  font-family:var(--mono); font-size:10px; font-weight:500; line-height:12px;
  color:var(--ink-4); text-transform:uppercase; letter-spacing:0.1em;
}
table.hist td{ height:38px; }
table.hist tr:last-child td{ border-bottom:0; }
table.hist td.mo, table.hist th.mo{ text-align:left; padding-left:18px; }
table.hist td.notes, table.hist th.notes{ padding-right:18px; }
table.hist td.mo{ font-family:var(--mono); font-size:11.5px; color:var(--ink-3); }
table.hist td.notes{ font-size:11.5px; color:var(--ink-4); }
table.hist td .num{ font-family:var(--mono); font-size:12px; font-variant-numeric:tabular-nums; }
table.hist td .num.actual{ font-weight:500; color:var(--ink); }
table.hist td .num.target{ color:var(--ink-4); }
table.hist td .num.delta{ font-weight:500; }
table.hist td .num.delta.ok{ color:var(--ok); }
table.hist td .num.delta.bad{ color:var(--bad); }
table.hist td .num.empty{ color:var(--ink-5); }

/* Review thread: hairline-separated rows, flat inside the card. */
.thread{ display:flex; flex-direction:column; }
.msg{ padding:16px 18px; border-bottom:1px solid var(--rule); background:var(--surface); }
.thread > div:last-child .msg:last-child{ border-bottom:0; }
.msg.flag{ background:var(--warn-soft); }
.msg-head{ display:flex; align-items:center; gap:8px; margin-bottom:4px; }
.msg-head .avatar{ margin-right:4px; }
.msg-head .who{ font-size:13px; font-weight:600; color:var(--ink); }
.msg-head .ts{ font-family:var(--mono); font-size:10.5px; color:var(--ink-4); text-transform:uppercase; }
.msg-head .sp{ flex:1; }
.msg-body{ margin-left:40px; font-size:13px; color:var(--ink-2); line-height:20px; }
.msg-body p{ margin:0 0 4px; } .msg-body p:last-child{ margin-bottom:0; }
.msg-body a{ color:var(--accent); }
#thread-empty .msg-body{ margin-left:0; color:var(--ink-4); }
/* Flagged = amber, everywhere. */
.msg .tag{
  font-family:var(--mono); font-size:9.5px; padding:2px 6px; border-radius:3px;
  background:var(--surface); color:var(--warn-ink); border:1px solid var(--warn);
  text-transform:uppercase; letter-spacing:0.04em;
}

/* Composer: "Add a comment…" box + flag checkbox + solid accent Comment. */
.compose{ display:flex; flex-direction:column; gap:10px; padding:16px 18px; }
.compose textarea{
  width:100%; min-height:64px; padding:10px 12px;
  border:1px solid var(--rule-3); border-radius:8px; background:var(--surface);
  font-family:var(--sans); font-size:13px; line-height:16px; color:var(--ink);
  resize:vertical; outline:none;
}
.compose textarea::placeholder{ color:var(--ink-4); }
.compose textarea:focus{ border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
.compose-foot{ display:flex; align-items:center; gap:10px; }
.compose-flag{
  display:inline-flex; align-items:center; gap:7px; margin-right:auto;
  font-size:12px; line-height:16px; color:var(--ink-3); cursor:pointer;
}
.compose-flag input[type="checkbox"]{ width:14px; height:14px; margin:0; accent-color:var(--accent); }
.compose .btn.primary{ height:30px; padding:0 14px; border-radius:7px; }

/* Keyboard focus ring, consistent with design.css inputs. */
.det-back:focus-visible{
  outline:none; border-radius:4px;
  box-shadow:0 0 0 3px var(--accent-soft); color:var(--accent-ink);
}

/* ============================================================
   Chart crosshair + tooltip overlay (metric_detail_controller.js).
   The SVG point circles are transparent; the hover affordance is
   this HTML overlay. Animate transform/opacity only; honor
   prefers-reduced-motion.
   ============================================================ */
#bigChart{ position:relative; }

.md-overlay{ position:absolute; inset:0; pointer-events:none; }
.md-overlay[hidden]{ display:none; }

/* Vertical guide pinned to the focused reading. */
.md-crosshair{
  position:absolute; top:0; left:0; width:1px;
  background:linear-gradient(var(--rule-3), var(--rule-2));
  will-change:transform;
}

/* Focal ring drawn over the (invisible) SVG dot — kept in HTML so it stays
   circular under the SVG's preserveAspectRatio="none" stretch. */
.md-focus{
  position:absolute; top:0; left:0; width:9px; height:9px;
  margin:-4.5px 0 0 -4.5px; border-radius:50%;
  background:var(--surface); border:2px solid var(--accent);
  box-shadow:0 0 0 4px var(--accent-soft);
  will-change:transform;
}

.md-tooltip{
  position:absolute; top:0; left:0;
  display:flex; flex-direction:column; gap:1px; white-space:nowrap;
  padding:6px 9px; border-radius:var(--radius);
  background:var(--ink); color:var(--surface);
  box-shadow:var(--shadow-pop);
  will-change:transform;
}
.md-tip-period{ font-family:var(--mono); font-size:9.5px; letter-spacing:0.05em; text-transform:uppercase; color:var(--ink-5); }
.md-tip-value{ font-family:var(--mono); font-size:12.5px; font-weight:500; font-variant-numeric:tabular-nums; }

@media (prefers-reduced-motion: no-preference){
  .md-focus{ transition:transform .12s ease; }
  .md-crosshair{ transition:transform .12s ease; }
  .md-tooltip{ transition:transform .12s ease; }
}
