/* CSV Cleaner. Only this tool's own pieces; everything else is the shared tool frame.
   Colours come from the site's variables only (tests/catalogue.test.mjs checks there are no hex values here).
   Highlights never rely on colour alone: changed, added and removed cells also carry text labels or patterns. */

#tool-form, .cc-paper { --cc-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* Choosing a file */
.cc-drop { border: 2px dashed var(--silver); border-radius: var(--r-card); padding: 16px; display: grid; gap: 8px; justify-items: start; }
.cc-drop.is-over { border-color: var(--graphite); background: var(--mist); }
.cc-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.cc-file:focus-visible + #cc-start .cc-drop label { outline: 3px solid var(--graphite); outline-offset: 2px; }
.cc-drop .field__hint { margin: 0; }
.cc-paste { width: 100%; min-height: 110px; resize: vertical; font-size: 16px; font-family: var(--cc-mono); }
#cc-use-paste { margin-top: 10px; min-height: 44px; }
.cc-status { margin: 12px 0 0; font-weight: 600; }

/* Questions, stops and refusals */
.cc-ask { margin-top: 14px; }
.cc-msg { border: 2px solid var(--graphite); border-radius: var(--r-card); padding: 14px; display: grid; gap: 10px; }
.cc-msg p { margin: 0; }
.cc-msg--warn { border-style: solid; background: var(--mist); }
.cc-q { font-weight: 650; font-size: 17px; }
.cc-choice { margin: 0; display: grid; gap: 8px; }
.cc-pick { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--silver); border-radius: var(--r-btn); cursor: pointer; }
.cc-pick input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--graphite); }
.cc-pick:has(input:checked) { box-shadow: inset 0 0 0 2px var(--graphite); }
.cc-pick__b { display: grid; gap: 4px; min-width: 0; }
.cc-sample { font-family: var(--cc-mono); font-size: 14px; overflow-wrap: anywhere; color: var(--slate); }
.cc-line { font-family: var(--cc-mono); font-size: 14px; overflow-wrap: anywhere; background: var(--white); border: 1px solid var(--silver); border-radius: var(--r-ctl); padding: 6px 8px; }
.cc-line__n { display: block; font-family: inherit; color: var(--steel); font-size: 12px; }
.cc-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.cc-btns .btn, .cc-msg > .btn { min-height: 44px; justify-self: start; }
.cc-inline { max-width: 260px; }
.cc-larger { margin-top: 12px; }

/* Ticks: a real checkbox, 44px tall to tap */
.cc-tick { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 10px 0; cursor: pointer; line-height: 1.4; }
.cc-tick input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--graphite); }

