@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: dark;
  --bg: #11161c;
  --surface: #171e25;
  --surface-raised: #1c252e;
  --surface-soft: #202a34;
  --border: #2a3540;
  --border-strong: #3b4a57;
  --text: #edf2f4;
  --muted: #97a5af;
  --faint: #84959f;
  --signal: #f1c84b;
  --signal-soft: rgba(241, 200, 75, .12);
  --blue: #2787ed;
  --orange: #f2763a;
  --green: #50c795;
  --font: 'Manrope', 'Segoe UI', sans-serif;
  --mono: 'DM Mono', ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(ellipse at 52% -16%, rgba(55, 76, 91, .28), transparent 54%),
    var(--bg);
}
button, input, select { font: inherit; }
button, a, select, input { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
}

.app-shell { width: min(1600px, 100%); margin: 0 auto; padding: 0 34px 24px; }
.topbar {
  height: 82px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(139, 157, 169, .16);
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; color: var(--signal); display: grid; place-items: center; }
.brand-mark svg { width: 40px; height: 40px; }
.brand-copy { display: grid; gap: 2px; }
.eyebrow, .metric-label, .service-kicker, .detail-facts span, .list-scroll-hint {
  font: 500 10px/1.35 var(--mono); letter-spacing: .13em; color: var(--muted);
}
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: -.025em; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.service-link {
  min-width: 154px; display: flex; flex-direction: column; gap: 3px; padding: 10px 13px;
  text-decoration: none; border: 1px solid var(--border); border-radius: 8px; background: rgba(24, 32, 40, .76);
  font-size: 13px; font-weight: 700; transition: border-color .18s, background .18s, transform .18s;
}
.service-link:hover { transform: translateY(-1px); border-color: var(--border-strong); background: var(--surface-raised); }
.service-link-sarpas > span:last-child { color: var(--signal); }
.service-link-rower > span:last-child { color: #e2eaf0; }
.service-kicker { color: var(--faint); font-size: 8px; }

.intro { display: flex; align-items: flex-end; justify-content: space-between; padding: 34px 2px 22px; gap: 18px; }
.intro-kicker { color: var(--signal); display: flex; align-items: center; gap: 8px; margin-bottom: 11px; }
.live-dot, .footer-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(80, 199, 149, .1); }
.intro h1 { margin: 0; font-size: clamp(28px, 3.25vw, 43px); line-height: 1.12; letter-spacing: -.055em; font-weight: 800; }
.intro p { margin: 11px 0 0; max-width: 700px; color: var(--muted); font-size: 14px; }
.source-pill { margin-bottom: 4px; flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; background: rgba(23, 30, 37, .72); padding: 8px 11px; font: 500 9px var(--mono); letter-spacing: .08em; }
.source-pip { width: 6px; height: 6px; border-radius: 50%; background: var(--signal); }

