/* Track records: sources and evidence, the import tool, strategy health, safety plan, content history.
   Chart colours are the validated ones from app/charts.py: HILITE #e2bd6e, ACCENT #b8883a, SECOND #7d8ccf. */

:root {
  --src-api: #e2bd6e;
  --src-statement: #b8883a;
  --src-badge: #7d8ccf;
  --src-typed: #55555c;
}

/* ---- source of a month: a dot that always comes with a label (never colour alone) ---- */
.src { display: inline-flex; align-items: center; gap: .35rem; font-size: .76rem; color: var(--text-2); white-space: nowrap; }
.src::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--src-typed); box-shadow: 0 0 0 2px rgba(0, 0, 0, .35); flex: none; }
.src-api::before { background: var(--src-api); }
.src-statement::before { background: var(--src-statement); }
.src-badge::before { background: var(--src-badge); }
.src-typed::before { background: var(--src-typed); }
.src-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; }

.heat td[data-src] { position: relative; }
.heat td[data-src]::after { content: ""; position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--src-typed); opacity: .95; }
.heat td[data-src="api"]::after { background: var(--src-api); }
.heat td[data-src="statement"]::after { background: var(--src-statement); }
.heat td[data-src="badge"]::after { background: var(--src-badge); }
.heat td[data-src="typed"]::after { background: transparent; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28); }

/* evidence as a stacked bar: one segment per level, 2px gaps */
.ev-bar { display: flex; gap: 2px; height: 10px; border-radius: 6px; overflow: hidden; background: rgba(255, 255, 255, .04); }
.ev-bar > span { display: block; min-width: 4px; }
.ev-bar .api { background: var(--src-api); }
.ev-bar .statement { background: var(--src-statement); }
.ev-bar .badge { background: var(--src-badge); }
.ev-bar .typed { background: var(--src-typed); }
.ev-rows { display: grid; gap: .5rem; margin-top: .85rem; }
.ev-rows > div { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .75rem; align-items: center; font-size: .84rem; }
.ev-rows b { font-variant-numeric: tabular-nums; }
.ev-rows small { color: var(--faint); min-width: 3.2rem; text-align: right; font-variant-numeric: tabular-nums; }
.ev-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .55rem; }
.ev-head b { font-size: 1.55rem; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }

/* ---- health ---- */
.health-panel { display: grid; gap: 1.25rem 1.75rem; grid-template-columns: minmax(0, 1fr); padding: 1.35rem 1.5rem; margin-bottom: 1.1rem; }
.health-panel > * { min-width: 0; }
@media (min-width: 900px) { .health-panel { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .health-panel .hp-chart { grid-column: 1 / -1; } }
@media (min-width: 1360px) { .health-panel { grid-template-columns: minmax(250px, 1.05fr) minmax(250px, 1fr) minmax(0, 2.1fr); } .health-panel .hp-chart { grid-column: auto; } }
.hp-state { display: grid; gap: .6rem; align-content: start; }
.hp-state h2 { margin: 0; font-size: 1.05rem; display: flex; gap: .5rem; align-items: center; }
.hp-state h2 .icon { width: 17px; height: 17px; color: var(--gold-3); }
.hp-state p { margin: 0; color: var(--text-2); font-size: .9rem; }
.hp-note { font-size: .78rem; color: var(--faint); }
.state-pill { display: inline-flex; align-items: center; gap: .45rem; padding: .38rem .75rem .38rem .6rem; border-radius: 999px; font-weight: 640; font-size: .9rem; width: max-content; max-width: 100%; border: 1px solid var(--border); background: rgba(255, 255, 255, .04); color: var(--text); }
.state-pill .icon { width: 16px; height: 16px; }
.state-ok { color: #5fd89c; border-color: rgba(70, 201, 138, .25); background: rgba(70, 201, 138, .08); }
.state-watch { color: #f5c060; border-color: rgba(242, 181, 74, .28); background: rgba(242, 181, 74, .09); }
.state-alert { color: #f6858a; border-color: rgba(240, 107, 111, .3); background: rgba(240, 107, 111, .1); }
.state-stale, .state-inactive { color: var(--text-2); }
.state-pending { color: var(--gold-2); border-color: var(--accent-line); background: var(--accent-soft); }

.dd-meter { display: grid; gap: .45rem; }
.dd-meter .dm-top { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; }
.dd-meter .dm-top b { font-size: 1.7rem; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.dd-meter .dm-top span { font-size: .78rem; color: var(--muted); }
.dm-track { position: relative; height: 10px; border-radius: 6px; background: rgba(255, 255, 255, .06); }
.dm-track .dm-fill { position: absolute; inset: 0 auto 0 0; border-radius: 6px; background: linear-gradient(90deg, #b8883a, #e2bd6e); }
.dm-track .dm-fill.over { background: linear-gradient(90deg, #b8883a, #e0605f); }
.dm-track .dm-mark { position: absolute; top: -5px; bottom: -5px; width: 2px; border-radius: 2px; background: var(--text); box-shadow: 0 0 0 2px #111113; }
.dm-scale { display: flex; justify-content: space-between; font-size: .72rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.hp-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-top: .4rem; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--border); }
.hp-facts > div { background: #131315; padding: .6rem .8rem; display: grid; gap: .1rem; min-width: 0; }
.hp-facts span { font-size: .72rem; color: var(--muted); }
.hp-facts b { font-size: .98rem; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hp-chart .legend { margin-top: .35rem; }
.hp-chart .chart-svg { max-height: 230px; }

.gap-line { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; font-size: .84rem; color: var(--text-2); }
.gap-line b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---- corrections ---- */
.corr-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.corr-list li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .15rem .7rem; padding: .6rem 0; border-top: 1px solid var(--hairline); font-size: .86rem; }
.corr-list li:first-child { border-top: 0; padding-top: 0; }
.corr-list .corr-m { font-weight: 640; font-variant-numeric: tabular-nums; min-width: 4.6rem; }
.corr-list .corr-v { font-variant-numeric: tabular-nums; }
.corr-list s { color: var(--faint); }
.corr-list small { grid-column: 2; color: var(--faint); font-size: .76rem; }

/* ---- admin: strategy sub-navigation ---- */
.strat-tabs { display: flex; gap: .25rem; flex-wrap: wrap; align-items: center; margin: 0 0 1.25rem; padding: .3rem; border: 1px solid var(--border); border-radius: 13px; background: rgba(0, 0, 0, .22); width: max-content; max-width: 100%; overflow-x: auto; }
.strat-tabs a { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .85rem; border-radius: 9px; color: var(--muted); font-weight: 560; font-size: .9rem; white-space: nowrap; }
.strat-tabs a .icon { width: 15px; height: 15px; }
.strat-tabs a:hover { color: var(--text); text-decoration: none; background: rgba(255, 255, 255, .04); }
.strat-tabs a.active { background: var(--surface-4); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, .07) inset, 0 1px 3px rgba(0, 0, 0, .4); }
.strat-tabs .badge { margin-left: .1rem; }

/* ---- admin: import tool ---- */
.tool-grid { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1280px) { .tool-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); } }
.tool-grid > * { min-width: 0; }
.tool-card { display: grid; gap: 1rem; }
.tool-card .pills { margin-bottom: 0; width: 100%; }
.tool-card .pills a { flex: 1; justify-content: center; }
.dropzone { display: grid; place-items: center; gap: .45rem; padding: 1.6rem 1rem; border: 1.5px dashed rgba(212, 167, 82, .35); border-radius: 14px; background: radial-gradient(80% 120% at 50% 0%, rgba(212, 167, 82, .07), transparent 70%); text-align: center; }
.dropzone .icon { width: 26px; height: 26px; color: var(--gold-3); }
.dropzone input[type=file] { max-width: 100%; }
.dropzone p { margin: 0; font-size: .84rem; color: var(--muted); max-width: 52ch; }
.paste-area { min-height: 230px; font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: .82rem; line-height: 1.5; tab-size: 8; white-space: pre; }
.format-list { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; font-size: .84rem; color: var(--text-2); }
.format-list li { display: flex; gap: .55rem; align-items: flex-start; }
.format-list .icon { width: 15px; height: 15px; color: var(--gold-3); margin-top: .15rem; flex: none; }
.record-card .heat td { min-width: 46px; }
.ev-files { display: grid; gap: .5rem; }
.ev-file { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .75rem; align-items: center; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 11px; background: rgba(255, 255, 255, .02); }
.ev-file.withdrawn { opacity: .55; }
.ev-file .li-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--accent-soft); color: var(--gold-2); }
.ev-file .li-icon .icon { width: 17px; height: 17px; }

/* preview diff */
.grade-shift { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.grade-shift .icon { color: var(--faint); }
.grade-shift .gs-col { display: grid; gap: .2rem; justify-items: center; font-size: .74rem; color: var(--muted); }
.diff-heat td { position: relative; text-align: center; font-variant-numeric: tabular-nums; font-size: .8rem; padding: .45rem .3rem; min-width: 52px; }
.diff-heat td.c-new { box-shadow: inset 0 0 0 1.5px rgba(226, 189, 110, .75); background: rgba(226, 189, 110, .1); color: var(--text); }
.diff-heat td.c-changed { box-shadow: inset 0 0 0 1.5px rgba(242, 181, 74, .8); background: rgba(242, 181, 74, .13); color: #f8d38a; font-weight: 640; }
.diff-heat td.c-changed s { display: block; font-size: .68rem; color: var(--faint); font-weight: 500; }
.diff-heat td.c-same { color: var(--muted); }
.diff-heat td.c-kept { color: var(--faint); }
.diff-heat td.c-removed { box-shadow: inset 0 0 0 1.5px rgba(240, 107, 111, .7); background: rgba(240, 107, 111, .1); color: #f6858a; }
.diff-heat td.c-removed span { text-decoration: line-through; }
.diff-legend { display: flex; flex-wrap: wrap; gap: .45rem 1rem; font-size: .78rem; color: var(--muted); }
.diff-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .35rem; vertical-align: -2px; }
.diff-legend .l-new { box-shadow: inset 0 0 0 1.5px rgba(226, 189, 110, .75); background: rgba(226, 189, 110, .1); }
.diff-legend .l-changed { box-shadow: inset 0 0 0 1.5px rgba(242, 181, 74, .8); background: rgba(242, 181, 74, .13); }
.diff-legend .l-removed { box-shadow: inset 0 0 0 1.5px rgba(240, 107, 111, .7); background: rgba(240, 107, 111, .1); }
.diff-legend .l-same { background: rgba(255, 255, 255, .06); }
.apply-bar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; justify-content: space-between; padding: .85rem 1.1rem; margin-top: 1.25rem; border: 1px solid rgba(212, 175, 95, .28); border-radius: 14px; background: rgba(17, 17, 19, .94); backdrop-filter: blur(8px); box-shadow: var(--shadow-lg); }
.apply-bar .row-tight { gap: .5rem; }
.num-old { color: var(--faint); text-decoration: line-through; }

/* sources */
.src-card { display: grid; gap: .9rem; }
.src-head { display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: center; }
.src-head h3 { margin: 0; font-size: 1rem; }
.src-cols { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .src-cols { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } }
.src-cols > * { min-width: 0; }
.mini-months { display: flex; flex-wrap: wrap; gap: .35rem; }
.mini-months span { font-size: .76rem; padding: .2rem .45rem; border-radius: 6px; background: rgba(255, 255, 255, .05); font-variant-numeric: tabular-nums; }
.publish-box { display: grid; gap: .75rem; padding: 1rem; border: 1px solid rgba(212, 175, 95, .28); border-radius: 14px; background: radial-gradient(90% 140% at 100% 0%, rgba(212, 167, 82, .08), transparent 60%), rgba(255, 255, 255, .015); }
.publish-box textarea { min-height: 170px; }
.rules-grid { display: grid; gap: .75rem 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); }

/* ---- member: copy safety plan ---- */
.plan-card { display: grid; gap: 1rem; }
.plan-grid { display: grid; gap: 1rem 1.5rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 980px) { .plan-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); } }
.plan-grid > * { min-width: 0; }
.plan-stops { display: grid; gap: .5rem; }
.plan-stops label.check { align-items: center; }
.plan-impact { display: grid; gap: .5rem; padding: .9rem 1rem; border-radius: 12px; border: 1px solid var(--border); background: rgba(255, 255, 255, .025); font-size: .9rem; }
.plan-impact b { font-variant-numeric: tabular-nums; }

/* ---- admin: history ---- */
.rev-list { display: grid; gap: .9rem; }
.rev { display: grid; gap: .6rem; }
.rev-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; }
.rev-head .v { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--gold-2); }
.rev-head code { font-size: .72rem; color: var(--faint); }
.rev-changes { display: grid; gap: .5rem; }
.rev-field { display: grid; grid-template-columns: minmax(110px, 180px) minmax(0, 1fr); gap: .6rem; font-size: .85rem; align-items: start; }
.rev-field > span:first-child { color: var(--muted); }
.rev-field .old { color: #f6858a; text-decoration: line-through; overflow-wrap: anywhere; }
.rev-field .new { color: #5fd89c; overflow-wrap: anywhere; }
.diff-lines { margin: 0; padding: .55rem .7rem; border-radius: 9px; background: rgba(0, 0, 0, .3); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .76rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 360px; overflow: auto; }
.diff-lines .add { color: #5fd89c; display: block; background: rgba(70, 201, 138, .07); }
.diff-lines .del { color: #f6858a; display: block; background: rgba(240, 107, 111, .07); }
.diff-lines .ctx { color: var(--faint); display: block; }
@media (max-width: 640px) { .rev-field { grid-template-columns: minmax(0, 1fr); gap: .15rem; } }
@media (min-width: 1280px) {
  .tool-grid > .tool-card { position: sticky; top: 76px; }
  .tool-grid.wide-left { grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr); }
}
.diff-heat td, .diff-heat th { white-space: nowrap; }
/* The track-record tools use the full width of large screens (the rest of the admin stays at 1280px). */
body.admin .content:has(> .track-wide) { max-width: 1780px; }
.tool-card > *, .record-card > *, .plan-card > *, .src-card > * { min-width: 0; }
.ev-ok { color: var(--success); display: inline-flex; vertical-align: -2px; }
.ev-ok .icon { width: 13px; height: 13px; }
