:root {
  color-scheme: dark;
  --bg: #0a0c14;
  --card: #121624;
  --text: #ecf0ff;
  --muted: #a2accf;
  --primary: #21357f;
  --secondary: #0c73d8;
  --border: #26304b;
}

* {
  box-sizing: border-box;
  scrollbar-width: none;
}

*::-webkit-scrollbar {
  display: none;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top, #1a2448 0%, rgba(26, 36, 72, 0.35) 35%, transparent 65%),
    linear-gradient(180deg, #0f1530 0%, var(--bg) 45%, #070a10 100%);
  z-index: -1;
}

.app {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  max-width: 1300px;
  margin: 0 auto;
}

.topbar {
  grid-column: span 12;
  padding: 0.6rem 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.8rem;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  object-fit: cover;
  background: #0f1321;
}

.user-copy {
  line-height: 1.2;
}

.user-label {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
}

.logout-link {
  color: #fff;
  background: #2a3350;
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 44px;
  min-width: 170px;
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  text-decoration: none;
}

.logout-link:hover {
  filter: brightness(1.08);
}

.landing {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.landing-card {
  width: min(100%, 460px);
  background: color-mix(in oklab, var(--card), black 8%);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem 1.4rem;
  text-align: center;
}

.landing-logo {
  width: 68px;
  height: 68px;
  margin: 0 auto 0.75rem;
  color: #7b8cff;
}

.landing-logo svg {
  width: 100%;
  height: 100%;
}

.discord-login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
  margin-top: 1rem;
  border-radius: 14px;
  text-decoration: none;
  background: #5865f2;
  color: #fff;
  font-weight: 700;
  padding: 0.86rem 1rem;
}

.discord-login-btn:hover {
  filter: brightness(1.06);
}

.discord-icon-wrap {
  width: 22px;
  height: 22px;
  display: inline-flex;
}

.discord-icon-wrap svg {
  width: 100%;
  height: 100%;
}

.card {
  background: color-mix(in oklab, var(--card), black 10%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
}

.controls {
  grid-column: span 4;
}

.map {
  grid-column: span 8;
  min-height: 360px;
  display: flex;
  flex-direction: column;
}

.details {
  grid-column: span 8;
}

.roster {
  grid-column: span 4;
}

#map {
  width: 100%;
  min-height: 360px;
  flex: 1;
  border-radius: 12px;
  margin-top: 0.8rem;
}

.admin-toggle {
  background: #2a3350;
  border: 1px solid var(--border);
  color: #fff;
  border-radius: 12px;
  min-height: 44px;
  min-width: 170px;
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex: 0 0 auto;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: nowrap;
  justify-content: flex-start;
  min-width: 0;
}

.user-copy {
  min-width: 0;
}

.user-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin {
  grid-column: 1 / -1;
}

.admin-header,
.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.admin-section {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  background: #0f1321;
}

.admin-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.9rem;
  max-height: 250px;
  overflow: auto;
}

.admin-list-item {
  background: #151b2e;
  border: 1px solid var(--border);
  color: var(--text);
  text-align: left;
}

.admin-list-item.active {
  border-color: #3a86ff;
  box-shadow: inset 0 0 0 1px #3a86ff;
}

.admin-form {
  margin-top: 0.9rem;
}

.admin-form textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f1321;
  color: var(--text);
  padding: 0.65rem 0.7rem;
  resize: vertical;
}

.admin-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

button.danger {
  background: #8a2d3b;
}

.admin-airline-color {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: #2a3350;
  overflow: hidden;
}

.admin-airline-color img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
}

.flight-search-wrap {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.35rem;
}

.flight-search-wrap input {
  width: 100%;
}

.admin-flight-search-wrap {
  margin-top: 0.6rem;
}

.admin-flight-search-wrap input {
  width: 100%;
  font-size: 0.88rem;
  padding: 0.5rem 0.65rem;
}

/* Tag / Note editor */
.tag-editor {
  margin-top: 0.2rem;
}

.tag-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}

.tag-toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #3a86ff;
  cursor: pointer;
}

.tag-fields {
  display: none;
}

.tag-fields.visible {
  display: block;
}

