:root {
  color-scheme: dark;
  --bg: #09090b;
  --panel: #131316;
  --panel-soft: #19191d;
  --line: rgba(255, 255, 255, 0.11);
  --text: rgba(255, 255, 255, 0.9);
  --muted: rgba(255, 255, 255, 0.55);
  --faint: rgba(255, 255, 255, 0.34);
  --red: #e5484d;
  --amber: #f4b74a;
  --green: #38c172;
  --blue: #56a8ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(9, 9, 11, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  color: white;
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link,
.ghost-btn,
.icon-btn,
.steam-btn,
.danger-btn,
.primary-btn,
.success-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.icon-btn {
  width: 36px;
  padding: 0;
}

.nav-link:hover,
.ghost-btn:hover,
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.steam-btn {
  border-color: rgba(86, 168, 255, 0.32);
  background: rgba(86, 168, 255, 0.13);
  color: #bcdcff;
}

.primary-btn {
  border-color: rgba(244, 183, 74, 0.34);
  background: rgba(244, 183, 74, 0.18);
  color: #ffd891;
  font-weight: 700;
}

.success-btn {
  border-color: rgba(56, 193, 114, 0.34);
  background: rgba(56, 193, 114, 0.16);
  color: #98e6ba;
}

.danger-btn {
  border-color: rgba(229, 72, 77, 0.34);
  background: rgba(229, 72, 77, 0.14);
  color: #ffaaa8;
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 26px 0 54px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 18px;
  margin-bottom: 18px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.08;
}

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

.panel,
.event-card,
.squad-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel {
  padding: 18px;
}

.event-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.event-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  text-decoration: none;
  color: var(--text);
}

.event-card:hover {
  border-color: rgba(244, 183, 74, 0.34);
  background: var(--panel-soft);
}

.event-card h2 {
  margin: 0;
  font-size: 18px;
}

.meta-row,
.commander-line {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.badge.pending {
  border-color: rgba(244, 183, 74, 0.34);
  color: #ffd891;
  background: rgba(244, 183, 74, 0.12);
}

.badge.approved {
  border-color: rgba(56, 193, 114, 0.34);
  color: #98e6ba;
  background: rgba(56, 193, 114, 0.12);
}

.badge.rejected,
.badge.cancelled {
  border-color: rgba(229, 72, 77, 0.34);
  color: #ffaaa8;
  background: rgba(229, 72, 77, 0.12);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text);
  font-weight: 700;
  vertical-align: middle;
}

.user-chip.compact {
  gap: 6px;
  font-size: 13px;
}

.user-chip.no-avatar {
  gap: 0;
}

.user-chip span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  object-fit: cover;
  background: rgba(255, 255, 255, 0.07);
}

.user-chip.compact .avatar {
  width: 22px;
  height: 22px;
  flex-basis: 22px;
}

.avatar.fallback {
  display: inline-grid;
  place-items: center;
  color: #ffd891;
  background: rgba(244, 183, 74, 0.16);
  font-size: 10px;
  font-weight: 800;
}

.role-chip,
.faction-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 1px 6px 1px 3px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}

.role-chip img,
.faction-chip img {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  object-fit: contain;
}

.faction-chip {
  min-height: 24px;
  padding: 2px 7px 2px 3px;
  color: var(--text);
}

.faction-chip img {
  width: 20px;
  height: 20px;
  flex-basis: 20px;
  border-radius: 50%;
}

.role-icon-only {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
}

.role-icon-only img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.role-icon-only span {
  display: none;
}

.profile-role-icon {
  width: 28px;
  height: 28px;
  flex-basis: 28px;
}

.profile-role-icon img {
  width: 20px;
  height: 20px;
}

.role-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.detail-head {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.detail-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.detail-title h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 38px);
}

.description {
  margin: 0;
  white-space: pre-wrap;
  color: var(--muted);
  line-height: 1.55;
}

.private-info {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(56, 193, 114, 0.28);
  border-radius: 8px;
  background: rgba(56, 193, 114, 0.08);
}

.private-info h2,
.profile-section h2 {
  margin: 0;
  font-size: 15px;
}

.private-info p {
  margin: 0;
  white-space: pre-wrap;
  color: var(--text);
  line-height: 1.5;
}

.stream-link {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 7px;
  border: 1px solid rgba(229, 72, 77, 0.32);
  background: rgba(229, 72, 77, 0.13);
  color: #ffaaa8;
  font-weight: 800;
  text-decoration: none;
}

.stream-link:hover {
  background: rgba(229, 72, 77, 0.2);
}

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

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

.side-panel {
  display: grid;
  gap: 12px;
}

.side-panel.side-red {
  background: linear-gradient(180deg, rgba(76, 15, 20, 0.72), rgba(19, 19, 22, 0.96) 180px);
  border-color: rgba(229, 72, 77, 0.28);
}

.side-panel.side-blue {
  background: linear-gradient(180deg, rgba(16, 35, 78, 0.72), rgba(19, 19, 22, 0.96) 180px);
  border-color: rgba(86, 168, 255, 0.28);
}

.side-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.side-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.side-title h2 {
  margin: 0;
  font-size: 20px;
}

.squad-list {
  display: grid;
  gap: 10px;
}

