:root {
  color-scheme: light;
  --bg: #f4efe6;
  --panel: #fffaf2;
  --panel-strong: #ffffff;
  --text: #1f2430;
  --muted: #5d6472;
  --accent: #9b4d2f;
  --accent-2: #325f6b;
  --line: #d6c9b8;
  --shadow: 0 18px 50px rgba(61, 45, 28, 0.12);
}

* {
  box-sizing: border-box;
}
html,
body {
  min-height: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Trebuchet MS", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(
      circle at top left,
      rgba(155, 77, 47, 0.12),
      transparent 32%
    ),
    radial-gradient(
      circle at top right,
      rgba(50, 95, 107, 0.12),
      transparent 28%
    ),
    linear-gradient(180deg, #f8f4ec 0%, var(--bg) 100%);
}

.shell {
  max-width: 1400px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.hero,
.panel,
.status-card,
.map-card,
.info-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 24px;
}

.app-logo {
  align-self: flex-start;
  width: min(110px, 16vw);
  height: auto;
  object-fit: contain;
}

.auth-logo {
  display: block;
  width: 96px;
  height: auto;
  margin: 0 0 20px auto;
  object-fit: contain;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-2);
  font-size: 0.8rem;
  margin: 0 0 8px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: clamp(2rem, 4vw, 3.6rem);
  margin-bottom: 12px;
}
.lede {
  max-width: 780px;
  color: var(--muted);
  line-height: 1.5;
}

.status-card {
  min-width: 280px;
  padding: 18px;
}
.status-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}
.label {
  color: var(--muted);
  font-size: 0.9rem;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin: 18px 0;
}

.tab,
button,
select {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
}

.tab,
button {
  background: var(--panel-strong);
  cursor: pointer;
}

.tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.panel {
  padding: 20px;
}

.panel:not(.hidden) {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 18px;
}

.inline-controls {
  display: grid;
  gap: 8px;
  min-width: 280px;
}

.coordinate-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
  padding-top: 6px;
}

.coordinate-editor.hidden {
  display: none;
}

.position-mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.position-mode-toggle button.active {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.coordinate-editor label {
  font-size: 0.78rem;
  color: var(--muted);
}

.coordinate-editor input {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}

.coordinate-editor button {
  grid-column: 1 / -1;
  padding: 9px 10px;
}

.content-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
  flex: 1;
  min-height: 0;
}

.map-card,
.info-card {
  padding: 16px;
}

.map-card {
  display: flex;
  min-height: 0;
}

.map {
  flex: 1;
  width: 100%;
  min-height: 640px;
  height: 100%;
}

.stack {
  display: grid;
  gap: 12px;
}

.info-item {
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.muted {
  color: var(--muted);
}
.hidden {
  display: none;
}
.demo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.hint {
  color: var(--muted);
  line-height: 1.5;
  margin-top: 16px;
}

.pilot-sync-status {
  display: inline-block;
  min-height: 1.4rem;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #315c42;
  background: rgba(109, 154, 113, 0.14);
}

.pilot-sync-status.retrying {
  color: #7a5523;
  background: rgba(179, 139, 62, 0.16);
}

.pilot-sync-status.fallback {
  color: #8a2630;
  background: rgba(179, 92, 121, 0.16);
}

.assignment-menu {
  position: fixed;
  z-index: 500;
  width: 240px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 250, 242, 0.98);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.assignment-menu-title {
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--accent-2);
}

.assignment-menu button {
  width: 100%;
  margin-bottom: 6px;
  text-align: left;
}

.assignment-menu button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.assignment-menu-note {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.map > svg {
  width: 100%;
  height: 100%;
  display: block;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.75),
    rgba(248, 242, 233, 0.85)
  );
  border-radius: 16px;
}

.leaflet-container {
  width: 100%;
  height: 100%;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.75),
    rgba(248, 242, 233, 0.85)
  );
  border-radius: 16px;
  font-family: inherit;
}

.sector-label {
  width: 190px;
  text-align: center;
  color: #17232d;
  font-size: 0.78rem;
  line-height: 1.15;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.95);
}

.sector-label strong,
.sector-label small {
  display: block;
}

.sector-label small {
  margin-top: 2px;
  font-size: 0.7rem;
  font-weight: 500;
}

.pilot-frequency-label {
  width: 86px;
  text-align: center;
  color: #17232d;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 26px;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.98);
}

