:root{--panel-bg:#071016;--panel-border:#152026;--accent:#0d2538}
/* Make box-sizing predictable so padding/margins align elements reliably */
*, *:before, *:after { box-sizing: border-box; }
body{font-family:Segoe UI,Arial,sans-serif;margin:0;background:#0b0f14;color:#e6eef8}
header{padding:12px 20px;background:var(--accent);color:#fff;display:flex;align-items:center;justify-content:space-between}
.header-left{display:flex;align-items:center;gap:12px}
.header-right{min-width:0} /* placeholder for future dropdowns */
#logo-placeholder{width:60px;height:60px;background:transparent;border-radius:6px;display:flex;align-items:center;justify-content:center;color:#000;font-weight:bold}
#logo-placeholder img{max-width:100%;max-height:100%;display:block;border-radius:6px}
h1{margin:0;font-size:1.5rem}
.controls{display:flex;flex-direction:row;gap:12px;align-items:center}
.controls label{margin-right:6px;color:#fff}
.controls input{margin-left:6px}
.affiliations{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.controls-actions{display:flex;gap:8px}
main{padding:12px}
.controls-section{margin-bottom:12px;padding:8px;background:#0b0f14;border:1px solid #152026;border-radius:6px}
.panels{display:block;gap:12px}
.panel{background:var(--panel-bg);border:1px solid var(--panel-border);padding:8px;border-radius:6px;overflow-x:auto}
.panel-row{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}
.panel-row > .panel{min-width:0}
.panel{min-width:0}
.panel ul{max-width:100%;overflow-wrap:break-word}
.vso-controls{display:flex;align-items:center;gap:12px;margin-bottom:8px}
.vso-controls label{color:#dfefff}
.vso-controls input[type="text"], .vso-controls input[type="number"]{background:#081218;border:1px solid #23303a;color:#dfefff;padding:4px;border-radius:4px;width:70px}
.vso-controls .affiliations{display:flex;gap:8px;align-items:center}
.aff-dropdown-container{position:relative;display:flex;gap:4px}
.dropdown-btn{background:#0d2538;border:1px solid #23303a;color:#dfefff;padding:4px 8px;border-radius:4px;cursor:pointer;font-size:12px;min-width:30px}
.dropdown-btn:hover{background:#11507a}
.aff-dropdown{position:absolute;top:100%;left:0;background:#081218;border:1px solid #23303a;border-radius:4px;padding:8px;min-width:200px;max-height:300px;overflow-y:auto;z-index:1000;display:none}
.aff-dropdown.show{display:block}
.aff-option{display:flex;align-items:center;gap:8px;padding:4px 0;border-bottom:1px solid #23303a}
.aff-option:last-child{border-bottom:none}
.aff-option input[type="checkbox"]{margin:0}
.aff-option label{color:#dfefff;cursor:pointer;flex:1;display:flex;align-items:center;gap:8px}
.aff-option .delete-aff{
	background: transparent;
	border: none;
	color: #ff6b6b;
	width: 20px;
	height: 20px;
	display:flex;
	align-items:center;
	justify-content:center;
	cursor:pointer;
	transition: transform .12s ease, color .12s ease;
	padding:0;
}
.aff-option .delete-aff svg{display:block;width:14px;height:14px}
.aff-option .delete-aff:hover{color:#ff4757;transform:scale(1.12)}
.aff-option .delete-aff:focus{outline:2px solid rgba(255,71,87,0.12);outline-offset:2px;border-radius:4px}

/* Generic button styles */
.btn{background:#0d2538;border:1px solid #23303a;color:#dfefff;padding:6px 10px;border-radius:6px;cursor:pointer}
.btn:hover{background:#11507a}
.controls-actions .btn{padding:6px 12px}
.panel h2{color:#cfe6ff}
/* Panel header layout: align title left and controls right */
.panel-header{display:flex;align-items:center;justify-content:space-between;gap:12px}
.panel-header .vso-controls{margin-bottom:0}
/* On narrow viewports stack header elements */
@media (max-width:960px){
	.panel-header{flex-direction:column;align-items:stretch;gap:8px}
	.panel-header .vso-controls{justify-content:flex-start;flex-wrap:wrap}
}
/* Give the maps section the same horizontal padding as <main> so the
	outer edges of the maps align with the tables rendered inside <main>. */
#maps-section{padding:12px 0 0;position:relative;}

/* Center content and constrain width so maps and tables align exactly.
	Pick a comfortable max-width that matches the desired layout; feel free
	to adjust this value if you want a wider or narrower layout. */
.container{max-width:1800px;margin:0 auto;padding:0 12px;width:100%;}

/* On very wide displays keep the content from becoming absurdly wide.
	 Prefer using a viewport-relative cap so large-but-not-huge monitors
	 look good while still giving plenty of horizontal room. */
@media (min-width:2200px){
	.container{max-width:90vw}
}
/* Responsive: collapse to single column on narrow viewports */
@media (max-width:960px){
	#maps-container{grid-template-columns:1fr}
	.panel-row{grid-template-columns:1fr}
	#maps-container{height:45vh}
}
/* make the maps side by side using the same two-column grid as panels
   so columns align exactly between the maps row and the subsequent panel rows */
#maps-container{display:grid;grid-template-columns:repeat(2,1fr);gap:12px;height:55vh;width:100%;max-width:none;margin:0;padding:0;align-items:stretch}
/* Map divs are direct grid children with panel styling - they occupy exactly
   the same grid column width as panels with identical padding/border */
#p56-map, #sfra-map{
	min-width:0;
	height:100%;
	position:relative;
	background:var(--panel-bg);
	border:1px solid var(--panel-border);
	padding:8px;
	border-radius:6px;
	box-sizing:border-box;
}
ul{margin:6px 0;padding-left:18px}
li{margin-bottom:6px}
.legend{position:absolute;right:12px;top:12px;background:rgba(6,10,14,0.85);padding:10px;border-radius:6px;color:#dfefff;z-index:4000}
/* Colored checkmark labels */
.legend .legend-check{display:flex;align-items:center;cursor:pointer;user-select:none}
.legend .legend-check input[type="checkbox"]{margin:0;opacity:0;width:0;height:0;position:absolute}
.legend .legend-check .checkmark{font-size:16px;font-weight:bold;margin-right:6px;transition:opacity 0.2s}
.legend .legend-check input[type="checkbox"]:not(:checked) + .checkmark{opacity:0.3}
/* Color classes for checkmarks and airspace borders */
.legend .frz .checkmark{color:#f0ad4e}
.legend .p56 .checkmark{color:#d9534f}
.legend .sfra .checkmark{color:#0275d8}
.legend .ground .checkmark{color:#6c757d}
.legend .vicinity .checkmark{color:#28a745}
/* aircraft tooltip */
/* Ensure tooltip text is readable even when Leaflet applies default styles.
	Use selector specificity so our styles take precedence. */
.ac-tooltip{color:#ffffff;font-size:13px;line-height:1.2}
.ac-tooltip div{margin:2px 0}
/* Leaflet wraps tooltips with .leaflet-tooltip; ensure our fp-tooltip variant
	and its inner .ac-tooltip inherit the white color regardless of defaults. */
.leaflet-tooltip.fp-tooltip, .leaflet-tooltip.fp-tooltip .ac-tooltip { color: #ffffff !important; }
.ac-tooltip .ac-type{color:#cfe6ff;font-weight:600;margin-left:6px}

/* Collapsible legend styles */
.legend .legend-header{margin-bottom:6px}
.legend .legend-header button{background:transparent;border:0;color:#dfefff;font-size:1rem;cursor:pointer}
.legend.collapsed .legend-body{display:none}

footer{padding:12px 20px;background:#071016;color:#e6eef8;text-align:center}
.disclaimers{margin-bottom:8px}
.disclaimers p{margin:4px 0;font-size:0.9rem;color:#cfe6ff}
.build-info{margin-top:8px;font-size:0.85rem;color:#8b9db8;font-family:monospace;display:flex;align-items:center;justify-content:center;gap:4px;flex-wrap:wrap}
.build-info .github-link{display:inline-flex;align-items:center;color:#cfe6ff;text-decoration:none;line-height:1}
.build-info .github-link:hover{color:#9fc5ff}
.build-info .gh-icon{width:20px;height:20px;fill:currentColor;display:block}
/* flight plan tooltip styling */
.fp-tooltip .fp{white-space:pre-wrap;max-width:360px;display:block;color:#fff;font-size:12px}
.fp-tooltip{background:rgba(6,10,14,0.98);border:1px solid rgba(255,255,255,0.06);padding:6px;border-radius:4px}
.traffic-table{width:100%;border-collapse:collapse;font-size:0.85rem;table-layout:auto;min-width:800px}
.traffic-table thead{position:sticky;top:0;z-index:10;display:block;width:100%;overflow-y:auto;scrollbar-gutter:stable}
.traffic-table tbody{display:block;max-height:400px;overflow-y:auto;width:100%;scrollbar-gutter:stable}
.traffic-table thead tr, .traffic-table tbody tr{display:table;width:100%;table-layout:fixed}
.traffic-table th, .traffic-table td{padding:3px 4px;border-bottom:1px solid #23303a;text-align:center;word-wrap:break-word;white-space:normal;overflow:hidden;min-width:50px}
.traffic-table th{background:#0d2538;color:#cfe6ff;font-weight:600}
/* Bearing, Range, Alt, GS, Dep, Arr columns get minimum 300px width */
#p56-table th:nth-child(5), #p56-table td:nth-child(5),
#p56-table th:nth-child(6), #p56-table td:nth-child(6),
#p56-table th:nth-child(7), #p56-table td:nth-child(7),
#p56-table th:nth-child(8), #p56-table td:nth-child(8),
#p56-table th:nth-child(10), #p56-table td:nth-child(10),
#p56-table th:nth-child(11), #p56-table td:nth-child(11),
#sfra-table th:nth-child(5), #sfra-table td:nth-child(5),
#sfra-table th:nth-child(6), #sfra-table td:nth-child(6),
#sfra-table th:nth-child(7), #sfra-table td:nth-child(7),
#sfra-table th:nth-child(8), #sfra-table td:nth-child(8),
#sfra-table th:nth-child(10), #sfra-table td:nth-child(10),
#sfra-table th:nth-child(11), #sfra-table td:nth-child(11),
#frz-table th:nth-child(5), #frz-table td:nth-child(5),
#frz-table th:nth-child(6), #frz-table td:nth-child(6),
#frz-table th:nth-child(7), #frz-table td:nth-child(7),
#frz-table th:nth-child(8), #frz-table td:nth-child(8),
#frz-table th:nth-child(10), #frz-table td:nth-child(10),
#frz-table th:nth-child(11), #frz-table td:nth-child(11),
#vso-table th:nth-child(6), #vso-table td:nth-child(6),
#vso-table th:nth-child(7), #vso-table td:nth-child(7),
#vso-table th:nth-child(8), #vso-table td:nth-child(8),
#vso-table th:nth-child(9), #vso-table td:nth-child(9),
#vso-table th:nth-child(11), #vso-table td:nth-child(11),
#vso-table th:nth-child(12), #vso-table td:nth-child(12) {min-width:300px}
/* P56 Events: Aircraft, Dep, Arr columns */
#p56-events-table th:nth-child(2), #p56-events-table td:nth-child(2),
#p56-events-table th:nth-child(6), #p56-events-table td:nth-child(6),
#p56-events-table th:nth-child(7), #p56-events-table td:nth-child(7) {min-width:300px}
.traffic-table tbody tr:hover{background:#152026}
.traffic-table .expandable{cursor:pointer}
.traffic-table .flight-plan{display:none}
.traffic-table .flight-plan.show{display:table-row}
.traffic-table .flight-plan-cell{background:#081218;padding:0 !important;border-top:1px solid #23303a}
.traffic-table .flight-plan pre{font-size:0.8rem;color:#dfefff;margin:0;white-space:pre-wrap}
/* Flight plan form styles (compact inline) */
.fp-compact{display:block;width:100%;box-sizing:border-box;padding:10px;background:rgba(6,10,14,0.9);border-radius:4px;overflow-wrap:break-word}
.fp-row-inline{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin-bottom:8px;max-width:100%}
.fp-inline-field{background:#071016;border:1px solid #23303a;padding:6px 12px;border-radius:4px;display:inline-flex;gap:8px;align-items:center;white-space:nowrap;box-sizing:border-box}
.fp-lbl{font-size:11px;color:#5b9adb;font-weight:700;letter-spacing:0.02em}
.fp-inline-field{color:#e6eef8;font-size:13px}
.fp-route-field{flex:1 1 calc(100% - 20px);min-width:0;max-width:calc(100% - 20px);overflow:hidden;text-overflow:ellipsis;white-space:pre-wrap;word-break:break-word;overflow-wrap:break-word;box-sizing:border-box}
.fp-remarks-box{flex:1 1 calc(100% - 20px);min-width:0;max-width:calc(100% - 20px);background:#071016;border:1px solid #23303a;padding:10px;border-radius:4px;display:flex;flex-direction:column;gap:4px;overflow-wrap:break-word;box-sizing:border-box}
.fp-rmk-text{color:#e6eef8;font-size:12px;white-space:pre-wrap;line-height:1.4;word-break:break-word;overflow-wrap:break-word;max-width:100%}
/* Block layout for RTE and RMK sections */
.fp-row-block{display:block;margin-bottom:8px;max-width:100%;background:#071016;border:1px solid #23303a;padding:10px;border-radius:4px;overflow-wrap:break-word;box-sizing:border-box}
.fp-route-content{color:#e6eef8;font-size:13px;white-space:pre-wrap;line-height:1.4;word-break:break-word;overflow-wrap:break-word;max-width:100%;margin-top:4px;padding-left:0}
.fp-rmk-content{color:#e6eef8;font-size:12px;white-space:pre-wrap;line-height:1.4;word-break:break-word;overflow-wrap:break-word;max-width:100%;margin-top:4px;padding-left:0}
.traffic-table .flight-plan-cell{padding:0 !important;box-sizing:border-box}
/* Squawk highlighting */
.traffic-table .squawk-1200{color:#fff3cd !important} /* yellow */
.traffic-table .squawk-emergency{color:#f8d7da !important} /* red */
.traffic-table .squawk-7777{color:#ffeaa7 !important} /* orange */
/* Ground aircraft divider - subtle horizontal line across all cells */
.traffic-table tr.ground-divider td{
	padding:0 !important;
	height:1px;
	background:transparent;
	border-bottom:2px solid #23303a;
}
.traffic-table .squawk-vfr{color:#d1ecf1 !important} /* blue */

/* Status text colors to match map colors */
.status-frz{color:#f0ad4e;font-weight:700}
.status-p56{color:#d9534f;font-weight:700}
.status-sfra{color:#0275d8;font-weight:700}
.status-ground{color:#6c757d;font-weight:700}
.status-vicinity{color:#28a745;font-weight:700}
.status-airborne{color:#ffffff;font-weight:700}

/* small swatches next to status labels */
.status-swatch{display:inline-block;width:12px;height:12px;border-radius:2px;margin-right:8px;vertical-align:middle;border:1px solid rgba(0,0,0,0.25)}
.status-swatch-frz{background:#f0ad4e}
.status-swatch-p56{background:#d9534f}
.status-swatch-sfra{background:#0275d8}
.status-swatch-ground{background:#6c757d}
.status-swatch-vicinity{background:#28a745}
.status-swatch-airborne{background:#ffffff}
.status-label{font-weight:700}

/* Leaderboard callsigns cell: allow multiple callsigns to wrap and display on separate lines */
.lb-callsigns{white-space:normal;word-break:break-word;line-height:1.2;font-size:0.95rem}
/* small, subtle indicator when there are additional callsigns not shown */
.callsign-more{color:#9fb9d8;font-size:0.85rem;margin-top:4px}

/* clickable table headers */
.traffic-table th{cursor:pointer}
.traffic-table th.sort-asc::after{content:' ▴';font-size:1em;display:inline-block;margin-left:6px;color:#cfe6ff;opacity:0.95}
.traffic-table th.sort-desc::after{content:' ▾';font-size:1em;display:inline-block;margin-left:6px;color:#cfe6ff;opacity:0.95}

/* Make squawk column wrappable */
#sfra-table td:nth-child(9), #frz-table td:nth-child(9), #vso-table td:nth-child(10), #p56-table td:nth-child(9) { white-space: normal; word-break: break-word; }

/* Highlight when a flight path is visible for an aircraft (subtle) */
.row-path-highlight{background:rgba(240,173,78,0.03);box-shadow:inset 0 0 0 2px rgba(240,173,78,0.06);border-left:4px solid rgba(240,173,78,0.08)}

/* Marker/plane halo when its path is visible */
.path-highlight{transform:scale(1.06);filter:drop-shadow(0 0 8px rgba(240,173,78,0.45));transition:transform .12s ease,filter .12s ease}

/* Admin clear button: intentionally subtle. Visibility is cosmetic only;
	 actual security is enforced by the server-side password. */
.admin-clear-btn{
	position:fixed;
	right:12px;
	bottom:12px;
	width:28px;
	height:28px;
	border-radius:6px;
	border:1px solid rgba(255,255,255,0.04);
	background:rgba(255,255,255,0.02);
	color:#cfe6ff;
	font-size:14px;
	line-height:26px;
	text-align:center;
	cursor:pointer;
	opacity:0.06; /* nearly invisible by default */
	transition:opacity .12s ease, transform .12s ease;
	z-index:6000;
}
.admin-clear-btn:hover{ opacity:0.9; transform:scale(1.05); }
.admin-clear-btn:focus{ outline:2px solid rgba(127,179,255,0.18); opacity:0.9 }

/* P56 leaderboard headers should not be clickable (no user sorting) */
#p56-leaderboard-tbody thead th,
table:has(#p56-leaderboard-tbody) th {
  cursor: default;
}

/* P56 leaderboard column width constraints */
#p56-leaderboard-table th:nth-child(1), #p56-leaderboard-table td:nth-child(1), /* Rank */
#p56-leaderboard-table th:nth-child(5), #p56-leaderboard-table td:nth-child(5)  /* P56 Busts */ {
  max-width: 400px;
}

/* Tables will size naturally to content without forced minimum widths */

/* P56 Alert Controls */
.p56-alert-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.p56-alert-controls label {
  color: #dfefff;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.p56-alert-controls input[type="checkbox"] {
  cursor: pointer;
}

/* P56 Alert Banner Overlay */
.p56-alert-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  max-width: 90vw;
  max-height: 90vh;
  background: rgba(6, 10, 14, 0.95);
  border: 2px solid #d9534f;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(217, 83, 79, 0.4);
  display: none;
}
.p56-alert-banner.show {
  display: block;
  animation: fadeIn 0.5s ease-in;
}
.p56-alert-banner.fadeout {
  animation: fadeOut 5s ease-out forwards;
}
.p56-alert-banner img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}
.p56-alert-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #d9534f;
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  line-height: 1;
  transition: background 0.2s ease;
}
.p56-alert-close:hover {
  background: #c9302c;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* Purge modal */
.modal-overlay{
  position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:9000;display:none;align-items:center;justify-content:center
}
.modal-overlay.show{display:flex}
.modal{
  background:#0b0f14;border:1px solid #23303a;border-radius:8px;max-width:900px;width:90vw;max-height:80vh;display:flex;flex-direction:column;box-shadow:0 10px 30px rgba(0,0,0,0.6)
}
.modal header{padding:12px 16px;border-bottom:1px solid #23303a;color:#cfe6ff;display:flex;align-items:center;justify-content:space-between}
.modal .modal-body{padding:10px 16px;overflow:auto}
.modal .list{max-height:50vh;overflow:auto;border:1px solid #23303a;border-radius:6px;padding:8px;background:#071016}
.modal .list-item{display:flex;gap:10px;align-items:center;border-bottom:1px solid #152026;padding:6px 4px}
.modal .list-item:last-child{border-bottom:none}
.modal footer{padding:12px 16px;border-top:1px solid #23303a;display:flex;gap:8px;justify-content:flex-end;background:#071016}
.btn-danger{background:#7a1621;border-color:#a53b47}
.btn-danger:hover{background:#8f1b28}

/* Compact variant for password dialog */
.modal.small{max-width:480px}
.pwd-row{display:flex;gap:8px;align-items:center}
.pwd-field{flex:1;background:#081218;border:1px solid #23303a;color:#dfefff;padding:8px;border-radius:4px}
.btn-icon{min-width:36px;padding:6px 8px;line-height:1}

/* P56 intrusion point labels */
.p56-point-label-wrapper{pointer-events:none;}
.p56-point-label{font-size:10px;color:#ffffff;background:rgba(0,0,0,0.35);padding:2px 4px;border-radius:3px;white-space:nowrap;font-weight:500;backdrop-filter:blur(2px);}
