/* ============================================================
   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; }
/* Phone: title+chips and Edit / Clear flag / Delete used to share one
   nowrap row. Actions are flex-shrink:0, so at ~390 the identity column
   collapsed and the last chip (FLAGGED · 3 MONTHS CRITICAL) painted under
   the buttons. Stack them; keep every control. Desktop stays a single row. */
@media (max-width:720px){
  .det-head{ flex-direction:column; align-items:stretch; gap:14px; }
  .det-actions{ flex-wrap:wrap; }
}
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); }
}

/* ---- Trend card ----------------------------------------------------------
   The chart is the assistant's card (styled in chat.css, drawn by
   assistant_card_controller.js). It carries its own frame, so the page only
   owns the space around it. */
.det-trend{ margin-bottom:24px; }

/* ---- 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:minmax(0, 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.
   The five columns have a min-content wider than a phone card. `.card`
   sets overflow:hidden for the radius, so the table used to clip
   (#246). `.hist-scroll` is the same idea as `.grid-scroll`: keep the
   glyphs, scroll to the later columns. */
.hist-card{ min-width:0; }
.hist-scroll{
  overflow-x:auto; overscroll-behavior-inline:contain;
  scrollbar-width:thin; scrollbar-color:var(--ink-3) var(--surface-2);
}
@media (max-width:720px){
  /* Always paint the bar on a phone so overlay scrollbars still
     read as "more columns this way" — same reason .grid-scroll
     forces overflow-x:scroll when a side has more. */
  .hist-scroll{ overflow-x:scroll; }
}
.hist-scroll::-webkit-scrollbar{ height:12px; }
.hist-scroll::-webkit-scrollbar-thumb{
  background:var(--ink-3); border-radius:8px;
}
.hist-scroll::-webkit-scrollbar-track{ background:var(--surface-2); }
table.hist{ width:max-content; min-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);
  white-space:nowrap;
}
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);
}
