:root {
  --bg1: #0b1020;
  --bg2: #1a243d;
  --accent: #ff5f1f;
  --accent2: #ff1f57;
  --text: #eef2ff;
  --muted: #b8c2e0;
  --card: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.18);
  --error: #ff7b7b;
  --ok: #5eea9f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: radial-gradient(circle at 10% 10%, #23325e 0, transparent 40%),
              radial-gradient(circle at 85% 85%, #4a1837 0, transparent 40%),
              linear-gradient(130deg, var(--bg1), var(--bg2));
  min-height: 100vh;
}

.container { width: min(1100px, 92vw); margin: 0 auto; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar-toggle {
  display: inline-block;
  position: fixed;
  top: 12px;
  left: 276px;
  z-index: 80;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 95, 31, 0.9), rgba(255, 31, 87, 0.9));
  color: #fff;
  padding: 8px 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}

.sidebar-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.32);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.46);
  z-index: 60;
}

.sidebar {
  width: 260px;
  min-width: 260px;
  padding: 24px 16px;
  border-right: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 70;
}
.brand { color: #fff; text-decoration: none; font-weight: 800; letter-spacing: .3px; }
.brand-wrap { text-decoration: none; display: flex; flex-direction: column; gap: 2px; }
.subbrand { color: var(--muted); font-size: .74rem; letter-spacing: .2px; }
.side-nav { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.side-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
}
.side-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.06); border-color: var(--border); }

.main-content-wrap { flex: 1; min-width: 0; }
.main-content { padding: 64px 0 38px; }

body.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
}

body.sidebar-collapsed .main-content-wrap {
  width: 100%;
}

body.sidebar-collapsed .sidebar-toggle {
  left: 12px;
}

@media (max-width: 960px) {
  .sidebar-toggle {
    left: 12px;
  }

  body.sidebar-open .sidebar-toggle {
    left: 220px;
  }

  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-overlay {
    display: block;
  }
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
}
.hero h1 { margin: 0 0 10px; font-size: clamp(1.8rem, 4vw, 2.7rem); }
.hero p { color: var(--muted); margin: 0 0 12px; }

.btn {
  display: inline-block;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  padding: 10px 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-secondary { background: #334155; }
.btn-sm { padding: 6px 10px; font-size: .85rem; }
.danger-btn { background: #7f1d1d; }

.form-grid { display: grid; gap: 10px; }
.two-col { grid-template-columns: 1fr 1fr; }
.two-col .full { grid-column: 1 / -1; }
label { display: grid; gap: 6px; font-size: .95rem; }
input, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 9px 10px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #8ab4ff;
  box-shadow: 0 0 0 2px rgba(138, 180, 255, 0.18);
}

textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 9px 10px;
  resize: vertical;
  min-height: 88px;
}

.row-space { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.actions-row { display: inline-flex; gap: 8px; align-items: center; }
.table-wrap { overflow-x: auto; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.event-card { border: 1px solid rgba(255,255,255,.14); border-radius: 12px; padding: 14px; background: rgba(255,255,255,.02); }
.event-card h4 { margin: 0 0 8px; }
.event-card p { margin: 0 0 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }

.event-row-link {
  color: #e8f0ff;
  text-decoration: none;
  font-weight: 700;
}

.event-row-link:hover {
  color: #93c5fd;
  text-decoration: underline;
}

.events-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
}

.events-table thead th {
  background: rgba(15, 23, 42, 0.8);
  color: #dbeafe;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.events-table tbody tr {
  transition: background .12s ease;
}

.events-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.08);
}