.metrics { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) minmax(170px, 1fr) minmax(260px, 1.7fr); gap: 10px; margin-bottom: 18px; }
.metric-card, .metric-note { min-height: 91px; background: linear-gradient(140deg, rgba(27, 36, 44, .94), rgba(21, 28, 35, .94)); border: 1px solid var(--border); border-radius: 10px; padding: 13px 16px; }
.metric-card { display: grid; align-content: space-between; }
.metric-accent { border-top: 2px solid var(--signal); padding-top: 12px; }
.metric-label { color: var(--faint); font-size: 9px; }
.metric-card strong { font-size: 25px; line-height: 1; letter-spacing: -.04em; }
.metric-caption { font-size: 10px; color: var(--muted); }
.metric-note { display: flex; align-items: center; gap: 11px; color: #c2ccd1; font-size: 11px; line-height: 1.55; }
.note-mark { display: grid; place-items: center; width: 21px; height: 21px; flex: 0 0 auto; border: 1px solid rgba(241, 200, 75, .52); color: var(--signal); border-radius: 50%; font: 500 12px var(--mono); }

.workspace { display: grid; grid-template-columns: minmax(335px, 390px) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.panel { border: 1px solid var(--border); border-radius: 12px; background: linear-gradient(155deg, rgba(24, 32, 40, .98), rgba(20, 27, 34, .98)); box-shadow: 0 12px 34px rgba(0, 0, 0, .18); }
.records-panel { min-height: 690px; display: flex; flex-direction: column; overflow: hidden; }
.panel-heading, .map-heading { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.panel-heading { min-height: 77px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.panel-heading h2, .map-heading h2, .detail-panel h2 { margin: 3px 0 0; font-size: 18px; letter-spacing: -.03em; }
.record-counter { min-width: 36px; height: 30px; display: grid; place-items: center; border: 1px solid var(--border-strong); border-radius: 7px; color: var(--signal); font: 500 12px var(--mono); }

.filters { display: grid; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.search-field { position: relative; display: block; }
.search-field svg { position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); stroke: var(--faint); stroke-width: 1.7; fill: none; pointer-events: none; }
.search-field input, .filter-row input, .filter-row select { width: 100%; height: 37px; border: 1px solid var(--border); border-radius: 7px; background: #12181e; color: var(--text); font-size: 11px; }
.search-field input { padding: 0 11px 0 36px; }
.search-field input::placeholder { color: #74828c; }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.filter-row label { display: grid; gap: 5px; color: var(--faint); font: 500 9px var(--mono); letter-spacing: .04em; }
.filter-row input, .filter-row select { padding: 0 8px; color-scheme: dark; }
.filter-bottom { grid-template-columns: 1fr auto; align-items: end; }
.text-button { height: 36px; border: 0; background: transparent; color: var(--signal); padding: 0 7px; cursor: pointer; font-size: 10px; font-weight: 700; }
.text-button:hover { color: #ffe28a; }

.import-block { padding: 12px 16px 13px; border-bottom: 1px solid var(--border); background: rgba(13, 19, 24, .28); }
.import-copy { display: grid; gap: 3px; }
.import-copy strong { font-size: 11px; }
.import-copy span { color: var(--muted); font-size: 9px; }
.import-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 10px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 0 11px; border-radius: 7px; cursor: pointer; text-decoration: none; font-size: 10px; font-weight: 700; transition: background .18s, border-color .18s, transform .18s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .48; cursor: not-allowed; }
.button-primary { color: #12160f; background: var(--signal); border: 1px solid var(--signal); }
.button-primary:hover { background: #ffdc71; }
.file-picker { position: relative; overflow: hidden; }
.file-picker-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-picker:focus-within { outline: 2px solid var(--signal); outline-offset: 3px; }
.button-quiet { color: #c6d0d5; background: #202932; border: 1px solid var(--border-strong); }
.button-quiet:hover:not(:disabled) { background: #29343e; }
.button-outline { color: var(--signal); background: transparent; border: 1px solid rgba(241, 200, 75, .45); }
.button-outline:hover { background: var(--signal-soft); }
.import-help { margin: 9px 0 0; color: var(--faint); font-size: 9px; line-height: 1.45; }
.import-help code { color: #c2cdd2; font: 10px var(--mono); }

.list-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px 8px; color: var(--muted); font-size: 10px; }
.list-scroll-hint { color: var(--faint); font-size: 7px; letter-spacing: .09em; }
.area-list { flex: 1; min-height: 180px; max-height: 445px; overflow: auto; padding: 0 10px 12px; scrollbar-color: #3a4650 transparent; scrollbar-width: thin; }
.record-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px; padding: 8px 7px 8px 10px; border: 1px solid transparent; border-bottom-color: rgba(58, 71, 82, .58); border-radius: 7px; transition: background .15s, border-color .15s; }
.record-card:hover { background: rgba(39, 52, 63, .64); }
.record-card.is-active { border-color: rgba(241, 200, 75, .37); border-left: 3px solid var(--signal); background: rgba(241, 200, 75, .09); padding-left: 8px; }
.record-main { display: grid; gap: 5px; min-width: 0; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.record-title-row { display: flex; align-items: center; gap: 7px; min-width: 0; }
.record-title { overflow: hidden; color: #e6ecef; font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.height-badge { flex: 0 0 auto; border-radius: 4px; padding: 2px 5px; font: 500 8px var(--mono); }
.height-badge-30 { color: #91caff; border: 1px solid rgba(39, 135, 237, .37); background: rgba(39, 135, 237, .13); }
.height-badge-90 { color: #ffb18b; border: 1px solid rgba(242, 118, 58, .4); background: rgba(242, 118, 58, .13); }
.record-subline { display: flex; align-items: center; gap: 7px; min-width: 0; color: var(--muted); font: 9px var(--mono); }
.record-protocol { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-date { flex: 0 0 auto; color: #aebac0; font: 9px var(--font); }
.record-actions { display: flex; gap: 4px; }
.icon-action { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: #182128; color: var(--muted); text-decoration: none; cursor: pointer; font-size: 9px; font-weight: 700; }
.icon-action:hover { color: var(--signal); border-color: var(--border-strong); }
.empty-state { display: grid; justify-items: center; gap: 5px; padding: 30px 16px; color: var(--muted); text-align: center; font-size: 11px; }
.empty-state strong { color: var(--text); }
.empty-state[hidden], .reset-button[hidden] { display: none; }

.map-column { display: grid; grid-template-rows: minmax(420px, 1fr) auto; gap: 12px; min-width: 0; }
.map-panel { min-height: 480px; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.map-heading { min-height: 70px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.map-heading h2 { font-size: 17px; }
.legend { display: flex; align-items: center; gap: 12px; color: var(--muted); font: 10px var(--mono); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; }
.dot-30 { background: var(--blue); }
.dot-90 { background: var(--orange); }
.map-frame { position: relative; flex: 1; min-height: 350px; margin: 12px; overflow: hidden; border: 1px solid #34414a; border-radius: 8px; background: #d4d8d5; }
#map { position: absolute; inset: 0; min-height: 350px; z-index: 1; }
.map-message { position: absolute; z-index: 500; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(17, 23, 29, .94); color: var(--muted); text-align: center; font-size: 12px; line-height: 1.6; }
.map-message[hidden] { display: none; }
.leaflet-container { background: #dfe4e0; font-family: var(--font); }
.leaflet-control-zoom a { background: #172029 !important; color: #e8eef0 !important; border-color: #3b4852 !important; }
.leaflet-control-attribution { color: #2c3b43 !important; background: rgba(238, 242, 238, .8) !important; font-size: 9px !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #172029; color: var(--text); }
.leaflet-popup-content { margin: 11px 13px; font-size: 11px; line-height: 1.5; }
.popup-title { display: block; color: var(--signal); font: 500 11px var(--mono); }
.popup-copy { display: block; margin-top: 3px; color: #bdc8ce; }
.map-stamp { position: absolute; z-index: 450; top: 12px; left: 12px; display: inline-flex; align-items: center; gap: 7px; padding: 6px 8px; border: 1px solid rgba(45, 58, 67, .5); border-radius: 4px; background: rgba(18, 25, 30, .88); color: #d5dfe3; font: 8px var(--mono); letter-spacing: .06em; pointer-events: none; }
.stamp-square { width: 6px; height: 6px; background: var(--signal); }
.map-footer { display: flex; justify-content: space-between; gap: 12px; padding: 0 16px 12px; color: var(--faint); font-size: 9px; }
.map-footer > span:first-child { display: flex; align-items: center; gap: 7px; }
.footer-dot { width: 6px; height: 6px; background: var(--signal); box-shadow: none; }

.detail-panel { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 18px; }
.detail-main { min-width: 0; }
.detail-panel h2 { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.detail-note { max-width: 620px; margin: 5px 0 11px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.detail-facts { display: flex; flex-wrap: wrap; gap: 18px; }
.detail-facts > div { display: grid; gap: 4px; }
.detail-facts span { color: var(--faint); font-size: 8px; }
.detail-facts strong { color: #e0e8eb; font: 500 11px var(--mono); }
.detail-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: 7px; }

.page-footer { display: flex; justify-content: space-between; gap: 14px; padding: 18px 2px 0; color: var(--faint); font-size: 9px; line-height: 1.5; }
.toast { position: fixed; z-index: 2000; bottom: 22px; left: 50%; max-width: calc(100vw - 32px); transform: translate(-50%, 14px); opacity: 0; pointer-events: none; padding: 11px 16px; border: 1px solid rgba(80, 199, 149, .38); border-radius: 8px; background: #18352d; color: #d9f6e9; box-shadow: 0 8px 24px rgba(0, 0, 0, .28); font-size: 11px; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 1100px) {
  .app-shell { padding-right: 22px; padding-left: 22px; }
  .workspace { grid-template-columns: minmax(300px, 350px) minmax(0, 1fr); gap: 12px; }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-note { grid-column: 1 / -1; min-height: 58px; }
  .detail-panel { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 800px) {
  .app-shell { padding: 0 16px 18px; }
  .topbar { height: auto; min-height: 72px; }
  .brand-mark, .brand-mark svg { width: 34px; height: 34px; }
  .service-link { min-width: 0; padding: 8px 9px; font-size: 11px; }
  .service-kicker { font-size: 7px; }
  .intro { padding-top: 27px; }
  .workspace { grid-template-columns: 1fr; }
  .records-panel { min-height: 0; }
  .area-list { max-height: 360px; }
  .map-column { grid-template-rows: auto auto; }
  .map-panel { min-height: 470px; }
  .detail-panel { flex-direction: row; align-items: center; }
}
@media (max-width: 560px) {
  .app-shell { padding-right: 11px; padding-left: 11px; }
  .topbar { align-items: center; gap: 8px; }
  .brand { gap: 7px; }
  .brand-mark, .brand-mark svg { width: 29px; height: 29px; }
  .brand-name { font-size: 14px; }
  .brand-copy .eyebrow { font-size: 7px; }
  .top-actions { gap: 5px; }
  .service-link { padding: 7px; font-size: 10px; }
  .service-kicker { display: none; }
  .intro { align-items: flex-start; flex-direction: column; padding: 23px 2px 17px; }
  .intro h1 { font-size: 30px; }
  .intro p { max-width: 360px; font-size: 12px; }
  .desktop-break { display: none; }
  .source-pill { margin: 0; font-size: 8px; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 12px; }
  .metric-card { min-height: 82px; padding: 11px; }
  .metric-card strong { font-size: 22px; }
  .metric-note { grid-column: 1 / -1; min-height: 54px; padding: 10px 12px; font-size: 10px; }
  .panel-heading { min-height: 67px; padding: 12px 13px; }
  .filters { padding: 12px; }
  .import-block { padding-right: 12px; padding-left: 12px; }
  .import-actions { gap: 5px; }
  .button { padding: 0 9px; font-size: 9px; }
  .list-meta { padding-right: 12px; padding-left: 12px; }
  .record-card { padding-right: 4px; padding-left: 7px; }
  .map-column { grid-template-rows: auto auto; gap: 9px; }
  .map-panel { min-height: 400px; }
  .map-heading { padding: 12px; }
  .map-frame { min-height: 280px; margin: 8px; }
  #map { min-height: 280px; }
  .map-footer { padding: 0 10px 9px; font-size: 8px; }
  .detail-panel { flex-direction: column; align-items: stretch; padding: 13px; }
  .detail-facts { gap: 11px; }
  .detail-actions { width: 100%; }
  .detail-actions .button { flex: 1; }
  .page-footer { flex-direction: column; gap: 5px; padding-top: 13px; }
}
