:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel2: #273449;
  --txt: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent2: #0ea5e9;
  --ok: #22c55e;
  --warn: #f59e0b;
  --border: #334155;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--txt);
  height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  background: linear-gradient(90deg, #0c4a6e, #075985);
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 1.15rem; font-weight: 700; }
.brand span { font-weight: 400; color: #bae6fd; font-size: .85rem; }

.badge { padding: 4px 10px; border-radius: 20px; font-size: .8rem; font-weight: 600; }
.badge-warn { background: var(--warn); color: #1a1a1a; }
.badge-ok { background: var(--ok); color: #06210f; }

.layout { display: flex; height: calc(100vh - 53px); }

.sidebar {
  width: 300px; flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px;
  transition: width .2s, padding .2s;
}
/* Panel colapsado: el plano ocupa casi toda la pantalla */
.layout.colapsado .sidebar {
  width: 0; padding: 0; overflow: hidden; border: none;
}

.toggle {
  width: auto; padding: 5px 10px; margin-left: 10px;
  background: rgba(255,255,255,.15); color: #fff; font-size: .8rem;
}
.toggle:hover { background: rgba(255,255,255,.28); }

.card {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}
.card h3 { margin: 0 0 10px; font-size: .85rem; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); }
.card.demo { border-color: #7c3aed44; }

select, input[type=text], input:not([type]), input[placeholder] {
  width: 100%; padding: 8px 10px; margin-bottom: 8px;
  background: var(--bg); color: var(--txt);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: .9rem;
}
input[type=file] { padding: 6px; }

.row { display: flex; gap: 6px; }
.row input { flex: 1; }
.row button { width: 40px; flex-shrink: 0; }

button {
  background: var(--accent2); color: #042f3d; border: none;
  padding: 8px 12px; border-radius: 8px; cursor: pointer;
  font-weight: 600; font-size: .9rem;
}
button:hover { background: var(--accent); }
button.full { width: 100%; margin-bottom: 6px; }
button.secondary { background: var(--panel); color: var(--txt); border: 1px solid var(--border); }
button.secondary:hover { background: var(--border); }

.muted { color: var(--muted); font-size: .8rem; display: block; margin-top: 4px; }
.slider { display: block; font-size: .8rem; color: var(--muted); margin-top: 8px; }
.slider input { width: 100%; }
.chk { display: flex; align-items: center; gap: 8px; font-size: .85rem; margin-top: 8px; cursor: pointer; }
.chk input { width: auto; margin: 0; }

.mapwrap { flex: 1; position: relative; }
#map { width: 100%; height: 100%; background: #0b1220; cursor: crosshair; }

.leyenda {
  position: absolute; bottom: 18px; right: 18px; z-index: 1000;
  background: rgba(15,23,42,.92); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; font-size: .78rem;
}
.leyenda .grad {
  height: 12px; width: 180px; border-radius: 6px; margin: 6px 0 2px;
  background: linear-gradient(90deg, #16a34a, #84cc16, #facc15, #f97316, #dc2626);
}
.grad-labels { display: flex; justify-content: space-between; color: var(--muted); }
#contPuntos { margin-top: 6px; }

/* puntos de medición */
.medicion-dot {
  border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 0 4px rgba(0,0,0,.6);
}

/* ===== Modal satélite ===== */
.modal {
  position: fixed; inset: 0; z-index: 5000;
  background: rgba(2,6,23,.8);
  display: flex; align-items: center; justify-content: center;
}
.modal.oculto { display: none; }
.modal-box {
  width: 86vw; height: 84vh; max-width: 1200px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--panel2); border-bottom: 1px solid var(--border);
}
.modal-head button { width: auto; padding: 4px 10px; }
.modal-tools {
  display: flex; gap: 8px; padding: 10px 16px; flex-wrap: wrap; align-items: center;
  border-bottom: 1px solid var(--border);
}
.modal-tools input { margin: 0; flex: 1; min-width: 180px; }
.modal-tools button { width: auto; white-space: nowrap; }
#satMap { flex: 1; }
.modal-foot {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 16px; background: var(--panel2); border-top: 1px solid var(--border);
}
/* mira central que marca el centro de la captura */
#satMap { position: relative; }
.mira {
  position: absolute; top: 50%; left: 50%; z-index: 1000;
  width: 26px; height: 26px; margin: -13px 0 0 -13px; pointer-events: none;
  border: 2px solid #38bdf8; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0,0,0,.4) inset;
}
.mira::before, .mira::after {
  content: ''; position: absolute; background: #38bdf8;
}
.mira::before { left: 11px; top: -8px; width: 2px; height: 8px; }
.mira::after  { top: 11px; left: -8px; height: 2px; width: 8px; }

/* ===== Editor (rotar + recortar) ===== */
.edwrap {
  flex: 1; position: relative; overflow: hidden;
  background: #0b1220; display: flex; align-items: center; justify-content: center;
}
#edCanvas { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.marco {
  position: absolute; border: 2px solid #38bdf8;
  box-shadow: 0 0 0 9999px rgba(2,6,23,.55); cursor: move; z-index: 5;
}
.marco .handle {
  position: absolute; right: -8px; bottom: -8px; width: 16px; height: 16px;
  background: #38bdf8; border: 2px solid #fff; border-radius: 3px; cursor: nwse-resize;
}
