:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #20242a;
  --muted: #6f7782;
  --line: #d8dde4;
  --accent: #126b5f;
  --warning: #b86e00;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

body.dashboard-page {
  height: 100vh;
  overflow: hidden;
}

a {
  color: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  text-decoration: none;
}

.brand-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

nav {
  display: flex;
  gap: 16px;
}

nav a {
  color: var(--muted);
  text-decoration: none;
}

.shell {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.dashboard-page .shell {
  width: 100%;
  height: calc(100vh - 57px);
  margin: 0;
  padding: 12px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 70%) minmax(360px, 30%);
  gap: 12px;
  height: 100%;
  min-height: 0;
}

.dashboard-sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}

.panel {
  margin-bottom: 16px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dashboard-sidebar .panel {
  margin-bottom: 0;
}

.map-panel {
  position: relative;
  padding: 0;
  overflow: hidden;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.map-progress {
  position: absolute;
  bottom: 10px;
  left: 10px;
  width: 110px;
  height: 4px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 2px;
  z-index: 1000;
  pointer-events: none;
  overflow: hidden;
}

.map-progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 2px;
  opacity: 1;
}

.map-progress-bar.loading {
  width: 40%;
  animation: map-progress-sweep 1.2s ease-in-out infinite;
}

@keyframes map-progress-sweep {
  0%   { transform: translateX(-100%); opacity: 0.6; }
  50%  { transform: translateX(75%);   opacity: 1;   }
  100% { transform: translateX(250%);  opacity: 0.6; }
}

.map-progress-bar.ticking {
  width: 100%;
  transform: none;
  opacity: 0.85;
  animation: map-progress-tick var(--tick-duration, 30s) linear forwards;
}

@keyframes map-progress-tick {
  from { width: 0%; }
  to   { width: 100%; }
}

#map {
  width: 100%;
  height: 100%;
  min-height: 0;
}

#map .leaflet-tile {
  filter: brightness(0.68) saturate(0.82) contrast(1.08);
}

.aircraft-marker {
  display: grid;
  place-items: center;
  filter: drop-shadow(0 2px 4px rgb(0 0 0 / 35%));
}

.aircraft-marker img {
  display: block;
  object-fit: contain;
  transform-origin: center;
}

h1,
h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

h2 {
  font-size: 16px;
}

.status {
  border-left: 6px solid var(--accent);
}

.status.warning {
  border-left-color: var(--warning);
}

.status.danger {
  border-left-color: var(--danger);
}

.status p,
.empty {
  margin: 0;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
}

.table-scroll {
  overflow-x: auto;
}

.aircraft-panel {
  display: flex;
  flex-direction: column;
  min-height: 250px;
}

.aircraft-panel .table-scroll {
  max-height: 205px;
  overflow: auto;
}

.panel-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.events {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.events-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.events-panel .events {
  overflow-y: auto;
  padding-right: 8px;
}

.events li {
  line-height: 1.45;
}

.event-title {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.event-name {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.event-badge {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}

.event-badge--approach {
  background: #fef3c7;
  color: #92400e;
}

.event-badge--danger {
  background: #fee2e2;
  color: #991b1b;
}

.event-badge--leave {
  background: #dcfce7;
  color: #166534;
}

.event-badge--landing {
  background: #e0f2fe;
  color: #075985;
}

.event-detail {
  color: var(--muted);
}

.events time,
.events small {
  color: var(--muted);
}

.settings-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
  align-items: start;
}

.form-panel {
  max-width: 560px;
}

@media (max-width: 860px) {
  .settings-layout {
    grid-template-columns: 1fr;
  }
}

form {
  display: grid;
  gap: 14px;
}

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

input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
}

select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

button {
  width: fit-content;
  padding: 10px 16px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: #4b5563;
}

.notification-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.inline-form {
  margin-top: 12px;
}

.error {
  color: var(--danger);
}

@media (max-width: 860px) {
  body.dashboard-page {
    height: auto;
    overflow: auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
  }

  .shell {
    padding: 12px;
  }

  .dashboard-page .shell {
    height: auto;
  }

  .dashboard-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .dashboard-sidebar {
    overflow: visible;
  }

  #map {
    height: 58vh;
    min-height: 340px;
  }

  table {
    display: block;
    overflow-x: auto;
  }
}