.color-pick-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.color-pick-row input[type="color"] {
  width: 40px;
  height: 38px;
  padding: 2px 3px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}

.color-pick-row input[type="text"],
.color-pick-row input:not([type="color"]) {
  flex: 1;
}

h1,
h2,
p {
  margin: 0;
}

.subtitle {
  margin-top: 0.3rem;
  color: var(--muted);
}

.field-group {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.35rem;
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

label {
  color: var(--muted);
  font-size: 0.9rem;
}

select,
input {
  width: 100%;
  min-width: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f1321;
  color: var(--text);
  padding: 0.65rem 0.7rem;
}

input[type='date'],
input[type='time'] {
  max-width: 100%;
  min-width: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.airline-logo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.5rem;
}

.airline-empty {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.2rem 0;
}

.airline-chip {
  border: 1px solid var(--border);
  background: #0f1321;
  border-radius: 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
}

.airline-chip img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  flex-shrink: 0;
}

.airline-chip.active {
  border-color: #3a86ff;
  box-shadow: inset 0 0 0 1px #3a86ff;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-top: 1rem;
}

.random-actions {
  grid-template-columns: 1fr;
}

button {
  border: none;
  border-radius: 12px;
  color: white;
  padding: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

button.primary {
  background: var(--primary);
}

button.secondary {
  background: var(--secondary);
}

button.muted {
  background: #2a3350;
}

button:hover {
  filter: brightness(1.08);
}

.status {
  min-height: 1.2rem;
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.flight-header {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
}

.flight-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  flex-shrink: 0;
}

.flight-header-copy {
  min-width: 0;
}

.flight-meta-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.flight-tag {
  --tag-color: #2f93ff;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--tag-color);
  background: color-mix(in srgb, var(--tag-color) 18%, transparent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.flight-banner {
  margin-left: auto;
  width: min(100%, 350px);
  height: 92px;
  object-fit: cover;
  object-position: center;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: #0f1321;
}

.is-hidden {
  display: none;
}

.flight-note {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #0f1321;
  color: var(--muted);
}

.flight-note p {
  line-height: 1.5;
}

.flight-note-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #21357f;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}

.aircraft {
  width: 100%;
  max-height: 250px;
  object-fit: contain;
  margin-top: 0.8rem;
  border-radius: 10px;
  background: #090b12;
}

.stats {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.stats div {
  background: #0f1321;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem;
}

@media (max-width: 900px) {
  .user-badge {
    margin-left: 0;
    gap: 0.45rem;
  }

  .topbar {
    text-align: left;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.55rem;
  }

  .admin-header,
  .admin-section-header,
  .admin-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

#rosterList {
  padding-left: 0;
  list-style: none;
  margin: 0.7rem 0 0;
  display: grid;
  gap: 0.5rem;
}

#rosterList li {
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: #0f1321;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font-size: 0.88rem;
}

.roster-delete-btn {
  background: none;
  border: none;
  color: #8a2d3b;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.2rem;
  line-height: 1;
  flex-shrink: 0;
  border-radius: 6px;
}

.roster-delete-btn:hover {
  background: #8a2d3b22;
  filter: none;
}

.app.overview-mode .map {
  grid-row: span 2;
  min-height: 740px;
}

.app.overview-mode .details {
  display: none;
}

@media (max-width: 900px) {
  .controls,
  .map,
  .details,
  .roster {
    grid-column: 1 / -1;
  }

  .actions,
  .inline-fields {
    grid-template-columns: 1fr;
  }

  .airline-logo-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .flight-banner {
    width: 100%;
    margin-left: 0;
  }

  .app.overview-mode .map {
    grid-row: auto;
    min-height: 540px;
  }

  .app.overview-mode .details {
    display: none;
  }

  .logout-link,
  .admin-toggle {
    min-width: 140px;
    width: auto;
  }

  .user-badge {
    min-width: 0;
  }

  .user-copy {
    min-width: 0;
  }

  .user-label,
  .user-copy strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 520px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.5rem;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 0.45rem;
  }

  .logout-link,
  .admin-toggle {
    min-width: 0;
    flex: 1 1 0;
  }
}
