:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3f56;
  --text: #e8edf4;
  --muted: #8fa3bc;
  --accent: #11a2f7;
  --accent-dim: #0e67ec;
  --warning: #f5a623;
  --danger: #ef5b5b;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(61, 214, 140, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(61, 140, 214, 0.08), transparent);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.header {
  border-bottom: 1px solid var(--border);
  background: rgba(26, 35, 50, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 600;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0.15rem;
}

.header-stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.stat-pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.stat-pill strong {
  color: var(--accent);
  font-size: 1.1rem;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.tab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s;
}

.tab:hover { color: var(--text); border-color: var(--muted); }
.tab.active {
  background: var(--accent);
  color: #0a1610;
  border-color: var(--accent);
  font-weight: 600;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.info-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.badge {
  background: rgba(61, 214, 140, 0.15);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  white-space: nowrap;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.group-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.group-card.rank-1 {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(61, 132, 214, 0.3), var(--shadow);
}

.group-card .rank {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--border);
  line-height: 1;
}

.group-card.rank-1 .rank { color: var(--accent); }

.group-card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  padding-right: 2rem;
}

.group-total {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}

.group-total span {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
}

.group-meta {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.member-list {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.member-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  font-size: 0.875rem;
}

.member-row .km {
  font-weight: 600;
  color: var(--text);
}

.member-row .km.bonus::after {
  content: " ×1,5";
  font-size: 0.7rem;
  color: var(--warning);
  font-weight: 500;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form-card {
  max-width: 520px;
  padding: 1.5rem;
}

.form-card h2 {
  font-size: 1.15rem;
  margin-bottom: 1.25rem;
}

label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.optional { font-weight: 400; opacity: 0.7; }

input[type="text"],
input[type="number"],
input[type="date"],
select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
}

input[type="file"] {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  color: var(--text);
}

.checkbox-label input {
  margin-top: 0.2rem;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.checkbox-label small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.km-preview {
  background: rgba(61, 214, 140, 0.1);
  border: 1px solid rgba(61, 127, 214, 0.3);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--accent);
}

.screenshot-preview {
  margin-top: 0.5rem;
}

.screenshot-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.9; }
.btn.primary {
  background: var(--accent);
  color: #0a1610;
  width: 100%;
  margin-top: 0.5rem;
}

.btn.danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.form-message {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.875rem;
}

.form-message.success {
  background: rgba(61, 214, 140, 0.12);
  color: var(--accent);
  border: 1px solid rgba(61, 122, 214, 0.3);
}

.form-message.error {
  background: rgba(239, 91, 91, 0.12);
  color: var(--danger);
  border: 1px solid rgba(239, 91, 91, 0.3);
}

.run-list { display: flex; flex-direction: column; gap: 0.75rem; }

.run-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: start;
}

.run-item-main h4 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.run-item-main .meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.run-km {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  text-align: right;
}

.run-km .raw {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}

.run-km .bonus-tag {
  display: inline-block;
  background: rgba(245, 166, 35, 0.15);
  color: var(--warning);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.25rem;
  vertical-align: middle;
}

.run-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.25rem;
}

.run-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.hidden { display: none !important; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.lightbox img {
  max-width: 95vw;
  max-height: 90vh;
  border-radius: var(--radius);
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

@media (max-width: 520px) {
  .row { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; align-items: flex-start; }
}
