/* Rennkalender – Stylesheet */
:root {
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #e2e5ea;
  --accent: #c8102e;
  --accent-dark: #9e0c24;
  --on-accent: #fff;
  --top: #161a22;
  --top-text: #fff;
  --on-bg: #1d2330;
  --on-bg-muted: #6b7280;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: .5rem 0 1rem; }
h2 { font-size: 1.15rem; }
.container { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.narrow { max-width: 480px; margin: 1rem auto; }
.small { font-size: .85rem; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; }
.nowrap { white-space: nowrap; }
.print-only { display: none; }

/* Kopfzeile */
.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  background: var(--top); color: var(--top-text); padding: .6rem 1rem;
  border-bottom: 4px solid var(--accent);
}
.topbar .brand { color: var(--top-text); font-weight: 700; font-size: 1.15rem; text-decoration: none; display: inline-flex; align-items: center; gap: .45rem; }
.brand-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  background: var(--bg); border-radius: 9px; box-shadow: 0 0 0 1px rgba(0,0,0,.15);
}
.brand-icon img { width: 28px; height: 28px; display: block; }
body.embed .brand-icon { width: 28px; height: 28px; border-radius: 7px; }
body.embed .brand-icon img { width: 22px; height: 22px; }
.topbar nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.topbar nav a { color: var(--top-text); opacity: .85; text-decoration: none; }
.topbar nav a:hover { opacity: 1; }
.topbar nav a.btn { color: var(--on-accent); opacity: 1; }
.pill { background: var(--accent); color: var(--on-accent); border-radius: 10px; padding: 0 .45em; font-size: .8em; }
.footer { text-align: center; color: var(--on-bg-muted); font-size: .8rem; padding: 2rem 1rem; }
.footer a { color: inherit; }
.container > h1, .settings > h1, .toolbar .period, .narrow > h1, .narrow > h2, .narrow > p, .container > p:not(.empty) { color: var(--on-bg); }
.toolbar .period small, .count { color: var(--on-bg-muted) !important; }

/* Einbettung (iFrame) */
body.embed .topbar { padding: .4rem .8rem; }
body.embed .topbar .brand { font-size: 1rem; }
body.embed .container { padding: .6rem; }

