@font-face { font-family: "Inter"; font-weight: 100 900; font-display: swap; src: url(../fonts/inter-latin-wght-normal.woff2) format("woff2"); }
:root {
  --font: "Inter", system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --bg: #04050b;
  --panel: #0c0f1e;
  --panel-2: #11142a;
  --line: rgba(232, 226, 214, .14);
  --text: #f1ece2;
  --muted: #9d9bb0;
  --accent: #d8b77a;
  --accent-2: #b9adff;
  --ok: #7fd6a4;
  --warn: #f0c27a;
  --bad: #f08a8a;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
}
a { color: var(--accent-2); }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 15px; margin-bottom: 10px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 6px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; border-bottom: 1px solid var(--line); background: #0d1428;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand h1 { font-size: 17px; }
.brand p { margin: 0; color: var(--muted); font-size: 12px; }

.layout { display: grid; grid-template-columns: 360px 1fr; min-height: calc(100vh - 57px); }
.sidebar { padding: 14px; border-right: 1px solid var(--line); overflow-y: auto; max-height: calc(100vh - 57px); }
.main { position: relative; display: flex; flex-direction: column; min-width: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.hidden { display: none !important; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
input, select, textarea {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 7px 9px; font: inherit; min-width: 0; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); outline-offset: -1px; }
textarea { font-family: ui-monospace, Consolas, monospace; font-size: 11px; margin: 6px 0; }
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.row select { flex: 1; }
.narrow { width: 90px; flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr .8fr; gap: 8px; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 12px; }
.status { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.bad { color: var(--bad); }
details summary { cursor: pointer; color: var(--muted); font-size: 12px; }

.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.checks.single { grid-template-columns: 1fr; margin-bottom: 12px; }
.checks label { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.checks input { width: auto; }
.results-head label { flex-direction: row; align-items: center; gap: 6px; }
.results-head input { width: auto; }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 7px; padding: 7px 12px; font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent-2); }
.btn.primary { background: var(--accent); color: #1b1203; border-color: var(--accent); font-weight: 600; width: 100%; padding: 10px; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: .5; cursor: wait; }
.btn.small { padding: 4px 10px; font-size: 12px; }

.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.tab { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 9px 6px; cursor: pointer; font: inherit; font-weight: 600; }
.tab.active { background: var(--panel); color: var(--text); border-color: var(--accent); }

.footnote { color: var(--muted); font-size: 11px; }

.map { height: 46vh; min-height: 300px; border-bottom: 1px solid var(--line); }
.legend {
  position: absolute; top: 10px; right: 10px; z-index: 500; background: rgba(13,20,40,.9);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px;
}
.legend div { display: flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 10px; display: inline-block; border-radius: 2px; }

.progress {
  position: absolute; top: calc(46vh - 40px); left: 50%; transform: translateX(-50%); z-index: 600;
  width: min(360px, 80%); background: rgba(13,20,40,.95); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px; font-size: 12px; text-align: center;
}
.progress .bar { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent) var(--p, 0%), var(--line) var(--p, 0%)); margin-bottom: 4px; }

.results-wrap { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(320px, 1.1fr); flex: 1; min-height: 0; }
.results { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.results-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px 4px; }
.results-head h2 { margin: 0; }
.list { overflow-y: auto; padding: 8px 10px 14px; max-height: calc(54vh - 100px); min-height: 200px; }
.detail { padding: 14px; overflow-y: auto; max-height: calc(54vh - 60px); min-height: 200px; }
.empty { color: var(--muted); padding: 20px 6px; }

