/* changes.css
 * The Changes view is scanned, not read: the question is "did anything move",
 * and the answer must land before any number is parsed. Direction is carried
 * by a coloured rail and an arrow as well as by the digit, so a red row reads
 * as bad at a glance and does not depend on colour alone.
 */

.ch-wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px 64px; }

.ch-head { margin-bottom: 20px; }
.ch-h1 { font-size:1.625rem; font-weight: 700; color: var(--text); margin: 0 0 8px; text-wrap: balance; }
.ch-sub { font-size:0.9375rem; line-height: 1.6; color: var(--text-2); margin: 0; max-width: 62ch; }

.ch-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 24px; }
.ch-input {
  flex: 1 1 240px; min-width: 0; padding: 10px 12px; font: inherit; font-size:0.9375rem;
  color: var(--text); background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px;
}
.ch-input:focus { outline: none; border-color: var(--accent); }

/* The range control is a .tu-seg (tool-ui.css); only the selected state is named here. */
.tu-seg .ch-range-btn { padding: 0 14px; }
.tu-seg .ch-range-btn.on { background: var(--bg-card); color: var(--text); box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(0,0,0,.12); }
.ch-range-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.ch-btn {
  padding: 10px 18px; font: inherit; font-size:0.9375rem; font-weight: 700;
  border-radius: 8px; border: 1px solid var(--border); cursor: pointer;
  color: var(--text); background: var(--bg-card);
}
.ch-btn.on { color: #fff; background: var(--accent); border-color: var(--accent); }
.ch-btn[disabled] { opacity: .6; cursor: default; }

/* Summary ------------------------------------------------------------- */
.ch-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px;
  margin-bottom: 24px;
}
.ch-card {
  padding: 16px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.ch-card-label {
  font-size:0.8125rem; font-weight: 700;
  color: var(--text-3); margin-bottom: 8px;
}
.ch-card-value { font-size:1.5rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.ch-card-note { font-size:0.875rem; color: var(--text-2); margin-top: 6px; line-height: 1.5; }

/* Ledger -------------------------------------------------------------- */
.ch-section-label {
  font-size:0.8125rem; font-weight: 700;
  color: var(--text-3); margin: 28px 0 10px;
}
.ch-list { display: flex; flex-direction: column; gap: 6px; }
.ch-row {
  display: grid; grid-template-columns: 4px 1fr auto auto; align-items: center; gap: 14px;
  padding: 0 16px 0 0; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; text-decoration: none; color: inherit;
  transition: border-color .12s;
}
.ch-row:hover { border-color: var(--border-strong, var(--accent)); }
.ch-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* The rail repeats the direction structurally, so the row is legible without
 * relying on the colour of the number alone. */
.ch-rail { align-self: stretch; background: var(--border); }
.ch-row.up   .ch-rail { background: var(--green); }
.ch-row.down .ch-rail { background: var(--red); }

.ch-name { padding: 14px 0; min-width: 0; }
.ch-tool { font-size:0.9375rem; font-weight: 600; color: var(--text); }
.ch-when { font-size:0.8125rem; color: var(--text-3); margin-top: 3px; }

.ch-score {
  font-size:1.125rem; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; text-align: right;
}
.ch-from { font-size:0.8125rem; color: var(--text-3); font-variant-numeric: tabular-nums; }

.ch-delta {
  display: inline-flex; align-items: center; gap: 4px; justify-content: flex-end;
  min-width: 74px; padding: 5px 10px; border-radius: 6px;
  font-size:0.875rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--text-2); background: var(--bg-elevated, var(--bg)); border: 1px solid var(--border);
}
.ch-delta.up   { color: var(--green); background: var(--green-bg); border-color: var(--green-border); }
.ch-delta.down { color: var(--red);   background: var(--red-bg);   border-color: var(--red-border); }
.ch-delta.new  { color: var(--blue);  background: var(--blue-bg);  border-color: var(--blue-border); }

/* Never run ----------------------------------------------------------- */
.ch-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-chip {
  padding: 7px 12px; font-size:0.875rem; font-weight: 600; text-decoration: none;
  color: var(--text-2); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 16px; transition: color .12s, border-color .12s;
}
.ch-chip:hover { color: var(--text); border-color: var(--accent); }

/* States -------------------------------------------------------------- */
.ch-empty {
  padding: 44px 24px; text-align: center; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--r-lg);
}
.ch-empty-title { font-size:1.0625rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.ch-empty-note { font-size:0.9375rem; color: var(--text-2); line-height: 1.6; max-width: 48ch; margin: 0 auto; }
.ch-error { border-color: var(--red-border); }

.ch-skel { display: flex; flex-direction: column; gap: 6px; }
.ch-skel-row {
  height: 58px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; opacity: .55; animation: ch-pulse 1.4s ease-in-out infinite;
}
.ch-skel-row:nth-child(2) { animation-delay: .12s; }
.ch-skel-row:nth-child(3) { animation-delay: .24s; }
.ch-skel-row:nth-child(4) { animation-delay: .36s; }
@keyframes ch-pulse { 0%,100% { opacity: .35; } 50% { opacity: .7; } }
@media (prefers-reduced-motion: reduce) { .ch-skel-row { animation: none; } }

@media (max-width: 640px) {
  .ch-wrap { padding: 0 16px 48px; }
  .ch-row { grid-template-columns: 4px 1fr auto; }
  .ch-score { display: none; }
}

.ch-chip-rest { color: var(--text-3); border-style: dashed; }