.pilot-position-marker {
  width: 20px !important;
  height: 20px !important;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: #c32f2f;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
  cursor: default;
}

.pilot-position-marker.is-draggable {
  cursor: grab;
}

.pilot-position-marker.is-draggable:active {
  cursor: grabbing;
}

.flight-position-marker {
  width: 40px !important;
  height: 40px !important;
  background: transparent;
}

.flight-position-marker .flight-dot {
  position: absolute;
  top: 15px;
  left: 15px;
  display: block;
  width: 10px;
  height: 10px;
  border: 1.5px solid #ffffff;
  border-radius: 50%;
  background: var(--flight-color, #214f70);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.flight-position-marker .flight-track {
  position: absolute;
  top: 19px;
  left: 20px;
  width: 16px;
  height: 2px;
  background: var(--flight-color, #214f70);
  border-radius: 2px;
  opacity: 0.85;
  transform: rotate(var(--flight-track));
  transform-origin: left center;
}

.sector {
  fill: rgba(155, 77, 47, 0.14);
  stroke: #7b5d45;
  stroke-width: 1.5;
}

.fir {
  fill: none;
  stroke: #6e6a63;
  stroke-width: 2;
  stroke-dasharray: 6 4;
}

.inner-sector {
  fill: rgba(255, 255, 255, 0.2);
  stroke: rgba(70, 70, 70, 0.25);
  stroke-width: 1;
}

.inner-sector.active {
  fill-opacity: 0.85;
  stroke: #1e5360;
  stroke-width: 3;
}

.pilot-dot {
  fill: #c32f2f;
  stroke: white;
  stroke-width: 2;
}

.pilot-grid {
  align-items: stretch;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(440px, 100%);
  padding: 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.auth-card label,
.stack label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}
.auth-card input,
.stack input {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}
.supervisor-toolbar {
  align-items: end;
  flex-wrap: wrap;
}
.supervisor-toolbar label {
  display: grid;
  gap: 5px;
  font-size: 0.85rem;
}
.proposal-button.has-proposals {
  animation: proposal-pulse 1.4s ease-in-out infinite;
  background: #b35c79;
  color: white;
  border-color: #b35c79;
}

.has-pending-changes {
  background: #9b4d2f;
  color: #ffffff;
  border-color: #9b4d2f;
}
@keyframes proposal-pulse {
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 0 8px rgba(179, 92, 121, 0.15);
  }
}
dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: none;
  overflow: visible;
  border: 0;
  padding: 0;
  border-radius: 18px;
  background: transparent;
  box-shadow: var(--shadow);
}
dialog::backdrop {
  background: rgba(21, 30, 35, 0.45);
}
.dialog-card {
  position: relative;
  max-height: 82vh;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px;
  background: var(--panel);
}
.threshold-override {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}
.threshold-override button {
  white-space: nowrap;
}
.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
}
.dialog-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.audit-log {
  max-height: 280px;
  overflow: auto;
}
.audit-entry {
  padding: 9px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 3px;
  font-size: 0.84rem;
}
.audit-entry span {
  color: var(--muted);
}

.active-proposal {
  border: 2px solid #b35c79;
  background: rgba(179, 92, 121, 0.1);
}

.proposal-map-indicator {
  color: #8a2630;
  font-size: 0.8rem;
  text-transform: uppercase;
}
.error-page {
  padding: 32px;
  font:
    1.1rem "Segoe UI",
    sans-serif;
}

.designer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 16px;
  min-height: 640px;
}

.designer-layout .map {
  min-height: 640px;
}

.designer-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.designer-sidebar h2 {
  margin: 0;
  font-size: 1rem;
}

.designer-sidebar label {
  display: grid;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 700;
}

.cell-list {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
}

.cell-list-item {
  overflow: hidden;
  border: 1px solid var(--line);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-list-item.active {
  border-color: var(--accent);
  background: #f8e6d8;
}

.cell-details {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-strong);
}

.cell-details dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.cell-details dl div {
  display: grid;
  gap: 2px;
}

.cell-details dt {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}

.cell-details dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.85rem;
}

@media (max-width: 960px) {
  .hero,
  .panel-head,
  .content-grid {
    grid-template-columns: 1fr;
    display: grid;
  }
  .map {
    min-height: 420px;
  }
  .app-logo {
    width: 82px;
  }
  .designer-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .designer-layout .map {
    min-height: 420px;
  }
}
