:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e5e5e5;
  --text: #1a1a1a;
  --text-muted: #666;
  --accent: #1a73e8;
  --ok: #2d7a3e;
  --warn: #d97706;
  --danger: #c62828;
  --info: #1565c0;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom);
}

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}
header button {
  background: transparent;
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 18px;
  cursor: pointer;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.card-header h2 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
}
.card h2 { font-weight: 600; }

.muted { color: var(--text-muted); font-size: 13px; }
.hidden { display: none !important; }
.link-btn {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font: inherit; padding: 0;
}

button {
  font: inherit;
  padding: 9px 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 500;
  min-height: 38px;
}
button.secondary {
  background: white;
  color: var(--text);
  border-color: var(--border);
}
button.small { padding: 4px 8px; min-height: 28px; font-size: 12px; }
button:hover { opacity: 0.92; }
button:active { transform: translateY(1px); }

input[type="text"], input[type="number"], input[type="datetime-local"] {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--text);
  width: 100%;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.form-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.form-row label { min-width: 90px; color: var(--text-muted); font-size: 13px; }

/* Status lamp */
.status-card { padding: 16px; border-width: 2px; }
.status-card.status-green   { border-color: var(--ok);     background: #f1faf1; }
.status-card.status-yellow  { border-color: var(--warn);   background: #fffaf0; }
.status-card.status-red     { border-color: var(--danger); background: #fdecea; }
.status-card.status-loading { border-color: var(--border); background: #f9f9f9; }

.status-row { display: flex; align-items: center; gap: 14px; }
.lamp {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.06) inset;
}
.lamp.green   { background: radial-gradient(circle at 35% 35%, #6ed87f, #2d7a3e); box-shadow: 0 0 14px rgba(45,122,62,0.5), 0 0 0 2px rgba(0,0,0,0.06) inset; }
.lamp.yellow  { background: radial-gradient(circle at 35% 35%, #ffd76a, #d97706); box-shadow: 0 0 14px rgba(217,119,6,0.5), 0 0 0 2px rgba(0,0,0,0.06) inset; }
.lamp.red     { background: radial-gradient(circle at 35% 35%, #ff7065, #c62828); box-shadow: 0 0 14px rgba(198,40,40,0.5), 0 0 0 2px rgba(0,0,0,0.06) inset; }
.lamp.loading { background: #d4d4d4; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 0.6; } 50% { opacity: 1; } }

.status-text h2 { margin: 0; font-size: 19px; }
.status-text p { margin: 2px 0 0; }

.status-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
}
.status-list li {
  padding: 5px 0 5px 26px;
  position: relative;
  font-size: 14px;
}
.status-list li::before {
  position: absolute;
  left: 0;
  top: 5px;
}
.status-list li.blocker::before { content: '⛔'; }
.status-list li.warning::before { content: '⚠️'; }
.status-list li.ok::before      { content: '✅'; }
.status-list li.info::before    { content: 'ℹ️'; }

/* Map */
#map {
  width: 100%;
  height: 320px;
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.leaflet-container {
  font-family: inherit;
  font-size: 13px;
}

.position-info {
  margin-bottom: 4px;
}
.position-coords {
  font-family: ui-monospace, 'SF Mono', Monaco, monospace;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.position-label {
  width: 100%;
  border: none;
  border-bottom: 1px dashed transparent;
  padding: 4px 0;
  background: transparent;
  font-size: 14px;
  color: var(--text);
  outline: none;
}
.position-label:hover, .position-label:focus { border-bottom-color: var(--border); }
.position-label::placeholder { color: #999; font-style: italic; }

.sub-panel {
  background: #f7f7f7;
  border-radius: 8px;
  padding: 12px;
  margin-top: 10px;
}
.sub-panel h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}

.sim-banner {
  background: #e3f2fd;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.sim-banner .badge {
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}
.sim-banner #simBannerText { flex: 1; }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  background: #f7f7f7;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.ok      { background: #e6f4ea; color: var(--ok); }
.badge.warn    { background: #fff3e0; color: var(--warn); }
.badge.danger  { background: #fdecea; color: var(--danger); }
.badge.info    { background: #e3f2fd; color: var(--accent); }
.badge.neutral { background: #f0f0f0; color: var(--text-muted); }

.metar-text {
  font-family: ui-monospace, 'SF Mono', Monaco, monospace;
  font-size: 12px;
  background: #f7f7f7;
  padding: 8px 10px;
  border-radius: 4px;
  margin: 6px 0;
  word-break: break-all;
}

.box {
  padding: 10px 12px;
  border-radius: 4px;
  margin: 8px 0;
  border-left: 3px solid;
}
.box.warn    { background: #fff8e1; border-color: var(--warn); }
.box.danger  { background: #ffebee; border-color: var(--danger); }
.box.ok      { background: #e8f5e9; border-color: var(--ok); }
.box.info    { background: #e3f2fd; border-color: var(--accent); }

footer.meta {
  text-align: center;
  padding: 16px 4px 20px;
  font-size: 12px;
}
footer.meta p { margin: 4px 0; }

@media (max-width: 480px) {
  main { padding: 8px; }
  .card { padding: 12px; margin-bottom: 8px; border-radius: 8px; }
  #map { height: 260px; }
  header h1 { font-size: 15px; }
  .status-text h2 { font-size: 17px; }
  table { font-size: 12px; }
  th, td { padding: 5px 6px; }
}
