:root {
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1c1f24;
  --muted: #5d6470;
  --line: #dde1e6;
  --accent: #0e7490;
  --ok: #15803d;
  --warn: #b45309;
  --err: #b91c1c;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  background: #111827;
  color: #fff;
}
.top h1 { font-size: 1.15rem; margin: 0; }
.pills { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pill { font-size: 0.75rem; padding: 0.2rem 0.6rem; border-radius: 999px; background: #374151; }
.pill.ok { background: var(--ok); }
.pill.err { background: var(--err); }
.pill.user { display: inline-flex; gap: 0.3rem; align-items: center; margin: 0; }
.pill.user[hidden] { display: none; }
.pill.user button { font: inherit; color: inherit; background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

main { max-width: 1100px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; min-width: 0; }
.card h2 { margin: 0 0 0.75rem; font-size: 1rem; display: inline; }
.card > h2 { display: block; }
summary { cursor: pointer; margin-bottom: 0.75rem; }

.row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; margin: 0.75rem 0; }
.grid label, .fields label { display: grid; gap: 0.25rem; font-size: 0.85rem; color: var(--muted); }

input, select {
  font: inherit;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-width: 0;
}

.btn { font: inherit; padding: 0.55rem 0.9rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

progress { width: 100%; height: 0.6rem; }
.status { min-height: 1.4em; margin: 0.5rem 0 0; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.err { color: var(--err); }
.hint { font-size: 0.85rem; color: var(--muted); }

.canvas-wrap { overflow: hidden; border-radius: 8px; background: #222; }
#view { display: block; width: 100%; height: auto; cursor: pointer; }

.legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: 0.8rem; color: var(--muted); }
.dot { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 3px; margin-right: 0.3rem; vertical-align: -1px; }
.dot.ok { background: #22c55e; }
.dot.fixed { background: #3b82f6; }
.dot.low { background: #eab308; }
.dot.edited { background: #f97316; }
.dot.empty { background: #ef4444; }

/* ---------- skyttar ---------- */
#shooters { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 470px), 1fr)); }
.shooter { border: 1px solid var(--line); border-radius: 10px; padding: 0.75rem; min-width: 0; }
.shooter-head { display: grid; gap: 0.5rem; margin-bottom: 0.5rem; }
.card-crop { display: block; width: 100%; max-width: 22rem; height: auto; border-radius: 6px; border: 1px solid #ddd; cursor: zoom-in; }
.card-crop.big { max-width: 100%; cursor: zoom-out; }
.card-box { display: grid; gap: 0.4rem; justify-items: start; }
.btn.small { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
#view.adjusting { touch-action: none; }
.check { display: flex; align-items: baseline; gap: 0.4rem; margin: 0.6rem 0 0.2rem; }
.claude-only[hidden] { display: none; }
.check .hint { margin: 0; }
.fields input.low { background: #fef9c3; border-color: #eab308; }
.fields { display: grid; grid-template-columns: 1fr 5rem; gap: 0.5rem; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.protocol th, .protocol td { border: 1px solid var(--line); padding: 0.2rem; text-align: center; white-space: nowrap; }
.protocol th { background: #f9fafb; font-weight: 600; font-size: 0.8rem; padding: 0.3rem 0.4rem; }
.protocol td.shot { padding: 0.15rem; }
.thumb { display: block; width: 2.6rem; height: 1.7rem; margin: 0 auto 0.15rem; border-radius: 3px; }
.thumb.wide { width: 3.6rem; }
.protocol input { width: 2.6rem; text-align: center; padding: 0.25rem 0; font-weight: 600; }
.protocol input.fixed { background: #dbeafe; border-color: #3b82f6; }
.protocol input.claude { background: #ede9fe; border-color: #7c3aed; }
.dot.claude { background: #7c3aed; }
.protocol input.low { background: #fef9c3; border-color: #eab308; }
.protocol input.edited { background: #ffedd5; border-color: #f97316; }
.protocol input.empty { background: #fee2e2; border-color: #ef4444; }
.protocol input.bad { outline: 2px solid var(--err); }
.protocol td.sum { font-weight: 700; min-width: 2.5rem; }
.protocol td.read { font-size: 0.8rem; }
.protocol tr.mismatch td.sum { background: #fee2e2; }
.protocol td.xcount { text-align: right; color: var(--muted); font-size: 0.85rem; }
.protocol .read span.ok { color: var(--ok); }
.protocol .read span.bad { color: var(--err); font-weight: 600; }

#summary th, #summary td { border-bottom: 1px solid var(--line); padding: 0.4rem 0.75rem; text-align: left; }
#summary td:nth-child(n+3) { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- sparade resultat ---------- */
.filters { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.filters label { display: grid; gap: 0.25rem; font-size: 0.85rem; color: var(--muted); }
.results { width: 100%; }
.results th, .results td { border-bottom: 1px solid var(--line); padding: 0.35rem 0.5rem; text-align: right; white-space: nowrap; }
.results th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.results .name { text-align: left; }
.results .pick { width: 2rem; text-align: center; }
.results .tot { font-weight: 700; }
.results .series { color: var(--muted); font-size: 0.85rem; }
.results tr.comp td { background: #f3f4f6; text-align: left; white-space: normal; border-top: 2px solid var(--line); }
.results tbody.ext tr.comp td { background: #fff7ed; }
.results tr.comp .actions { float: right; display: inline-flex; gap: 0.3rem; }
.results td.res-image { text-align: left; white-space: normal; background: #fafafa; }
.results td.res-image img { display: block; max-width: min(100%, 40rem); height: auto; border: 1px solid var(--line); border-radius: 6px; }
.badge { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 0.1rem 0.45rem; border-radius: 999px; background: #e5e7eb; color: var(--muted); vertical-align: 1px; }
.badge.ext { background: #fed7aa; color: #9a3412; }

/* ---------- utskrift: resultatlista i klubbens stil (Calibri, tunna linjer, fet topp 3) ---------- */
#printout { display: none; }
@media print {
  @page { size: A4 portrait; margin: 15mm; }
  body > *:not(#printout) { display: none !important; }
  :root, body { background: #fff !important; }
  #printout { display: block; color: #000; font-family: Calibri, Carlito, Arial, sans-serif; font-size: 9pt; }
  #printout .p-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4mm; }
  #printout .p-title { font-weight: 700; font-size: 13pt; }
  #printout .p-date { font-weight: 700; }
  #printout .p-table { border-collapse: collapse; width: 100%; }
  #printout th, #printout td { border: 0.5pt solid #999; padding: 1pt 4pt; text-align: right; white-space: nowrap; }
  #printout th { font-weight: 700; background: #eee; }
  #printout .plac { width: 1%; text-align: center; }
  #printout .name { text-align: left; width: 99%; }
  #printout .tot { font-weight: 700; }
  #printout tr.p-top .plac { font-weight: 700; }
  #printout tr { break-inside: avoid; }
  #printout .p-gap { height: 10mm; }
  #printout th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
