:root {
  --ucm-red: #CF202E;
  --ucm-black: #000000;
  --ucm-gray: #A7A9AC;
  --bg: #0B0D10;
  --panel: #14171C;
  --panel-2: #1B1F26;
  --line: #262B33;
  --text: #E7E9EC;
  --text-dim: #9AA2AD;
  --text-mute: #6B7480;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.mono { font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace; }

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ===== TOP BAR ===== */
.topbar { flex-shrink: 0; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar-row1 {
  display: flex; align-items: center; gap: 16px; height: 60px; padding: 0 18px;
  border-bottom: 1px solid var(--line);
}
.topbar-row2 { display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 18px; }
.route-label { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; color: var(--text-mute); flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand-title { font-size: 17px; font-weight: 700; letter-spacing: 0.3px; color: #fff; line-height: 1; }
.brand-sub { font-size: 8.5px; letter-spacing: 1px; color: var(--text-mute); margin-top: 2px; }
.divider { width: 1px; height: 30px; background: var(--line); flex-shrink: 0; }

.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 9px; letter-spacing: 1px; color: var(--text-mute); }
.field input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  padding: 6px 10px;
  width: 96px;
  outline: none;
}
.field input:focus { border-color: var(--ucm-red); }
.field-dest input { border-color: rgba(207,32,46,0.5); background: rgba(207,32,46,0.06); }
.field-altn input { width: 72px; color: var(--text-dim); }
.field-altn input:not(:placeholder-shown) { color: var(--text); }
.opt-tag { text-transform: none; letter-spacing: 0; color: var(--text-mute); font-size: 8.5px; }

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 999px;
  background: var(--panel-2); border: none; color: var(--text-dim);
  cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { color: #fff; }

.route-input-wrap {
  flex-grow: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  height: 36px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 7px; padding: 0 12px;
}
.route-input-wrap input {
  border: none; background: transparent; padding: 0; width: 100%;
  font-size: 15px; font-weight: 600; letter-spacing: 0.4px;
}
.route-input-wrap input:focus { outline: none; }

.primary-btn {
  height: 38px; padding: 0 18px; border: none; border-radius: 8px;
  background: var(--ucm-red); color: #fff; font-size: 13px; font-weight: 700;
  letter-spacing: 0.4px; cursor: pointer; flex-shrink: 0;
}
.primary-btn:hover { background: #e3283a; }
.primary-btn:active { background: #a91824; }

.status-msg { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.status-msg.error { color: #FCA5A5; }
.status-msg.ok { color: #86EFAC; }

/* suggest dropdown */
.field { position: relative; }
.suggest {
  position: absolute; top: 100%; left: 0; margin-top: 4px; width: 260px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  max-height: 260px; overflow-y: auto; z-index: 50; display: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.suggest.open { display: block; }
.suggest-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover, .suggest-item.hi { background: rgba(207,32,46,0.15); }
.suggest-item .code { font-weight: 700; font-size: 13px; color: #fff; margin-right: 8px; font-family: "SF Mono", monospace; }
.suggest-item .name { font-size: 11px; color: var(--text-dim); }
.suggest-item .charts-flag { font-size: 9px; color: var(--ucm-red); float: right; letter-spacing: 0.5px; }

/* ===== BODY ===== */
.body-area { flex-grow: 1; display: flex; min-height: 0; }
#map { flex-grow: 1; background: #e8e4d8; }

.side-panel {
  width: 340px; flex-shrink: 0; background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}

.apt-toggle { display: flex; gap: 8px; padding: 14px 14px 10px; }
.apt-toggle-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0; border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--text-dim); cursor: pointer;
}
.apt-toggle-btn .apt-toggle-code { font-size: 14px; font-weight: 700; color: #fff; }
.apt-toggle-btn .apt-toggle-role { font-size: 9px; letter-spacing: 1px; }
.apt-toggle-btn.active { border-color: var(--ucm-red); background: rgba(207,32,46,0.12); color: #f3b7bd; }

.proc-tabs { display: flex; padding: 0 14px; gap: 20px; border-bottom: 1px solid var(--line); }
.proc-tab {
  background: none; border: none; padding: 8px 0 10px; font-size: 12px;
  font-weight: 600; letter-spacing: 0.4px; color: var(--text-mute); cursor: pointer;
  border-bottom: 2px solid transparent;
}
.proc-tab.active { color: #fff; border-bottom-color: var(--ucm-red); }

.proc-list { flex-grow: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.proc-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  border-left: 3px solid transparent; cursor: pointer;
}
.proc-item:hover { background: rgba(255,255,255,0.04); }
.proc-item.selected { background: rgba(207,32,46,0.12); border-left-color: var(--ucm-red); }
.proc-item .p-icon { flex-shrink: 0; color: var(--text-mute); }
.proc-item.selected .p-icon { color: #f3b7bd; }
.proc-item .p-name { font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.3; }
.proc-empty { padding: 20px 12px; color: var(--text-mute); font-size: 12px; text-align: center; }

.chart-viewer {
  flex-grow: 1; min-width: 0; display: flex; flex-direction: column; background: #525659;
}
.chart-viewer[hidden] { display: none; }
.chart-viewer-head {
  flex-shrink: 0; height: 40px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line);
  color: #fff; font-size: 13px; font-weight: 600;
}
.chart-viewer-title { font-family: "SF Mono", monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-tools { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.chart-tools-divider { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.chart-zoom-label { font-size: 11px; color: var(--text-dim); width: 38px; text-align: center; }
.chart-viewer-close {
  width: auto; border-radius: 7px; padding: 0 12px; height: 28px; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
}
.chart-stage {
  flex-grow: 1; min-height: 0; overflow: auto; background: #525659;
  display: flex; align-items: center; justify-content: center;
}
#chart-viewer-frame {
  flex-shrink: 0; width: 100%; height: 100%; background: #fff; border: none;
  transform-origin: center center; transition: transform 0.12s ease;
}

.app-footer {
  flex-shrink: 0; padding: 6px 16px; font-size: 10px; color: var(--text-mute);
  background: var(--panel); border-top: 1px solid var(--line); text-align: center;
}

/* Map layer control */
.layer-control {
  background: rgba(20,23,28,0.92); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; box-shadow: 0 4px 14px rgba(0,0,0,0.35); font-size: 11px;
  color: var(--text); min-width: 118px;
}
.layer-control .lc-title {
  font-size: 9px; letter-spacing: 1px; color: var(--text-mute); margin-bottom: 6px;
}
.layer-control label {
  display: flex; align-items: center; gap: 7px; padding: 3px 0; cursor: pointer; user-select: none;
}
.layer-control input[type="checkbox"] { accent-color: var(--ucm-red); width: 13px; height: 13px; margin: 0; }

/* Leaflet tweaks */
.leaflet-container { background: #e8e4d8; font-family: inherit; }
.wp-label {
  background: rgba(11,13,16,0.85); color: #fff; padding: 1px 5px; border-radius: 3px;
  font-size: 11px; font-weight: 700; font-family: "SF Mono", monospace; white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.15);
}
.apt-label {
  background: var(--ucm-red); color: #fff; padding: 2px 6px; border-radius: 3px;
  font-size: 12px; font-weight: 800; font-family: "SF Mono", monospace; white-space: nowrap;
}
.altn-label {
  background: var(--panel-2); color: var(--ucm-gray); border: 1px dashed var(--ucm-gray);
  padding: 2px 6px; border-radius: 3px; font-size: 12px; font-weight: 800;
  font-family: "SF Mono", monospace; white-space: nowrap;
}
.artcc-label {
  color: #2b3138; font-size: 13px; font-weight: 800; letter-spacing: 1.5px;
  text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff, 0 0 6px #fff;
  white-space: nowrap; text-align: center; line-height: 1.25;
}
.artcc-label .artcc-sub {
  display: block; font-size: 9.5px; font-weight: 700; letter-spacing: 0.3px; color: #4a5158;
}
.net-label {
  background: rgba(255,255,255,0.88) !important; color: #14171c !important;
  border: 1px solid rgba(0,0,0,0.25) !important; box-shadow: none !important;
  padding: 0px 4px !important; border-radius: 2px; font-size: 10px; font-weight: 700;
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace; white-space: nowrap;
}
.net-label::before { display: none; }
.net-label-awy { background: rgba(122,79,190,0.92) !important; color: #fff !important; border-color: rgba(0,0,0,0.2) !important; }
.mora-cell {
  color: #14171c; background: rgba(255,255,255,0.55); border: 1px solid rgba(0,0,0,0.35);
  border-radius: 3px; padding: 1px 4px; font-size: 12px; font-weight: 800;
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace; white-space: nowrap;
}
