/* app/admin.css - Sport Admin (passend zum Dashboard: dunkel, Glas, ein Akzent) */
*, *::before, *::after { box-sizing: border-box; }
:root {
    --bg: #070b14;
    --panel: rgba(15, 23, 42, 0.72);
    --panel-solid: #0f172a;
    --line: rgba(255, 255, 255, 0.07);
    --line-strong: rgba(255, 255, 255, 0.14);
    --text: #f1f5f9;
    --muted: #8ba3cb;
    --accent: #0ea5e9;
    --accent-rgb: 14, 165, 233;
    --ok: #34d399;
    --danger: #ff2a5f;
    --radius: 18px;
    --font-ui: 'Inter', system-ui, sans-serif;
}
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: var(--font-ui); font-size: 15px; line-height: 1.5;
    background-image: radial-gradient(900px 500px at 85% -10%, rgba(var(--accent-rgb), 0.12), transparent 60%),
        linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
    background-size: auto, 40px 40px, 40px 40px;
}
body.locked { overflow: hidden; }
h1, h2, h3 { font-family: var(--font-custom); letter-spacing: 1px; margin: 0; color: #fff; }
h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: 1.5px; }
h3 { font-size: 0.85rem; text-transform: uppercase; margin: 22px 0 6px; color: var(--muted); font-family: var(--font-ui); font-weight: 700; }
a { color: var(--accent); }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 0.82rem; }
.hint { color: var(--muted); font-size: 0.8rem; margin: 6px 0 16px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
[hidden] { display: none !important; }

/* --- Buttons --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 700 0.88rem/1 var(--font-ui); letter-spacing: 0.3px;
    padding: 13px 20px; border-radius: 12px; border: 1px solid transparent; cursor: pointer; text-decoration: none; color: #fff;
    transition: background .2s, border-color .2s, transform .15s, box-shadow .2s; min-height: 44px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--accent); box-shadow: 0 8px 20px rgba(var(--accent-rgb), 0.25); }
.btn-primary:hover { background: #38bdf8; }
.btn-ghost { background: rgba(255,255,255,0.04); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.1); }
.btn-danger { background: rgba(255,42,95,0.12); color: var(--danger); border-color: rgba(255,42,95,0.4); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 9px 14px; min-height: 38px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn.is-busy .btn-icon { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-strong); background: rgba(0,0,0,0.3); color: #fff; font-size: 1rem; cursor: pointer; flex: none; }
.icon-btn:hover { border-color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Formulare --- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 6px; }
.field > span em { text-transform: none; letter-spacing: 0; font-style: normal; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
    width: 100%; padding: 12px 14px; background: rgba(0,0,0,0.35); border: 1px solid var(--line-strong); color: #fff; border-radius: 12px;
    font: 500 16px/1.4 var(--font-ui); transition: border-color .2s, box-shadow .2s; }   /* 16px = kein Auto-Zoom auf iPhone */
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18); }
textarea { resize: vertical; min-height: 120px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* --- Alerts / Toasts --- */
.alert { padding: 14px 18px; border-radius: 14px; margin-bottom: 18px; font-weight: 600; border: 1px solid; }
.alert-ok { background: rgba(52,211,153,0.1); border-color: rgba(52,211,153,0.4); color: var(--ok); }
.alert-error { background: rgba(255,42,95,0.1); border-color: rgba(255,42,95,0.4); color: #ff6b8b; }
.toasts { position: fixed; z-index: 200; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100% - 32px)); pointer-events: none; }
.toast { background: var(--panel-solid); border: 1px solid var(--line-strong); border-left: 4px solid var(--ok); padding: 12px 16px; border-radius: 12px; font-weight: 600; font-size: 0.9rem;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6); animation: toastIn .25s ease-out; }
.toast.err { border-left-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* --- Topbar --- */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 18px; padding: 12px 24px; background: rgba(7,11,20,0.85);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-custom); font-weight: 900; letter-spacing: 1.5px; text-transform: uppercase; white-space: nowrap; }
.brand-mark, .login-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #0284c7, #38bdf8); color: #fff; font-size: 0.8rem; }
.tabs { display: flex; gap: 4px; flex: 1; justify-content: center; }
.tab { color: var(--muted); text-decoration: none; font-weight: 700; font-size: 0.88rem; padding: 10px 14px; border-radius: 10px; transition: color .2s, background .2s; white-space: nowrap; }
.tab:hover { color: #fff; }
.tab.active { color: #fff; background: rgba(var(--accent-rgb), 0.15); box-shadow: inset 0 -2px 0 var(--accent); }
.top-actions { display: flex; gap: 8px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 24px 80px; }

/* --- Übersicht --- */
.overview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; justify-content: center; gap: 4px; min-width: 0; }
.kpi-val { font-family: var(--font-custom); font-size: 1.6rem; font-weight: 900; color: #fff; line-height: 1.1; }
.kpi-val small { font-family: var(--font-ui); font-size: 0.8rem; color: var(--accent); }
.kpi-lbl { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); font-weight: 700; }
.kpi-bar { display: block; height: 5px; border-radius: 5px; background: rgba(255,255,255,0.08); overflow: hidden; margin-top: 6px; }
.kpi-bar i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.kpi-action { gap: 8px; }

/* --- Live-Status --- */
.live { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); margin-bottom: 22px; }
.live-dot { width: 12px; height: 12px; border-radius: 50%; background: #475569; flex: none; }
.live-txt { display: flex; flex-direction: column; flex: 1; min-width: 0; font-size: 0.86rem; }
.live-txt span { color: var(--muted); }
.live-actions { display: flex; gap: 8px; flex: none; }
.live-active { border-color: rgba(255,42,95,0.55); background: linear-gradient(90deg, rgba(255,42,95,0.14), var(--panel) 60%); }
.live-active .live-dot { background: var(--danger); box-shadow: 0 0 12px var(--danger); animation: pulse 1.4s infinite; }
.live-killed .live-dot { background: #f59e0b; }
@keyframes pulse { 50% { transform: scale(1.5); opacity: .7; } }

/* --- Panels --- */
.panel { background: var(--panel); border: 1px solid var(--line); border-top-color: var(--line-strong); border-radius: 22px; padding: 22px; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.panel > h2 { margin-bottom: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-narrow { max-width: 520px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid-tight { gap: 14px; }

/* --- Läufe-Liste --- */
.filters { display: grid; grid-template-columns: minmax(0, 1fr) 150px auto; gap: 10px; margin-bottom: 14px; align-items: center; }
.chips, .font-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: 600 0.8rem/1 var(--font-ui); color: var(--muted); background: rgba(255,255,255,0.04); border: 1px solid var(--line-strong); padding: 9px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.chip:hover { color: #fff; }
.chip.on { color: #fff; background: rgba(var(--accent-rgb), 0.2); border-color: var(--accent); }
.list { display: flex; flex-direction: column; gap: 6px; }
.month-sep { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); padding: 14px 4px 4px; display: flex; justify-content: space-between; }
.row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 8px 14px 8px 8px; border-radius: 14px;
    background: rgba(0,0,0,0.22); border: 1px solid transparent; cursor: pointer; text-align: left; width: 100%; color: inherit; font: inherit; transition: background .15s, border-color .15s; }
.row:hover { background: rgba(var(--accent-rgb), 0.08); border-color: rgba(var(--accent-rgb), 0.35); }
.row.is-open { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.12); }
.row-thumb { width: 56px; height: 56px; border-radius: 10px; background: rgba(255,255,255,0.05) center/cover no-repeat; display: grid; place-items: center; font-size: 1.3rem; color: var(--muted); position: relative; }
.row-thumb b { position: absolute; right: -4px; bottom: -4px; background: var(--accent); color: #fff; font-size: 0.65rem; border-radius: 8px; padding: 2px 5px; }
.row-main { min-width: 0; }
.row-title { font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: 0.8rem; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.row-meta .tag { color: #fbbf24; font-weight: 700; }
.row-note { font-size: 0.8rem; color: #cbd5e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.row-side { text-align: right; white-space: nowrap; }
.row-km { font-family: var(--font-custom); font-weight: 900; font-size: 1.1rem; color: #fff; }
.row-pace { font-size: 0.78rem; color: var(--accent); font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
#more-btn { margin-top: 12px; }

/* --- Editor-Drawer --- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 90; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); z-index: 100; background: #0b1222; border-left: 1px solid var(--line-strong);
    box-shadow: -30px 0 60px rgba(0,0,0,0.6); display: flex; flex-direction: column; transform: translateX(105%); transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 22px 10px; }
.drawer-head h2 { text-transform: none; font-size: 1.3rem; letter-spacing: 0.5px; line-height: 1.25; }
.ed-date { color: var(--muted); font-size: 0.8rem; font-weight: 600; margin-bottom: 4px; }
.ed-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 6px 22px 16px; border-bottom: 1px solid var(--line); }
.ed-stats div { background: rgba(0,0,0,0.3); border-radius: 12px; padding: 10px 6px; text-align: center; }
.ed-stats b { display: block; font-family: var(--font-custom); color: #fff; font-size: 1.05rem; }
.ed-stats span { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); font-weight: 700; }
.drawer-body { overflow-y: auto; padding: 18px 22px 40px; flex: 1; overscroll-behavior: contain; }
.ed-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 10px; }
#ed-save-state.saved { color: var(--ok); }
#ed-save-state.dirty { color: #fbbf24; }
.ed-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.ed-photo { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #000; }
.ed-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ed-photo .cover { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,0.7); color: #fde68a; font-size: 0.62rem; font-weight: 800; padding: 3px 7px; border-radius: 6px; letter-spacing: 0.5px; }
.ed-photo button { position: absolute; right: 6px; top: 6px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0,0,0,0.75); color: #fff; cursor: pointer; font-size: 0.85rem; }
.ed-photo button:hover { background: var(--danger); }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 20px; border: 2px dashed var(--line-strong); border-radius: 14px; text-align: center; cursor: pointer; font-size: 0.88rem; transition: border-color .2s, background .2s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.08); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dz-icon { font-size: 1.6rem; }
.upload-progress { position: relative; height: 30px; border-radius: 10px; background: rgba(0,0,0,0.35); overflow: hidden; margin-top: 10px; }
.upload-progress i { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(var(--accent-rgb), 0.5); transition: width .15s; }
.upload-progress span { position: relative; display: block; text-align: center; line-height: 30px; font-size: 0.78rem; font-weight: 700; }
.danger-zone { margin-top: 26px; border: 1px solid rgba(255,42,95,0.25); border-radius: 14px; padding: 12px 16px; }
.danger-zone summary { cursor: pointer; color: #ff6b8b; font-weight: 700; font-size: 0.85rem; }
.danger-zone p { color: var(--muted); }

/* --- Einstellungen / Impressum --- */
.font-chips { margin: -4px 0 14px; }
.font-preview { border: 1px solid var(--line); border-radius: 14px; padding: 18px; text-align: center; margin-bottom: 16px; background: rgba(0,0,0,0.25); }
.font-preview span { display: block; font-family: var(--font-preview, var(--font-custom)); font-size: 1.7rem; font-weight: 900; letter-spacing: 3px; color: #fff; }
.font-preview em { font-style: normal; color: var(--accent); }
.font-preview small { display: block; font-family: var(--font-preview, var(--font-custom)); color: var(--muted); letter-spacing: 2px; margin-top: 6px; font-weight: 700; }
.facts { margin: 0; display: flex; flex-direction: column; }
.facts div { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.facts div:last-child { border: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; text-align: right; }
.imp-preview { background: #fff; color: #1e293b; border-radius: 12px; padding: 18px 20px; min-height: 380px; max-height: 520px; overflow: auto; font-size: 0.9rem; }
.imp-preview h1, .imp-preview h2, .imp-preview h3 { color: #0f172a; font-family: var(--font-ui); text-transform: none; letter-spacing: 0; margin: 0.8em 0 0.4em; }
#imp-src { min-height: 380px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }

/* --- Login --- */
.login-page { display: grid; place-items: center; padding: 16px; }
.login-box { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-top-color: var(--line-strong); border-radius: 24px; padding: 32px 26px; text-align: center; backdrop-filter: blur(16px); box-shadow: 0 30px 60px rgba(0,0,0,0.5); }
.login-box h1 { font-size: 1.5rem; margin: 14px 0 4px; text-transform: uppercase; }
.login-box .muted { margin: 0 0 22px; font-size: 0.85rem; }
.login-box form { text-align: left; }
.login-box .btn { margin-top: 6px; }
.login-mark { width: 52px; height: 52px; border-radius: 16px; font-family: var(--font-custom); font-weight: 900; font-size: 1.1rem; }
.back-link { display: block; margin-top: 18px; color: var(--muted); font-size: 0.85rem; text-decoration: none; }

/* --- Responsive --- */
@media (max-width: 900px) {
    .overview { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .filters { grid-template-columns: minmax(0, 1fr) 130px; }
    .filters .chips { grid-column: 1 / -1; }
}
@media (max-width: 680px) {
    body { font-size: 14px; }
    .topbar { flex-wrap: wrap; padding: 10px 14px; gap: 8px 10px; }
    .brand-txt { display: none; }
    .tabs { order: 3; width: 100%; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; }
    .tabs::-webkit-scrollbar { display: none; }
    .top-actions { margin-left: auto; }
    .wrap { padding: 16px 14px 80px; }
    .kpi { padding: 14px; }
    .kpi-val { font-size: 1.3rem; }
    .kpi-action { grid-column: 1 / -1; }
    .live { flex-wrap: wrap; }
    .live-actions { width: 100%; }
    .live-actions .btn { flex: 1; }
    .panel { padding: 16px; border-radius: 18px; }
    .row { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 10px; padding: 6px 10px 6px 6px; }
    .row-thumb { width: 48px; height: 48px; }
    .row-note { display: none; }
    .ed-stats { grid-template-columns: repeat(2, 1fr); }
    .drawer { width: 100%; border-left: 0; }
    .row-2 { grid-template-columns: 1fr; gap: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (min-width: 681px) { .toasts { left: 24px; transform: none; } }
/* Fixes: Ellipsis in Zeilen, Tabs mobil in eigener Zeile */
.row-main, .row-title, .row-note { display: block; }
@media (max-width: 680px) {
    .tabs { flex: 1 1 100%; }
    .overview .kpi:nth-child(3) { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: baseline; }
    .row-km { font-size: 1rem; }
}
/* Titel bearbeiten */
.drawer-head > div:first-child { flex: 1; min-width: 0; }
.title-edit { display: flex; gap: 8px; align-items: center; }
.title-edit input { font-family: var(--font-custom); font-weight: 900; font-size: 1.15rem; letter-spacing: 0.5px; padding: 8px 10px; background: transparent; border-color: transparent; }
.title-edit input:hover { border-color: var(--line-strong); }
.title-edit input:focus { background: rgba(0,0,0,0.35); }
.title-origin { font-size: 0.75rem; color: var(--muted); margin: 4px 0 0 10px; }
.link-btn { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; padding: 0 2px; text-decoration: underline; }
.custom-mark { color: var(--accent); font-size: 0.8em; }