.ev {
  border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 9px 11px;
  margin-bottom: 7px; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
}
.ev:hover { border-color: var(--accent-2); }
.ev.sel { border-color: var(--accent); background: #1c2541; }
.ev .t { font-weight: 600; }
.ev .when { color: var(--text); font-variant-numeric: tabular-nums; }
.ev .sub { color: var(--muted); font-size: 12px; grid-column: 1 / -1; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 20px; align-self: start; text-align: center; }
.b-transit { background: rgba(61,220,151,.15); color: var(--ok); }
.b-near { background: rgba(255,209,102,.13); color: var(--warn); }
.b-occ { background: rgba(79,195,247,.15); color: var(--accent-2); }
.b-glob { background: rgba(141,153,181,.15); color: var(--muted); }
.b-inv { background: rgba(255,107,107,.13); color: var(--bad); }

.detail h2 { font-size: 17px; margin-bottom: 2px; }
.detail .lead { color: var(--muted); margin-bottom: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; margin: 10px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.callout { border-left: 3px solid var(--accent); background: var(--panel); padding: 8px 10px; border-radius: 0 8px 8px 0; margin: 10px 0; font-size: 13px; }
.callout.ok { border-color: var(--ok); }
.callout.warn { border-color: var(--warn); }
.sky { width: 100%; max-width: 420px; display: block; margin: 10px auto; background: #050816; border-radius: 10px; border: 1px solid var(--line); }
.sky text { fill: var(--muted); font-size: 11px; font-family: var(--font); }

.leaflet-container { background: #0a0f1d; }
.dark-tiles { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.6); }
.leaflet-tooltip.tt { background: rgba(13,20,40,.9); color: var(--text); border: 1px solid var(--line); font-size: 11px; padding: 2px 5px; }
.leaflet-tooltip.tt::before { display: none; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .results-wrap { grid-template-columns: 1fr; }
  .results { border-right: 0; border-bottom: 1px solid var(--line); }
  .list, .detail { max-height: none; }
  .topbar { padding: 10px 16px; }
  .sidebar { padding: 12px 16px; }
}

.tab { font-size: 12.5px; padding: 9px 2px; }
.quick { flex-wrap: wrap; gap: 6px; }
.satlist { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.satrow { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 5px 7px; border-radius: 7px; background: var(--panel-2); }
.satrow label { flex-direction: row; align-items: center; gap: 7px; color: var(--text); font-size: 13px; }
.satrow input { width: auto; }
.satrow .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.satrow small { color: var(--muted); font-size: 11px; display: block; }
.satrow small.warn { color: var(--warn); }
.satrow small.bad { color: var(--bad); }
.satrow .x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; }
.satchip { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 10px; border: 1px solid currentColor; margin-right: 4px; }

table.passes { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
table.passes th { position: sticky; top: 0; background: var(--bg); color: var(--muted); font-weight: 600; text-align: left; padding: 6px 5px; border-bottom: 1px solid var(--line); font-size: 11px; }
table.passes td { padding: 6px 5px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.passes tr.p { cursor: pointer; }
table.passes tr.p:hover td { background: var(--panel); }
table.passes tr.sel td { background: #1c2541; }
table.passes tr.day td { color: var(--muted); font-weight: 600; background: transparent; cursor: default; padding-top: 12px; }
.t-vis { color: var(--ok); } .t-day { color: var(--warn); } .t-sh { color: var(--muted); }

.live-grid { display: grid; gap: 8px; }
.livecard { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.livecard h4 { margin: 0 0 6px; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.livecard .kv { margin: 0; font-size: 12.5px; }
.video { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.satmarker { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; border: 2px solid #fff; box-shadow: 0 0 10px rgba(0,0,0,.6); }
.polar { width: 100%; max-width: 360px; display: block; margin: 8px auto; }
.polar text { fill: var(--muted); font-size: 11px; font-family: var(--font); }

.results-wrap.wide { grid-template-columns: minmax(420px, 1.5fr) minmax(300px, 1fr); }
.list { overflow-x: auto; }
table.passes td, table.passes th { padding: 5px 4px; }
@media (max-width: 1000px) { .results-wrap.wide { grid-template-columns: 1fr; } }

.satthumb { width: auto; vertical-align: middle; object-fit: contain; }
.satrow label .satthumb { width: 34px; height: 22px; }
.satimg { display: block; pointer-events: auto; }
.detail h2 .satthumb { margin-right: 4px; }

/* ---- móvil / app ---- */
.topbar { padding-top: max(10px, env(safe-area-inset-top)); }
@media (max-width: 700px) {
  body { font-size: 15px; }
  .brand p { display: none; }
  .tabs { position: sticky; top: 0; z-index: 900; background: var(--bg); padding: 6px 0; margin: 0 0 10px; }
  .tab { padding: 11px 2px; font-size: 12px; }
  .btn { padding: 10px 14px; }
  input, select { padding: 10px; font-size: 16px; }
  .map { height: 52vh; }
  .progress { top: 40vh; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .results-head { flex-wrap: wrap; gap: 6px; }
}

/* ---- en vivo: halo pulsante, seguimiento ---- */
.sat-pulse { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--c) 55%, transparent) 0%, transparent 70%); border: 1.5px solid var(--c); animation: satPulse 2.2s ease-out infinite; }
@keyframes satPulse { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(2.4); opacity: 0; } }
.satimg { position: relative; cursor: pointer; }
.follow-bar { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); z-index: 1000; display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 110px); padding: 6px 6px 6px 10px; border-radius: 14px; background: rgba(3,7,18,.86); border: 1px solid var(--c, #d8b77a);
  box-shadow: 0 4px 18px rgba(0,0,0,.5), 0 0 12px color-mix(in srgb, var(--c, #d8b77a) 40%, transparent); color: #e8ecf6; font-size: 12px; backdrop-filter: blur(8px); }
.follow-bar.hidden { display: none; }
.follow-bar img { width: 30px; height: auto; flex: none; }
.follow-bar b { display: block; font-size: 12.5px; }
.follow-bar small { display: block; color: #aab3c8; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.follow-bar .fb-x { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.06); color: #fff; cursor: pointer; }
.livecard[data-norad] { cursor: pointer; transition: border-color .2s; }
.livecard.following { border-color: var(--cyan, #d8b77a); box-shadow: 0 0 0 1px var(--cyan, #d8b77a) inset; }
