/* Stafettkoll – mörkt tema med hög kontrast (läsbart i skogen, natt & dag) */
:root {
  --bg: #10151c;
  --panel: #1a2230;
  --panel2: #222c3d;
  --text: #e8edf4;
  --dim: #93a1b5;
  --line: #2c3950;
  --gold: #ffc83d;
  --green: #4cd97b;
  --orange: #ff9838;
  --red: #ff6b6b;
  --blue: #58b0ff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(58px + env(safe-area-inset-bottom));
}

#topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 12px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
#compname { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#status { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
#updated { font-size: 12px; color: var(--dim); }
#updated.offline { color: var(--red); font-weight: 700; }
#settingsBtn { background: none; border: none; color: var(--dim); font-size: 20px; padding: 4px 6px; }

#banner {
  position: sticky; top: 45px; z-index: 9;
  background: var(--orange); color: #221200;
  font-weight: 800; font-size: 16px;
  padding: 10px 14px; text-align: center;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { filter: brightness(1.18); } }

#classchips {
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px;
  scrollbar-width: none;
}
#classchips::-webkit-scrollbar { display: none; }
#classchips button {
  flex-shrink: 0; padding: 7px 14px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text); font-size: 14px; font-weight: 600;
}
#classchips button.active { background: var(--blue); border-color: var(--blue); color: #04121f; }
#classchips button .done { color: inherit; opacity: .7; font-size: 11px; }

main { padding: 0 10px 16px; }
h3.section {
  margin: 14px 4px 6px; font-size: 12px; font-weight: 700;
  color: var(--dim); text-transform: uppercase; letter-spacing: .06em;
}

/* Lagkort */
.team {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; margin-bottom: 6px;
}
.team.starred { border-color: var(--gold); background: #201f16; }
.team.forvarn { border-color: var(--orange); box-shadow: 0 0 0 1px var(--orange); animation: pulse 1.2s infinite; }
.teamhead { display: flex; align-items: baseline; gap: 8px; }
.place { font-weight: 800; font-size: 17px; min-width: 26px; text-align: right; color: var(--blue); }
.tname { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tplus { color: var(--dim); font-variant-numeric: tabular-nums; font-size: 14px; }
.starbtn { background: none; border: none; font-size: 20px; color: var(--dim); padding: 2px 4px; line-height: 1; }
.starbtn.on { color: var(--gold); }

.runner { display: flex; align-items: center; gap: 8px; margin-top: 6px; padding-left: 34px; font-size: 14px; }
.runner .ico { flex-shrink: 0; width: 18px; text-align: center; }
.runner .rname { font-weight: 600; flex-shrink: 0; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runner .rinfo { color: var(--dim); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.runner.klar .ico { color: var(--green); }
.runner.ute .ico { color: var(--blue); }
.runner.ute .rinfo { color: var(--text); }
.runner.forvarn .rinfo, .runner.forvarn .ico { color: var(--orange); font-weight: 700; }
.runner.vantar { opacity: .55; }
.runner.bruten .ico { color: var(--red); }

.splitsrow { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 4px 0 2px 60px; }
.chip {
  font-size: 12px; color: var(--dim); background: var(--panel2);
  border-radius: 5px; padding: 1px 6px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chip small { opacity: .8; }
.chip.f { color: var(--orange); background: rgba(255,152,56,.14); }

.progress { height: 3px; background: var(--line); border-radius: 2px; margin: 5px 0 2px 34px; overflow: hidden; }
.progress > div { height: 100%; background: var(--blue); border-radius: 2px; }
.forvarn .progress > div { background: var(--orange); }

.gap { text-align: center; color: var(--dim); font-size: 13px; padding: 2px 0; }

/* Mina lag-kort */
.mycard { margin-bottom: 12px; }
.mycard .legrow { display: flex; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); font-size: 14px; align-items: flex-start; }
.mycard .legrow:first-of-type { border-top: none; }
.mycard .legno { flex-shrink: 0; width: 46px; color: var(--dim); font-weight: 700; font-size: 12px; padding-top: 2px; }
.mycard .legrow.current { background: linear-gradient(90deg, rgba(88,176,255,.12), transparent); border-radius: 6px; }
.mycard .legrow.current .legno { color: var(--blue); }
.legbody { flex: 1; min-width: 0; }
.legbody .runner { padding-left: 0; margin-top: 2px; }
.legbody .progress { margin-left: 0; }
.legbody .splitsrow { margin-left: 26px; }
.hint { margin-top: 6px; padding: 6px 8px; border-radius: 6px; background: rgba(255,152,56,.15); color: var(--orange); font-size: 13px; font-weight: 600; }

/* Sök & lista */
.search { width: 100%; padding: 10px 12px; margin: 6px 0; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 16px; }
details.alla summary { padding: 10px 4px; color: var(--blue); font-weight: 600; cursor: pointer; list-style: none; }
details.alla summary::before { content: '▸ '; }
details.alla[open] summary::before { content: '▾ '; }

/* Passeringar */
.pass { display: flex; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 14px; align-items: baseline; }
.pass .at { color: var(--dim); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.pass .who { font-weight: 600; flex: 1; min-width: 0; }
.pass .who small { color: var(--dim); font-weight: 400; }
.pass.starred { background: #201f16; border-left: 3px solid var(--gold); }
.filterrow { display: flex; gap: 8px; align-items: center; padding: 8px 4px; color: var(--dim); font-size: 14px; }

.empty { color: var(--dim); text-align: center; padding: 28px 16px; font-size: 15px; }
.empty b { color: var(--text); }

/* Flikar */
#tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: var(--panel);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs button {
  flex: 1; padding: 14px 4px; background: none; border: none;
  color: var(--dim); font-size: 14px; font-weight: 700;
}
#tabs button.active { color: var(--gold); }

/* Inställningar */
dialog {
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); color: var(--text);
  width: min(92vw, 380px); padding: 18px;
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { font-size: 17px; margin-bottom: 12px; }
dialog label { display: block; margin-bottom: 12px; font-size: 14px; color: var(--dim); }
dialog label.row { display: flex; gap: 8px; align-items: center; color: var(--text); }
dialog input[type=text], dialog select {
  width: 100%; margin-top: 4px; padding: 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 16px;
}
dialog menu { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
dialog menu button { padding: 10px 18px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-size: 15px; font-weight: 600; }
dialog menu button#settingsOk { background: var(--blue); border-color: var(--blue); color: #04121f; }