/* Buttons */
.btn {
  display: inline-block; padding: .45rem .9rem; border-radius: 6px; border: 1px solid #cfd4dc;
  background: #fff; color: var(--text); text-decoration: none; cursor: pointer; font: inherit; line-height: 1.3;
}
.btn:hover { border-color: #9aa3b0; }
.btn-sm { padding: .25rem .6rem; font-size: .88rem; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger { color: #b91c1c; border-color: #f0b4b4; }
.btn-danger:hover { background: #fdecec; }
form.inline { display: inline; }

/* Meldungen */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.flash ul { margin: 0; padding-left: 1.2rem; }
.flash-ok { background: #ecfdf3; border-color: #a7e3bf; }
.flash-warn { background: #fff8e6; border-color: #f2d48a; }
.flash-err { background: #fdecec; border-color: #f0b4b4; }
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: #161a22; color: #fff; padding: .5rem 1rem; border-radius: 6px; z-index: 9999;
}

/* Filter */
.filters { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1rem; }
.filter-row { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.filter-row label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: .2rem; }
.filter-row label.grow { flex: 1; min-width: 180px; }
.filter-row label.check { flex-direction: row; align-items: center; gap: .35rem; font-size: .9rem; color: var(--text); padding-bottom: .4rem; }
.filter-row select, .filter-row input[type=search], .filter-row input[type=text] { padding: .4rem .5rem; border: 1px solid #cfd4dc; border-radius: 6px; font: inherit; color: var(--text); background: #fff; }
.geo-filter { display: flex; gap: .4rem; align-items: flex-end; padding: .35rem .5rem .4rem; border: 1px dashed var(--line); border-radius: 8px; background: #fafbfc; }
.geo-filter input[type=text] { width: 9.5rem; }
.geo-filter .btn { padding: .42rem .8rem; }
.dist { color: var(--text); font-weight: 600; }
.month-nav { display: flex; gap: .25rem; padding-bottom: .1rem; }
.filter-cats { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; align-items: center; }
.filter-cats .reset { font-size: .85rem; margin-left: .3rem; }

.cat-toggle { cursor: pointer; }
.cat-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.cat-toggle span {
  display: inline-block; padding: .2rem .7rem; border-radius: 999px; font-size: .85rem;
  border: 2px solid var(--c); color: var(--text); background: #fff;
}
.cat-toggle input:checked + span { background: var(--c); color: #fff; text-shadow: 0 0 2px rgba(0,0,0,.45); }
.cat-toggle input:focus-visible + span { outline: 2px solid #333; outline-offset: 2px; }

/* Werkzeugleiste */
.toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .6rem; margin-bottom: .8rem; }
.toolbar .period { margin: 0; font-size: 1.3rem; flex: 1; text-align: center; }
.toolbar .period small { display: block; font-size: .8rem; font-weight: normal; color: var(--muted); }
.tabs { display: flex; border: 1px solid #cfd4dc; border-radius: 6px; overflow: hidden; }
.tab { padding: .4rem .9rem; text-decoration: none; color: var(--text); background: #fff; }
.tab + .tab { border-left: 1px solid #cfd4dc; }
.tab.active { background: var(--accent); color: var(--on-accent); }
.actions { display: flex; gap: .4rem; }
.dropdown { position: relative; }
.dropdown-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 4px); z-index: 1000; min-width: 290px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: .3rem 0;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a { display: block; padding: .5rem .9rem; color: var(--text); text-decoration: none; }
.dropdown-menu a:hover { background: var(--bg); }

/* Liste */
.month-head { margin: 1.4rem 0 .5rem; padding-bottom: .3rem; border-bottom: 2px solid var(--line); text-transform: uppercase; letter-spacing: .05em; font-size: .95rem; color: var(--on-bg-muted); }
.ev { background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--c); border-radius: var(--radius); margin-bottom: .5rem; }
.ev.past { opacity: .6; }
.ev summary { display: flex; gap: 1rem; padding: .7rem 1rem; cursor: pointer; list-style: none; align-items: center; }
.ev-date { align-self: flex-start; }
/* Kartenausschnitt (ca. 100 km breit) */
.ev-thumb {
  flex: 0 0 170px; height: 100px; border-radius: 6px; border: 1px solid var(--line); overflow: hidden;
  background: #e8ece4; position: relative; z-index: 0; pointer-events: none;
}
.ev-thumb .leaflet-container { background: #e8ece4; }
.ev summary::-webkit-details-marker { display: none; }
.ev summary:hover { background: #fafbfc; }
.ev-date { flex: 0 0 64px; text-align: center; line-height: 1.1; }
.ev-date .d { display: block; font-size: 1.7rem; font-weight: 700; }
.ev-date .m { font-size: .75rem; color: var(--muted); text-transform: uppercase; }
.ev-main { flex: 1; min-width: 0; }
.ev-title { font-weight: 650; font-size: 1.05rem; }
.ev-meta { color: var(--muted); font-size: .88rem; display: flex; flex-wrap: wrap; gap: .2rem 1rem; }
.ev-cats { margin-top: .3rem; display: flex; flex-wrap: wrap; gap: .3rem; }
.badge { background: var(--c); color: #fff; font-size: .75rem; padding: .05rem .5rem; border-radius: 999px; text-shadow: 0 0 2px rgba(0,0,0,.45); }
.ev-body { padding: 0 1rem 1rem calc(64px + 2rem); }
.desc { white-space: normal; margin: .5rem 0; }
.links { list-style: none; padding: 0; margin: .5rem 0; display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; }
.ev-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); background: var(--card); border-radius: var(--radius); }
.count { color: var(--muted); font-size: .85rem; text-align: right; }

/* Karte */
.map { height: 560px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 0; }
.map-small { height: 320px; margin: 1rem 0 .4rem; }
.map-picker { height: 360px; margin-top: .5rem; }
.rk-marker span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; padding: 0 6px;
  border-radius: 14px; color: #fff; font-weight: 700; font-size: 12px; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.5); white-space: nowrap; text-shadow: 0 0 2px rgba(0,0,0,.5);
}
.pop hr { border: 0; border-top: 1px solid var(--line); }
.map-legend { width: 100%; border-collapse: collapse; margin-top: 1rem; background: var(--card); font-size: .9rem; }
.map-legend th, .map-legend td { padding: .4rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.map-legend tr[data-id] { cursor: pointer; }
.map-legend tr[data-id]:hover { background: #fafbfc; }
.num { display: inline-block; min-width: 24px; text-align: center; color: #fff; border-radius: 12px; font-weight: 700; font-size: .8rem; padding: 0 4px; }

/* Detailseite */
.detail { background: var(--card); border: 1px solid var(--line); border-top: 6px solid var(--c); border-radius: var(--radius); padding: 1.2rem 1.5rem; }
.detail h1 { margin-top: 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.2rem; margin: 1rem 0; }
.facts dt { font-weight: 600; color: var(--muted); }
.facts dd { margin: 0; word-break: break-word; }

/* Formulare */
.form { display: flex; flex-direction: column; gap: .9rem; }
.form label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .9rem; }
.form input[type=text], .form input[type=email], .form input[type=password], .form input[type=date], .form input[type=time], .form textarea {
  padding: .5rem .6rem; border: 1px solid #cfd4dc; border-radius: 6px; font: inherit; font-weight: normal; width: 100%;
}
.form fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; display: flex; flex-direction: column; gap: .5rem; background: var(--card); }
.form legend { font-weight: 600; padding: 0 .3rem; }
.event-form { background: transparent; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.cat-grid { display: flex; flex-wrap: wrap; gap: .4rem; }
.cat-grid .cat-toggle { font-weight: normal; }
.geo-search { display: flex; gap: .5rem; }
.geo-search input { flex: 1; }
.geo-results { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.geo-results li { padding: .25rem 0; border-bottom: 1px dashed var(--line); }
.form-actions { display: flex; gap: .5rem; }
.hp { position: absolute; left: -9999px; }

/* uMap */
.umap-steps { margin: .2rem 0 .4rem; padding-left: 1.3rem; font-size: .9rem; display: flex; flex-direction: column; gap: .35rem; }
.umap-frame { width: 100%; height: 420px; border: 1px solid var(--line); border-radius: var(--radius); }
.umap-head { margin: 1.2rem 0 .5rem; }

/* Hilfe */
.help { max-width: 860px; margin: 0 auto; }
.help .toc { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1.2rem; }
.help .step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin: 1rem 0; }
.help .step h3 { margin: 0 0 .4rem; display: flex; gap: .6rem; align-items: center; }
.help .step h3 .n { flex: 0 0 2rem; height: 2rem; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; }
.help figure { margin: .8rem 0 0; }
.help figure img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; display: block; }
.help figcaption { font-size: .85rem; color: var(--muted); margin-top: .3rem; }
.help .tip { background: #fff8e6; border: 1px solid #f2d48a; border-radius: 6px; padding: .5rem .8rem; margin: .6rem 0; font-size: .92rem; }
.help .warn { background: #fdecec; border: 1px solid #f0b4b4; border-radius: 6px; padding: .5rem .8rem; margin: .6rem 0; font-size: .92rem; }
.help .way { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.help .way > div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.mail-log { background: #fafbfc; border: 1px solid var(--line); padding: .5rem; font-size: .8rem; white-space: pre-wrap; }
.mail-info { margin: .5rem 0 1rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
@media (max-width: 700px) { .help .way { grid-template-columns: 1fr; } .geo-filter { flex-wrap: wrap; } }

/* Einstellungen */
.settings { max-width: 760px; margin: 1rem auto; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1rem; }
.panel h2 { margin-top: 0; }
.color-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.color-field { font-weight: 600; }
.color-input { display: flex; align-items: center; gap: .5rem; font-weight: normal; }
.color-input input[type=color] { width: 56px; height: 38px; padding: 2px; border: 1px solid #cfd4dc; border-radius: 6px; background: #fff; cursor: pointer; }
.choice-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: .8rem 0 .2rem; }
.choice-label { font-weight: 600; min-width: 100px; }
.seg { display: inline-flex; border: 1px solid #cfd4dc; border-radius: 6px; overflow: hidden; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: .4rem 1rem; background: #fff; min-width: 3rem; text-align: center; font-weight: 600; }
.seg label + label span { border-left: 1px solid #cfd4dc; }
.seg input:checked + span { background: var(--accent); color: var(--on-accent); }
.seg input:focus-visible + span { outline: 2px solid #333; outline-offset: -3px; }
.code-label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; margin-top: 1rem; }
#embed-code { font: .85rem/1.4 ui-monospace, Consolas, monospace; padding: .5rem; border: 1px solid #cfd4dc; border-radius: 6px; width: 100%; resize: vertical; background: #fafbfc; }
#embed .form-actions { margin-top: .6rem; }

/* Admin */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--card); font-size: .9rem; }
.table th, .table td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table input[type=text] { padding: .35rem .5rem; border: 1px solid #cfd4dc; border-radius: 6px; font: inherit; width: 100%; min-width: 220px; }
.table .w-num { width: 70px; padding: .35rem; border: 1px solid #cfd4dc; border-radius: 6px; }
.actions-cell { display: flex; flex-wrap: wrap; gap: .3rem; }
.status-pending { background: #fff8e6; }
.status-pending .status { font-weight: 700; color: #a15c00; }
.status-blocked { color: var(--muted); }

@media (max-width: 700px) {
  .grid3 { grid-template-columns: 1fr; }
  .toolbar .period { order: -1; flex-basis: 100%; }
  .ev-body { padding-left: 1rem; }
  .ev-date { flex-basis: 48px; }
  .ev summary { gap: .6rem; padding: .6rem .7rem; }
  .ev-thumb { flex-basis: 96px; height: 72px; }
  .settings .color-grid { grid-template-columns: 1fr; }
  .map { height: 420px; }
}

/* Druck */
@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 10.5pt; }
  .no-print, .leaflet-control-zoom { display: none !important; }
  .print-only { display: block; }
  .print-foot { color: #666; font-size: 8pt; margin-top: 1rem; }
  .container { max-width: none; padding: 0; }
  .toolbar .period { text-align: left; font-size: 16pt; }
  .ev { break-inside: avoid; border: 1px solid #ccc; border-left: 5px solid var(--c); margin-bottom: 3mm; }
  .ev.past { opacity: 1; }
  .ev summary { padding: 2mm 3mm; }
  .ev-body { padding: 0 3mm 2mm calc(64px + 2rem); }
  .month-head { break-after: avoid; }
  .badge, .num, .rk-marker span, .ev, .detail { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .map { height: 150mm; border: 1px solid #ccc; break-inside: avoid; }
  .map-small { height: 90mm; }
  .map-legend { font-size: 9pt; }
  .map-legend tr { break-inside: avoid; }
  .detail { border: none; padding: 0; }
  a { color: inherit; text-decoration: none; }
}
