/* Modernes Live-Ergebnis-UI — PLAN-FRONTEND.md, Revision 2. */

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/static/fonts/manrope-latin.woff2") format("woff2");
}

:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --ink: #0b1220;
  --muted: #5a6675;
  --line: #e5e8ee;
  --dark: #0b1220;
  --lime: #c6f24e;
  --green: #15803d;
  --green-soft: #e8f5ec;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --slate-soft: #f1f5f9;
  --fresh: #f6fde8;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.4;
  font-feature-settings: "tnum" 0;
}

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 28px; }

/* --------------------------------------------------------------- Kopf */

.top { background: var(--dark); color: #fff; }

.top-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding-top: 12px;
  padding-bottom: 12px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand:hover { text-decoration: none; }

.mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #fff;
  color: var(--dark);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .18);
  overflow: hidden;
}
.mark img { width: 32px; height: 32px; display: block; }

.brandtext { display: flex; flex-direction: column; gap: 1px; }

.kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--lime);
}

.event { font-size: 18px; font-weight: 650; letter-spacing: -.01em; color: #fff; }

.topmeta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .02em;
}
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); animation: blink 2s infinite; }
.live.pulse { animation: pop .4s ease; }

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes pop { 0% { opacity: .4; } 100% { opacity: 1; } }

.clock { font-size: 13px; color: rgba(255, 255, 255, .6); font-variant-numeric: tabular-nums; }

.ghost {
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  transition: background .15s, border-color .15s;
}
.ghost:hover { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .3); text-decoration: none; }

button.ghost { font: inherit; cursor: pointer; background: transparent; appearance: none; }
.topmeta form { margin: 0; display: inline-flex; }

/* ------------------------------------------------------- Hauptnavigation */

.mainnav { background: var(--surface); border-bottom: 1px solid var(--line); }