.squad-card {
  padding: 12px;
  display: grid;
  gap: 8px;
}

.squad-card.pending {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.025);
}

.squad-card.pending .squad-name,
.squad-card.pending .squad-count {
  color: rgba(255, 255, 255, 0.48);
}

.squad-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.squad-title-line {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.squad-name {
  margin: 0;
  font-size: 16px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.squad-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.squad-actions,
.member-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.small-btn {
  min-height: 30px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.small-btn.good {
  border-color: rgba(56, 193, 114, 0.32);
  color: #98e6ba;
}

.small-btn.bad {
  border-color: rgba(229, 72, 77, 0.32);
  color: #ffaaa8;
}

.members {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 7px;
}

.member {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 32px;
  padding: 6px 9px;
  background: rgba(255, 255, 255, 0.035);
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
}

.member:last-child {
  border-bottom: 0;
}

.member.approved {
  color: var(--text);
}

.member.pending {
  color: rgba(255, 255, 255, 0.46);
}

.member.leader {
  background: rgba(255, 255, 255, 0.055);
}

.player-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.player-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.profile-link {
  color: inherit;
  text-decoration: none;
}

.profile-link:hover {
  color: #ffd891;
}

.empty-inline {
  color: var(--faint);
  font-size: 13px;
}

.profile-panel,
.profile-form {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.profile-head,
.profile-main {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  min-width: 0;
}

.profile-main h1 {
  margin: 8px 0;
  font-size: clamp(26px, 4vw, 38px);
}

.profile-avatar {
  width: 74px;
  height: 74px;
  flex: 0 0 74px;
  border-radius: 8px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
}

.profile-avatar.fallback {
  display: inline-grid;
  place-items: center;
  color: #ffd891;
  font-size: 22px;
  font-weight: 900;
}

.profile-section {
  display: grid;
  gap: 10px;
}

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

.profile-event-group h3 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

.profile-event {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-decoration: none;
}

.profile-event.pending {
  color: rgba(255, 255, 255, 0.48);
}

.profile-event:hover {
  border-color: rgba(244, 183, 74, 0.34);
  background: rgba(255, 255, 255, 0.065);
}

.profile-event strong,
.profile-event span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-event span,
.profile-event-meta {
  color: inherit;
  opacity: 0.78;
  font-size: 13px;
}

.profile-event-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.profile-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.profile-facts div {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
}

.profile-facts span {
  color: var(--muted);
  font-size: 12px;
}

.profile-facts strong,
.profile-facts a {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.check-row input {
  width: auto;
  flex: 0 0 auto;
}

.applications-panel {
  position: sticky;
  top: 86px;
  display: grid;
  gap: 12px;
}

.applications-list {
  display: grid;
  gap: 8px;
}

.application-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.application-row.side-red {
  background: rgba(76, 15, 20, 0.72);
  border-color: rgba(229, 72, 77, 0.3);
}

.application-row.side-blue {
  background: rgba(16, 35, 78, 0.72);
  border-color: rgba(86, 168, 255, 0.3);
}

.application-main,
.application-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.application-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 800;
}

.squad-pill {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.action-icon {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
}

.action-icon.approve {
  color: #98e6ba;
  border-color: rgba(56, 193, 114, 0.34);
}

.action-icon.remove {
  color: #ffaaa8;
  border-color: rgba(229, 72, 77, 0.34);
}

.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--faint);
  text-align: center;
}

.event-form {
  margin-bottom: 16px;
  display: grid;
  gap: 12px;
}

.form-section,
.event-map-list,
.event-maps {
  display: grid;
  gap: 10px;
}

.event-map-form,
.event-map-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.event-map-form h3,
.event-maps h2 {
  margin: 0;
}

.map-search {
  position: relative;
}

.map-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 900;
}

.map-sides {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.map-side {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border-radius: 7px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.map-side.side-red {
  background: rgba(76, 15, 20, 0.56);
  border-color: rgba(229, 72, 77, 0.25);
}

.map-side.side-blue {
  background: rgba(16, 35, 78, 0.56);
  border-color: rgba(86, 168, 255, 0.25);
}

.form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.form-head h2 {
  margin: 0;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #15161a;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

select option {
  background: #15161a;
  color: var(--text);
}

.user-search {
  position: relative;
  display: grid;
  gap: 6px;
}

.user-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #15161a;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.36);
}

.user-search-results:empty {
  display: none;
}

.user-search-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.user-search-option:last-child {
  border-bottom: 0;
}

.user-search-option:hover,
.user-search-option:focus-visible {
  background: rgba(86, 168, 255, 0.12);
  outline: none;
}

.user-search-steam,
.user-search-hint {
  color: var(--muted);
  font-size: 12px;
}

.user-search-hint {
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid rgba(229, 72, 77, 0.35);
  background: #231214;
  color: #ffccca;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.35);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.72);
}

.modal-panel {
  width: min(520px, 100%);
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.42);
}

.modal-body {
  display: grid;
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 820px) {
  .topbar,
  .detail-title,
  .hero {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .side-grid,
  .event-layout,
  .map-sides,
  .grid.two,
  .profile-facts {
    grid-template-columns: 1fr;
  }

  .applications-panel {
    position: static;
  }
}