.events-table td,
.events-table th {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.events-table tbody tr:last-child td {
  border-bottom: 0;
}

.inline { display: inline-flex; align-items: center; gap: 6px; }
.driver-class-form { flex-wrap: nowrap; }
.driver-class-select {
  width: auto;
  min-width: 68px;
  padding: 6px 26px 6px 10px;
  line-height: 1.2;
}

.class-manager-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.class-search {
  display: grid;
  gap: 10px;
}

.class-search-input {
  max-width: 520px;
}

.class-search-results {
  min-height: 24px;
}

.class-manager-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.class-manager-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.class-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.class-actions form {
  margin: 0;
}

.class-btn-active {
  border: 1px solid transparent;
}

.class-btn-active.class-A {
  background: linear-gradient(135deg, #10b981, #059669);
}

.class-btn-active.class-B {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.class-btn-active.class-C {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}
.link-btn {
  border: 0;
  background: none;
  color: #9ac4ff;
  cursor: pointer;
  font: inherit;
  padding: 0;
  margin-left: 8px;
}
.danger { color: var(--error); }
.stack-sm { display: inline-flex; gap: 8px; align-items: center; }

.flash-wrap { margin-bottom: 12px; }
.flash {
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.flash-success { color: var(--ok); }
.flash-error { color: var(--error); }

.narrow { max-width: 640px; }

.field-error {
  color: var(--error);
  margin-top: -4px;
  display: block;
}

.track-layout-preview {
  margin-top: 14px;
}

.track-layout-preview img {
  display: block;
  width: min(420px, 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.check-row input[type="checkbox"] {
  width: auto;
}

.inspection-status {
  margin-top: 10px;
  color: var(--muted);
}

.feed-post {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.feed-post h4 {
  margin: 0 0 6px;
}

.muted-line {
  color: var(--muted);
  margin: 0 0 8px;
}

.author-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.feed-headline {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 8px;
  font-weight: 600;
}

.feed-time {
  color: #c9d6ec;
  font-size: 0.9rem;
  font-weight: 600;
}

.author-avatar,
.author-avatar-fallback {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  flex: 0 0 36px;
}

.author-avatar {
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.author-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #1d4ed8, #0f766e);
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: 8px;
}

.comment-input {
  min-width: 0;
  width: 100%;
  flex: 1;
}

.comment-submit {
  padding: 5px 9px;
  font-size: .8rem;
  line-height: 1;
  height: 34px;
}

.field-meta {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  color: var(--muted);
  font-size: .78rem;
  margin-top: -4px;
}

.hint {
  color: var(--muted);
  font-size: .88rem;
  margin-top: -2px;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-head h2,
.profile-head p {
  margin: 0;
}

.collapsible-card details > summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 700;
}

.collapsible-card details > summary::-webkit-details-marker {
  display: none;
}

.collapsible-body {
  margin-top: 12px;
}

.profile-photo-form {
  margin: 0;
}

.profile-photo-input {
  display: none;
}

.profile-photo-btn {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  border-radius: 999px;
}

.profile-photo {
  width: 58px;
  height: 58px;
  border-radius: 999px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.38);
}

.profile-photo-fallback {
  width: 58px;
  height: 58px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 2px solid rgba(255, 255, 255, 0.38);
  background: linear-gradient(135deg, #1d4ed8, #0f766e);
  color: #fff;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
}

.badge-signed { background: rgba(34,197,94,.2); color: #86efac; border: 1px solid rgba(34,197,94,.4); }
.badge-sent, .badge-viewed { background: rgba(59,130,246,.18); color: #93c5fd; border: 1px solid rgba(59,130,246,.4); }
.badge-not_sent { background: rgba(148,163,184,.18); color: #cbd5e1; border: 1px solid rgba(148,163,184,.35); }
.badge-declined, .badge-expired, .badge-failed { background: rgba(239,68,68,.18); color: #fca5a5; border: 1px solid rgba(239,68,68,.4); }

.driver-class-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.driver-class-pill strong {
  font-size: 1.05rem;
}

.driver-class-A {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.5);
}

.driver-class-B {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.5);
}

.driver-class-C {
  background: rgba(245, 158, 11, 0.22);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.5);
}

.comment-list {
  margin-top: 8px;
  margin-bottom: 8px;
}

.comment-item {
  padding: 6px 8px;
  border-left: 2px solid var(--border);
  margin-bottom: 6px;
}

.car-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.car-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.car-tile-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: border-color .14s ease, transform .14s ease;
}

.car-tile-link:hover {
  border-color: rgba(96, 165, 250, 0.55);
  transform: translateY(-1px);
}

.car-thumb {
  width: 68px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}

.car-thumb-large {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.compact-note h3,
.compact-note p {
  margin: 0;
}

.register-shell {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 18px;
  align-items: start;
}

.register-intro h2 {
  margin-top: 0;
  margin-bottom: 8px;
}

.register-intro p {
  color: var(--muted);
  margin: 0;
  line-height: 1.55;
}

.register-form {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.event-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.event-tile {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  position: relative;
}

.event-tile img {
  width: 100%;
  height: 130px;
  object-fit: contain;
  background: rgba(2, 6, 23, 0.7);
  display: block;
}

.event-fallback {
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b, #334155);
  color: #dbeafe;
  font-weight: 700;
}

.event-class-overlay {
  position: absolute;
  left: 10px;
  top: 98px;
  z-index: 2;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(2, 6, 23, 0.82);
  color: #dbeafe;
  font-size: 0.76rem;
  font-weight: 700;
}

.event-tile-body {
  padding: 10px;
}

.event-signup-form {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.event-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
  align-items: start;
}

.event-nav {
  display: grid;
  gap: 8px;
}

.event-nav h2 {
  margin: 0;
  font-size: 1.2rem;
}

@media (max-width: 960px) {
  .event-shell {
    grid-template-columns: 1fr;
  }
}

.event-tile-body h4 {
  margin: 0 0 6px;
}

.pop-comment {
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.comment-head {
  font-size: .85rem;
  color: #ffd1c0;
  margin-bottom: 3px;
  font-weight: 700;
}

@media (max-width: 800px) {
  .two-col { grid-template-columns: 1fr; }
  .nav-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .register-shell { grid-template-columns: 1fr; }
}