.mainnav-inner {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.mainnav-inner::-webkit-scrollbar { display: none; }

.mainnav-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 13px 16px;
  margin-bottom: -1px;
  border-bottom: 3px solid transparent;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.mainnav-item:hover { color: var(--ink); text-decoration: none; }
.mainnav-item.active { color: var(--ink); border-bottom-color: var(--lime); }
.mainnav-item.active .mainnav-digit { background: var(--dark); color: #fff; }

.mainnav-digit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 3px;
  border-radius: 5px;
  background: var(--slate-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 700px) {
  .mainnav-inner { flex-wrap: wrap; overflow-x: visible; }
  .mainnav-item { padding: 10px 11px; font-size: 12.5px; }
}

.flash {
  margin-bottom: 18px;
  padding: 11px 16px;
  border-radius: 10px;
  background: var(--fresh);
  color: #166534;
  font-size: 13.5px;
  font-weight: 650;
  box-shadow: inset 3px 0 0 var(--green);
}

.pending-banner { background: var(--amber-soft); border-bottom: 1px solid var(--amber); }
.pending-item {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13.5px;
  font-weight: 600;
  color: #7a4e00;
}
.pending-item form { margin: 0; }

.dns-zone { margin-top: 16px; opacity: .85; }
.dns-zone h2 { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.rowactions { display: flex; gap: 8px; }
.rowactions form { margin: 0; }

/* ------------------------------------------------------------- Seite */

.page { padding-top: 24px; padding-bottom: 40px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  background: #e8ecf1;
  border-radius: 12px;
}
.seg-item {
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.seg-item:hover { color: var(--ink); text-decoration: none; }
.seg-item.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }

.hint-inline { font-size: 12px; color: var(--muted); }

/* Kategorie-Tabs */
.cat-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  max-width: 100%;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  margin-bottom: -1px;
  border-bottom: 3px solid transparent;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.cat-tab:hover { color: var(--ink); text-decoration: none; }
.cat-tab.active { color: var(--ink); border-bottom-color: var(--lime); }
.cat-tab .n {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--slate-soft);
  color: var(--muted);
}
.cat-tab.active .n { background: var(--dark); color: #fff; }
#live.loading { opacity: .55; transition: opacity .1s; }
@media (max-width: 640px) {
  .cat-tabs { flex-wrap: wrap; overflow-x: visible; }
  .cat-tab { padding: 8px 10px; font-size: 12.5px; }
  .toolbar { gap: 8px; }
}

/* ------------------------------------------------------------ Metriken */

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.metric .k { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.metric .v { font-size: 26px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric .v.small { font-size: 15px; font-weight: 650; letter-spacing: 0; }
.metric .v.ok { color: var(--green); }
.metric .v.error { color: #b91c1c; }
.metric .v.warn { color: var(--amber); }

/* -------------------------------------------------------- Wettkampftag */

.dashbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.dashbar-status, .dashbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dashbar-label { font-size: 13px; font-weight: 650; color: var(--ink); }

.popover-wrap { position: relative; display: inline-flex; }

.popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5;
  width: 240px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--dark);
  color: #fff;
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: 0 8px 20px rgba(16, 24, 40, .25);
}

@media (max-width: 700px) {
  .dashbar { padding: 10px; }
  .dashbar-status, .dashbar-actions { gap: 8px; }
}

/* -------------------------------------------------------------- Karten */

.cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tablecard { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  z-index: 1;
}

tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafc; }

tr.fresh { background: var(--fresh); box-shadow: inset 3px 0 0 var(--lime); }
tr.fresh:hover { background: #f0fbdc; }

td.rank { width: 56px; font-size: 19px; font-weight: 750; font-variant-numeric: tabular-nums; }
td.rank.first { font-weight: 800; }

td.name { min-width: 230px; }
td.name a { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
td.name a:hover { text-decoration: underline; text-underline-offset: 3px; }
td.name .club { display: block; margin-top: 2px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

td.cat { width: 70px; font-size: 12.5px; color: var(--muted); }

td.loops { width: 120px; }
.loop {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--slate-soft);
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}
.loop + .loop { margin-left: 4px; }

td.num { text-align: right; font-size: 14px; font-variant-numeric: tabular-nums; color: #334155; }
th.num { text-align: right; }

td.total { font-size: 22px; font-weight: 750; letter-spacing: -.02em; color: var(--ink); padding-left: 18px; }

td.time { text-align: right; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }

td.status { width: 150px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  background: var(--slate-soft);
  color: #475569;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.late { background: var(--amber-soft); color: var(--amber); }
.pill.no_finish { background: var(--slate-soft); color: #64748b; }
.pill.dsq { background: var(--red-soft); color: var(--red); }

.tag.warn { background: var(--amber-soft); color: var(--amber); }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

/* --------------------------------------------------------------- Feed */

.feed { padding: 16px; }
.feed h2 { margin: 0 0 8px; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.feed ol { list-style: none; margin: 0; padding: 0; }
.feed li + li { border-top: 1px solid var(--line); }
.feed li a { display: block; padding: 10px 8px; margin: 0 -8px; border-radius: 10px; }
.feed li a:hover { background: #f8fafc; text-decoration: none; }
.feed-name { display: block; font-size: 14px; font-weight: 650; }
.feed-meta { display: block; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.feed .hint { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------- Detail */

.back { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.back:hover { color: var(--ink); }

.person { padding: 24px; margin-bottom: 18px; }

.person .kicker { color: var(--green); }
.person h2 { margin: 2px 0 14px; font-size: clamp(30px, 4vw, 40px); font-weight: 750; letter-spacing: -.025em; line-height: 1.05; }

.scoreline { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; font-size: 14px; color: var(--muted); }
.score { font-size: 56px; font-weight: 800; line-height: .9; letter-spacing: -.04em; color: var(--ink); font-variant-numeric: tabular-nums; }
.unit { font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.sep { width: 1px; height: 22px; background: var(--line); }

.chipno { margin-top: 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.block { margin-top: 18px; }
.block .card { padding: 18px 20px; }
.block h3 { margin: 0 0 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

table.loops { margin-top: 6px; }
table.loops th { position: static; }
table.loops td, table.loops th { padding: 9px 10px; }
table.loops td { font-size: 13.5px; }
table.loops th:nth-child(1) { width: 84px; }
table.loops th:nth-child(2) { width: 80px; }
table.loops th:nth-child(3) { width: 170px; }
table.loops th:nth-child(4) { width: 110px; }
table.loops th:nth-child(5) { width: 160px; }
table.loops tr.ok td:nth-child(3) { color: var(--green); font-weight: 650; }
table.loops tr.bad td:nth-child(3) { color: #b91c1c; font-weight: 650; }

.protocol { margin: 8px 0 0; padding: 0; list-style: none; }
.protocol li {
  display: flex;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--muted);
}
.protocol li::before {
  content: counter(step, decimal-leading-zero);
  counter-increment: step;
  flex: 0 0 24px;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.protocol { counter-reset: step; }

/* --------------------------------------------------------------- Fuss */

.foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  padding-bottom: 28px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

/* ------------------------------------------------------------ Schmal */

@media (max-width: 1100px) {
  .cols { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  td.name { min-width: 190px; }
}

@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .top-inner { min-height: 64px; }
  .event { font-size: 16px; }
  .metrics { gap: 10px; }
  .metric { padding: 12px; }
  .metric .v { font-size: 22px; }
  td.cat, th.cat { display: none; }
  td.name { min-width: 150px; }
  td.name a { font-size: 15px; }
  td.total { font-size: 19px; }
  td.loops { width: auto; }
  .clock { display: none; }
}

/* ------------------------------------------------ Korrektur / Jury */

.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  vertical-align: middle;
}

.auto { font-style: normal; font-weight: 600; letter-spacing: 0; text-transform: none; color: #94a3b8; margin-left: 6px; }

.h3note { margin-left: 8px; font-weight: 600; letter-spacing: .02em; text-transform: none; color: #94a3b8; }

.edit { padding: 16px 20px 18px; }

.editform { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.field input, .field select {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 10px;
}
.field input:focus, .field select:focus {
  outline: 2px solid rgba(34, 197, 94, .35);
  outline-offset: 1px;
  border-color: #86efac;
}
.field.wide { grid-column: 1 / -1; }

.formactions { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #1e293b; }
.btn.ghost { background: transparent; color: var(--muted); }

.formerror { margin: 0 0 12px; padding: 10px 12px; border-radius: 9px; background: #fef2f2; color: #b91c1c; font-size: 13px; font-weight: 600; }
.editinfo { margin: 0 0 12px; padding: 10px 12px; border-radius: 9px; background: #f8fafc; color: #334155; font-size: 13px; }

.quickactions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.audit { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.audit h4 { margin: 0 0 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.audit ul { margin: 0; padding: 0; list-style: none; }
.audit li { font-size: 12.5px; color: #475569; padding: 3px 0; }
.muted { color: var(--muted); }

.massform { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; }
.massform .field { min-width: 190px; }
.massform .formactions { grid-column: auto; }

.starttable td, .starttable th { padding: 10px 12px; }
.starttable .who { font-weight: 650; }

.paid-filter { display: flex; gap: 6px; }
.paid-filter a {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
  text-decoration: none;
  background: var(--slate-soft);
}
.paid-filter a.active { background: var(--ink); color: #fff; }
.paidtoggle.yes { background: var(--green-soft); color: var(--green); border-color: transparent; }
.paidtoggle.no { background: var(--slate-soft); color: #64748b; border-color: transparent; }
.inlineform { display: flex; align-items: center; gap: 8px; }
.inlineform .btn { padding: 8px 12px; }
.massform .formactions { align-items: center; padding-bottom: 1px; }
.starttable input[type="time"] {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 9px;
}
.starttable input[type="time"]:focus {
  outline: 2px solid rgba(34, 197, 94, .35);
  outline-offset: 1px;
  border-color: #86efac;
}

@media (max-width: 720px) {
  .editform { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------- Hilfe */

.help { max-width: 760px; }
.help-steps li { padding-left: 4px; }
.help-steps li strong { color: var(--ink); }

.help-faq details {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.help-faq details:first-child { border-top: 0; padding-top: 0; }
.help-faq summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
}
.help-faq summary:focus-visible { outline-offset: 4px; }
.help-faq p { margin: 10px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.6; }

@media print {
  body { background: #fff; }
  .top { background: #fff; color: #000; }
  .event, .kicker { color: #000; }
  .mark, .live, .clock, .ghost, .toolbar, .feed, .back, .foot, .flash, .topmeta form,
  .mainnav, .dashbar, .pending-banner { display: none; }
  .cols { display: block; }
  .card { box-shadow: none; border-color: #999; }
  thead th { background: #eee; }
  .help-faq details { break-inside: avoid; }
}