/* The file, in one line once it's read */
.cc-about { margin-top: 4px; display: grid; gap: 10px; }
.cc-fileline { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.cc-fileline__t { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.cc-read { display: block; color: var(--slate); font-size: 15px; }
.cc-link.cc-change { min-height: 44px; display: inline-flex; align-items: center; }
.cc-utf8 { margin: 0; font-size: 15px; color: var(--slate); }
.cc-presets { display: grid; gap: 8px; margin: 0; }
.cc-fixes, .cc-dups, .cc-save { margin-top: 26px; }
.cc-save { display: grid; gap: 10px; }
.cc-fixes__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.cc-fixes__head .label, .cc-dups .label { margin: 0; }
.cc-fixes__head .btn { min-height: 44px; }

/* What was found: one list, a line per fix */
.cc-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--silver); }
.cc-fix { border-bottom: 1px solid var(--silver); min-width: 0; }
.cc-fix__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0 10px; padding: 6px 0; }
.cc-fix__tick { display: flex; gap: 12px; align-items: flex-start; min-height: 44px; padding: 10px 0 2px; cursor: pointer; line-height: 1.35; font-weight: 600; grid-column: 1 / -1; }
.cc-fix__tick input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--graphite); }
.cc-fix__row > .cc-fix__t { grid-column: 1 / -1; padding: 10px 0 2px; font-weight: 600; }
.cc-fix__n { font-size: 14px; color: var(--slate); padding-left: 34px; }
.cc-link.cc-fix__more { justify-self: end; min-height: 44px; }
.cc-fix--pending .cc-fix__n { color: var(--graphite); font-weight: 600; }
.cc-fix__d { display: grid; gap: 8px; padding: 0 0 12px 34px; min-width: 0; }
.cc-fix__d[hidden] { display: none; }
.cc-fix__x { margin: 0; color: var(--slate); font-size: 15px; }
.cc-ex { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.cc-ex__w { display: block; color: var(--steel); font-size: 12.5px; }
.cc-ex__v { font-family: var(--cc-mono); overflow-wrap: anywhere; white-space: pre-wrap; }
.cc-arrow { color: var(--steel); }
.cc-link { border: 0; background: none; padding: 4px 2px; font: inherit; font-size: 14px; color: var(--graphite); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 32px; }
.cc-warn { margin: 6px 0; font-weight: 600; }
.cc-warn:empty { display: none; }
.cc-small { max-width: 220px; margin: 0; }
.cc-num { font-variant-numeric: tabular-nums; }
.cc-cols { margin: 4px 0 6px; display: grid; gap: 6px; }
.cc-colbtns { display: flex; gap: 10px; }
.cc-chiplist { max-height: 180px; overflow: auto; padding: 2px; }
.cc-chiplist .chip span { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.cc-items { display: grid; gap: 8px; max-height: 420px; overflow: auto; }
.cc-item { border-top: 1px solid var(--silver); padding-top: 8px; }
.cc-item__n { font-weight: 650; }
.cc-item__vals { margin: 4px 0; font-family: var(--cc-mono); font-size: 14px; overflow-wrap: anywhere; }
.cc-sepmark { color: var(--steel); }

/* Duplicates: the finding, then the groups; how rows are matched is one tap away */
.cc-dups, #cc-dup, .cc-groups, .cc-group, .cc-recs { min-width: 0; max-width: 100%; }
#cc-dup { display: grid; gap: 10px; }
.cc-dupfind { margin: 4px 0 0; }
.cc-dupfind:empty { display: none; }
.cc-dupopts .more__in { gap: 10px; }
.cc-dupopts legend { font-weight: 600; margin-bottom: 4px; }
.cc-dupkeep { align-items: center; gap: 8px; }
.cc-groups { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.cc-group { border: 1px solid var(--silver); border-radius: var(--r-btn); padding: 6px 10px; }
.cc-group summary { cursor: pointer; min-height: 44px; padding: 10px 0; font-weight: 600; }
.cc-recs { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 10px; }
.cc-rec { border: 1px solid var(--silver); border-radius: var(--r-ctl); padding: 8px 10px; }
.cc-rec.is-kept { box-shadow: inset 4px 0 0 var(--graphite); }
.cc-rec.is-going dd { text-decoration: line-through; color: var(--steel); }
.cc-rec .cc-dupst { display: flex; flex-wrap: wrap; align-items: center; gap: 0 14px; max-width: none; }
.cc-rec .cc-dupst__n { display: inline; }
.cc-rec__vals { margin: 6px 0 0; display: grid; gap: 4px; font-size: 14px; }
.cc-rec__vals > div { display: grid; grid-template-columns: minmax(6em, 38%) minmax(0, 1fr); gap: 8px; padding: 2px 4px; }
.cc-rec__vals dt { color: var(--steel); overflow-wrap: anywhere; }
.cc-rec__vals dd { margin: 0; font-family: var(--cc-mono); overflow-wrap: anywhere; white-space: pre-wrap; }
.cc-excel { margin: 6px 0; padding-left: 20px; overflow-wrap: anywhere; }

/* The preview */
.cc-filechanges { margin: 0 0 12px; font-size: 14px; color: var(--slate); }
.cc-fc__t { margin: 0 0 4px; font-weight: 650; color: var(--graphite); }
.cc-fc { margin: 0; padding-left: 18px; }
.cc-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.cc-pageinfo { margin: 8px 0; font-size: 14px; color: var(--slate); }
.cc-tablewrap { overflow: auto; max-height: 70vh; border: 1px solid var(--silver); border-radius: var(--r-ctl); -webkit-overflow-scrolling: touch; }
.cc-tablewrap:focus-visible { outline: 3px solid var(--graphite); outline-offset: 2px; }
.cc-tablewrap--mini { max-height: 260px; margin-top: 6px; }
.cc-table, .cc-mini { border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.cc-table th, .cc-table td, .cc-mini th, .cc-mini td { border-bottom: 1px solid var(--mist); border-right: 1px solid var(--mist); padding: 6px 8px; text-align: left; vertical-align: top; white-space: pre; max-width: 22em; overflow: hidden; text-overflow: ellipsis; }
.cc-table thead th { position: sticky; top: 0; background: var(--white); z-index: 2; border-bottom: 2px solid var(--silver); font-weight: 650; }
.cc-table .cc-n { position: sticky; left: 0; background: var(--white); z-index: 1; color: var(--steel); font-weight: 500; white-space: normal; min-width: 3.5em; max-width: 8em; }
.cc-table thead .cc-n { z-index: 3; }
.cc-table td { cursor: pointer; }
.cc-table td:hover { background: var(--mist); }
.cc-mini { margin: 4px 0; }
.cc-mini td { font-family: var(--cc-mono); font-size: 13px; }
.is-ch { background: var(--mist); box-shadow: inset 3px 0 0 var(--graphite); font-weight: 600; }
.is-add { box-shadow: inset 0 0 0 1px var(--steel); }
.is-drop { background: repeating-linear-gradient(135deg, var(--mist) 0 6px, var(--white) 6px 12px); color: var(--steel); }
.is-gone td { text-decoration: line-through; color: var(--steel); }
.is-head th, .is-head td { font-weight: 650; }
.is-diff { box-shadow: inset 0 0 0 2px var(--graphite); font-weight: 650; background: var(--mist); }
.is-diff-kept { box-shadow: inset 0 0 0 1px var(--steel); }
.is-flash td, .is-flash th { outline: 2px solid var(--graphite); outline-offset: -2px; }
.cc-tag { display: block; font-size: 11px; font-weight: 650; text-decoration: none; color: var(--graphite); letter-spacing: .02em; white-space: normal; }
.cc-tag--gone::before { content: "✕ "; }
.cc-tag--kept::before { content: "✓ "; }
.cc-tag--add { display: inline-block; margin-left: 4px; font-weight: 500; color: var(--steel); }
.cc-dupst { white-space: normal; min-width: 9.5em; max-width: 11em; text-align: left; font-family: inherit; }
/* The row's number, Keep/Remove and its state stay in view while the table scrolls sideways (phones). */
.cc-grouptable .cc-dupst { position: sticky; left: 0; z-index: 1; background: var(--white); box-shadow: 1px 0 0 var(--silver); }
.cc-grouptable tr.is-kept .cc-dupst { box-shadow: inset 4px 0 0 var(--graphite), 1px 0 0 var(--silver); }
.cc-grouptable tr.is-going td { text-decoration: line-through; color: var(--steel); }
.cc-dupst__n { display: block; font-weight: 650; }
.cc-dupst .cc-tick { min-height: 44px; padding: 10px 0; font-size: 14px; }
.cc-dupst .cc-tag { font-size: 12px; }
.cc-group__n { font-weight: 500; color: var(--slate); }
.cc-dupbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.cc-dupbar[hidden] { display: none; }
.cc-dupsel { margin: 0; flex: 1 1 100%; font-weight: 600; }
.cc-dupbar .btn, .cc-dupbar .cc-link { min-height: 44px; }
.cc-sp { color: var(--steel); }
.cc-inv { display: inline-block; margin: 0 1px; padding: 0 3px; border: 1px solid var(--steel); border-radius: 3px; font-size: 10px; line-height: 1.4; color: var(--slate); vertical-align: 1px; text-decoration: none; }
.cc-pager { display: flex; gap: 8px; margin-top: 8px; }
.cc-pager .btn { min-height: 44px; }
.cc-detail { margin-top: 12px; border: 1px solid var(--graphite); border-radius: var(--r-btn); padding: 12px; }
.cc-detail__t { margin: 0 0 6px; font-weight: 650; }
.cc-dl { margin: 0 0 8px; display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; }
.cc-dl dt { font-weight: 600; }
.cc-dl dd { margin: 0; }
.cc-val { font-family: var(--cc-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.cc-checked { margin: 12px 0 0; font-size: 14px; font-weight: 600; }
.cc-checked--bad { padding: 8px; border: 2px solid var(--graphite); }
.cc-empty { color: var(--slate); }

@media (max-width: 420px) {
  .cc-table th, .cc-table td { max-width: 14em; padding: 6px; }
}
@media print { .cc-pager, .cc-bar, .cc-detail { display: none; } }

/* Possible duplicates (no exact duplicates, but a column of identifiers repeats): the finding itself */
.cc-possible { display: grid; gap: 6px; }
.cc-possible[hidden] { display: none; }
.cc-possible p { margin: 0; }
.cc-possible__list { margin: 0; padding-left: 18px; font-size: 14px; overflow-wrap: anywhere; }
.cc-matchbtn { justify-self: start; min-height: 44px; }

/* The review on phones: one line per change */
.cc-changes { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--mist); }
.cc-chg { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--mist); font-size: 14px; min-width: 0; }
.cc-chg__w { color: var(--steel); font-size: 12.5px; }
.cc-chg__v { font-family: var(--cc-mono); overflow-wrap: anywhere; white-space: pre-wrap; }
.cc-chg.is-gone .cc-chg__v { color: var(--steel); }
.cc-chg__w .cc-tag { display: inline; }
.cc-pager[hidden] { display: none; }
.cc-ba[hidden] { display: none; }

/* Phones: the download at the foot of the screen, with room left under the page so nothing is covered */
.cc-mbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--white); box-shadow: 0 -1px 0 var(--silver); }
.cc-mbar[hidden] { display: none; }
.cc-mbar__t { margin: 0; font-size: 13.5px; color: var(--slate); min-width: 0; }
.cc-mbar .btn { min-height: 44px; flex: none; }
body.cc-has-mbar { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
@media print { .cc-mbar { display: none !important; } }

/* the review link scrolls here: clear of the site header */
#cc-preview .cc-bar { scroll-margin-top: 5.5rem; }
