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

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:      #060d18;
  --bg-panel:     #0a1525;
  --bg-panel2:    #0d1b2e;
  --bg-item:      #0f2040;
  --border:       #152b4a;
  --border-light: #1e3d66;
  --accent:       #0d6efd;
  --accent-dim:   #0a4a9e;
  --text-primary: #ddeaf8;
  --text-secondary: #8cb4d4;
  --text-muted:   #5a82a8;
  --mono:         'JetBrains Mono', monospace;
  --sans:         'Inter', 'Segoe UI', sans-serif;

  --green:   #1db954;
  --yellow:  #f59e0b;
  --red:     #e53935;
  --purple:  #7c3aed;
  --cyan:    #06b6d4;
}

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 13px;
  overflow: hidden;
}

/* ── HEADER ─────────────────────────────────────────────────────────────── */
header {
  height: 52px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0 16px;
  padding: 0 16px;
  flex-shrink: 0;
  overflow: visible;  /* allow nav dropdowns to render below the header */
  position: relative;
  z-index: 500;
}

.header-brand {
  display: flex; align-items: center; gap: 10px;
}
.app-icon { width: 34px; height: 34px; flex-shrink: 0; }
.logo {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 3px;
  color: var(--cyan);
  line-height: 1.1;
}
.logo span { color: var(--text-secondary); font-weight: 400; }
.company-tagline {
  font-size: 0.52rem; letter-spacing: .16em;
  color: var(--text-muted); margin-top: 1px;
  text-transform: uppercase;
}

.header-center {
  text-align: center;
}
.sys-label {
  font-size: 0.65rem;
  letter-spacing: 4px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.stat-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.stat-label {
  font-size: 0.58rem;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.stat-value {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 500;
}
.mono { font-family: var(--mono); }

.link-indicator {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 2px;
}
.link-indicator.online  { background: #0a2e1a; color: var(--green); border: 1px solid #1a5c2e; }
.link-indicator.offline { background: #2a0a0a; color: var(--red);   border: 1px solid #5c1a1a; }

/* ── LAYOUT ──────────────────────────────────────────────────────────────── */
body {
  display: flex;
  flex-direction: column;
}

.main-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── COLUMNA DERECHA (flex vertical) ─────────────────────────────────────── */
#right-column {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--border);
}

/* DIVISOR ARRASTRABLE */
#panel-divider {
  height: 5px;
  background: var(--border);
  cursor: ns-resize;
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s;
}
#panel-divider:hover,
#panel-divider.dragging { background: var(--accent); }

/* ── SECTOR 1 — MAPA ─────────────────────────────────────────────────────── */
#map-sector {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #b8d4e8;
  overflow: hidden;
}

#map-toolbar {
  height: 36px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  flex-shrink: 0;
}

.toolbar-label {
  font-size: 0.6rem;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-right: 4px;
  margin-left: 8px;
}
.toolbar-label:first-child { margin-left: 0; }

.toolbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 8px;
}

.area-select {
  background: var(--bg-base);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 3px 8px;
  border-radius: 2px;
  font-size: 0.72rem;
  font-family: var(--sans);
  font-weight: 500;
  outline: none;
  cursor: pointer;
  min-width: 210px;
  transition: border-color 0.15s;
}
.area-select:focus { border-color: var(--accent); }
.area-select option, .area-select optgroup {
  background: var(--bg-panel2);
  color: var(--text-primary);
}

.tb-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 3px 10px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 0.65rem;
  font-family: var(--sans);
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: all 0.15s;
}
.tb-btn:hover { border-color: var(--border-light); color: var(--text-primary); }
.tb-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}

/* Small select controls in the toolbar (trail window, vector mode/time) */
.tb-select {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 2px;
  font-size: 0.62rem;
  font-family: var(--sans);
  font-weight: 500;
  letter-spacing: 0.5px;
  padding: 2px 4px;
  height: 24px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.tb-select:hover  { border-color: var(--border-light); color: var(--text-primary); }
.tb-select:focus  { border-color: var(--accent); }
.tb-select option { background: var(--bg-panel2); color: var(--text-primary); }

#map { flex: 1; }

#map-coords {
  position: absolute;
  bottom: 8px;
  left: 10px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  background: rgba(6,13,24,0.8);
  padding: 3px 8px;
  border-radius: 2px;
  border: 1px solid var(--border);
  letter-spacing: 0.5px;
  pointer-events: none;
}

#depth-legend {
  position: absolute;
  bottom: 8px;
  right: 10px;
  background: rgba(6,13,24,0.88);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px 10px;
  font-size: 0.68rem;
  color: var(--text-primary);
  z-index: 100;
  pointer-events: none;
  min-width: 168px;
}
#depth-legend.hidden { display: none; }
.dl-title {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.dl-row {
  display: flex;
  align-items: center;
  margin-top: 3px;
  white-space: nowrap;
}
.dl-sw {
  display: inline-block;
  width: 16px;
  height: 10px;
  margin-right: 6px;
  border-radius: 2px;
}

/* ── SECTOR 2 — INFO ─────────────────────────────────────────────────────── */
#info-sector {
  background: var(--bg-panel2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-height: 120px;
}

/* ── SECTOR 3 — EVENTOS ──────────────────────────────────────────────────── */
#events-sector {
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 0 0 240px;
  min-height: 80px;
}

.sector-header {
  height: 36px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
  flex-shrink: 0;
}

.alert-badge {
  background: var(--red);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  font-family: var(--mono);
}
.alert-badge.hidden { display: none; }

#info-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
}

#events-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── NO SELECTION ────────────────────────────────────────────────────────── */
.no-selection {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.65rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 60px;
  padding: 0 8px;
}
.no-sel-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── INFO PANEL CONTENT ──────────────────────────────────────────────────── */
.obj-type-tag {
  font-size: 0.55rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 2px;
  margin-bottom: 4px;
  display: inline-block;
}
.tag-vessel { background: #0a1e3d; color: var(--cyan);  border: 1px solid #0e3060; }
.tag-aid    { background: #1a0e2d; color: #a78bfa; border: 1px solid #3d1a6e; }

.obj-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1px;
}
.obj-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-bottom: 8px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 5px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.field-label {
  font-size: 0.68rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}

.field-value {
  font-size: 0.92rem;
  color: var(--text-primary);
  font-family: var(--mono);
}

.coords-block {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 0.88rem;
  color: var(--cyan);
  line-height: 1.4;
  margin-bottom: 8px;
}
.coords-block .label {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 2px;
  font-family: var(--sans);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 2px;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.pill-ok     { background: #071f10; color: var(--green);  border: 1px solid #0e3d1e; }
.pill-warn   { background: #1f1200; color: var(--yellow); border: 1px solid #3d2500; }
.pill-danger { background: #1f0505; color: var(--red);    border: 1px solid #3d0a0a; }

.status-dot-small {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-ok     { background: var(--green); box-shadow: 0 0 4px var(--green); }
.dot-warn   { background: var(--yellow); }
.dot-danger { background: var(--red); box-shadow: 0 0 4px var(--red); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.disp-bar-wrap {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 2px;
  height: 5px;
  margin-top: 4px;
  overflow: hidden;
}
.disp-bar { height: 100%; border-radius: 2px; transition: width 0.6s ease; }

.aton-badge {
  background: #1a0a2e;
  border: 1px solid #4a1a8e;
  color: #c084fc;
  font-size: 0.62rem;
  letter-spacing: 2px;
  padding: 3px 8px;
  border-radius: 2px;
  font-weight: 600;
  display: inline-block;
  margin-bottom: 10px;
}

/* ── EVENTS ──────────────────────────────────────────────────────────────── */
.event-item {
  background: var(--bg-item);
  border-left: 3px solid var(--border-light);
  border-radius: 2px;
  padding: 8px 10px;
  font-size: 0.75rem;
  animation: slideIn 0.2s ease;
}
.event-item.ev-red    { border-color: var(--red);    background: #130505; }
.event-item.ev-yellow { border-color: var(--yellow); background: #13100a; }
.event-item.ev-purple { border-color: var(--purple); background: #0e0a18; }
.event-item.ev-blue   { border-color: var(--accent); background: #050d1f; }

.ev-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.ev-type {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.ev-red    .ev-type { color: var(--red); }
.ev-yellow .ev-type { color: var(--yellow); }
.ev-purple .ev-type { color: #c084fc; }
.ev-blue   .ev-type { color: var(--cyan); }

.ev-time {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--text-muted);
}

.ev-detail {
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.4;
}

.ev-mmsi {
  font-family: var(--mono);
  color: var(--text-primary);
  font-size: 0.75rem;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(6px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── TOOLTIP ─────────────────────────────────────────────────────────────── */
.tooltip {
  position: fixed;
  background: rgba(6,13,24,0.97);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  padding: 10px 12px;
  font-size: 0.75rem;
  color: var(--text-primary);
  pointer-events: none;
  z-index: 9999;
  max-width: 240px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}
.tooltip.hidden { display: none; }

.tt-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.tt-type {
  font-size: 0.58rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.tt-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 3px;
}
.tt-key { color: var(--text-muted); }
.tt-val { font-family: var(--mono); color: var(--text-primary); }

/* ── EDIT FORM ───────────────────────────────────────────────────────────── */
.edit-btn {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 0.65rem;
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: all 0.15s;
  margin-top: 14px;
  width: 100%;
}
.edit-btn:hover { border-color: var(--accent); color: var(--accent); }

.edit-form {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.edit-form-title {
  font-size: 0.6rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-label {
  font-size: 0.58rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-input {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 8px;
  border-radius: 2px;
  font-size: 0.8rem;
  font-family: var(--mono);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.form-input:focus { border-color: var(--accent); }

.form-input-select {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 8px;
  border-radius: 2px;
  font-size: 0.8rem;
  font-family: var(--sans);
  outline: none;
  width: 100%;
}

.form-textarea {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 8px;
  border-radius: 2px;
  font-size: 0.78rem;
  font-family: var(--sans);
  outline: none;
  resize: none;
  width: 100%;
  height: 56px;
  transition: border-color 0.15s;
}
.form-textarea:focus { border-color: var(--accent); }

.form-actions {
  display: flex;
  gap: 8px;
}

.btn-save {
  flex: 1;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: #fff;
  padding: 6px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: background 0.15s;
}
.btn-save:hover { background: var(--accent); }

.btn-cancel {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.btn-cancel:hover { border-color: var(--red); color: var(--red); }

.form-note {
  font-size: 0.65rem;
  color: var(--yellow);
  padding: 5px 8px;
  background: #13100a;
  border: 1px solid #3d2500;
  border-radius: 2px;
}

/* ── MODALES ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 8, 16, 0.82);
  backdrop-filter: blur(3px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-panel2);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  width: 440px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
}
.modal.hidden { display: none; }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-primary);
}

.modal-subtitle-inline {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 3px;
  font-family: var(--mono);
  letter-spacing: 0;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.15s;
  flex-shrink: 0;
}
.modal-close:hover { color: var(--red); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-error {
  margin-top: 12px;
  padding: 8px 12px;
  background: #1f0505;
  border: 1px solid var(--red);
  border-radius: 2px;
  color: #ef9a9a;
  font-size: 0.75rem;
}
.modal-error.hidden { display: none; }

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.btn-modal-primary {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: #fff;
  padding: 7px 20px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: background 0.15s;
  font-family: var(--sans);
}
.btn-modal-primary:hover { background: var(--accent); }
.btn-modal-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-modal-secondary {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 7px 16px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-family: var(--sans);
  transition: all 0.15s;
}
.btn-modal-secondary:hover { border-color: var(--red); color: var(--red); }

.save-status {
  font-size: 0.7rem;
  margin-left: auto;
  font-family: var(--mono);
}
.save-status.ok   { color: var(--green); }
.save-status.err  { color: var(--red); }

/* Edit form dentro del modal */
#modal-edit-body .form-field { margin-bottom: 12px; }
#modal-edit-body .field-row-modal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-section-label {
  font-size: 0.58rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 16px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ── Chart source cards ─────────────────────────────────────────────────── */
.chart-source-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chart-source-card:hover {
  border-color: var(--accent);
  background: var(--hover-bg, #1a2a3a);
}
.chart-card-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1px;
}
.chart-card-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}
.chart-card-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 4px;
  flex: 1;
}
.chart-card-btn {
  margin-top: 10px;
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
  padding: 4px 8px;
  text-align: center;
  font-weight: 600;
}
.chart-source-card:hover .chart-card-btn {
  background: var(--accent-dim);
  color: #fff;
}

/* ── Chart catalog table ────────────────────────────────────────────────── */
.chart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}
.chart-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 1px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
}
.chart-table td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-secondary);
}
.chart-row-btn {
  font-size: 0.62rem;
  letter-spacing: 1.5px;
  padding: 3px 8px;
  border-radius: 3px;
  border: 1px solid var(--accent-dim);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}
.chart-row-btn:hover  { background: var(--accent-dim); color: #fff; }
.chart-row-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.chart-row-btn.danger { border-color: var(--red); color: var(--red); }
.chart-row-btn.danger:hover { background: var(--red); color: #fff; }

/* Channel-specific buttons in the REPORT modal */
.chart-row-btn.ch-email    { border-color: #4a90e2; color: #4a90e2; }
.chart-row-btn.ch-email:hover { background: #4a90e2; color: #fff; }
.chart-row-btn.ch-whatsapp { border-color: #25d366; color: #25d366; }
.chart-row-btn.ch-whatsapp:hover { background: #25d366; color: #fff; }
.chart-row-btn.ch-sms      { border-color: #f5a623; color: #f5a623; }
.chart-row-btn.ch-sms:hover { background: #f5a623; color: #fff; }
.chart-row-btn.ch-all      { border-color: #c084fc; color: #c084fc; font-weight: 600; }
.chart-row-btn.ch-all:hover { background: #c084fc; color: #fff; }

.ctab-panel { display: block; }
.ctab-panel.hidden { display: none; }

/* ── Chart nearby panel ─────────────────────────────────────────────────── */
.chart-nearby-panel.hidden { display: none; }   /* MUST exist — JS toggles this class */
.chart-nearby-panel {
  position: absolute;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-bg);
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  min-width: 320px;
  max-width: 520px;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  font-size: 0.72rem;
}
.cnp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}
.cnp-title {
  font-size: 0.6rem;
  letter-spacing: 2px;
  color: var(--accent);
  font-weight: 700;
}
.cnp-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
}
.cnp-close:hover { color: var(--text-primary); }
#cnp-body { padding: 8px 12px 10px; }
.cnp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.cnp-cell { font-family: monospace; color: var(--accent); min-width: 90px; }
.cnp-name { color: var(--text-secondary); flex: 1; }
.cnp-scale { color: var(--text-muted); min-width: 60px; text-align: right; }
.cnp-btn {
  font-size: 0.58rem;
  letter-spacing: 1px;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--accent-dim);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}
.cnp-btn:hover { background: var(--accent-dim); color: #fff; }
.cnp-btn.installed { border-color: #4caf50; color: #4caf50; cursor: default; }
.cnp-noaa-note { color: var(--text-muted); font-size: 0.65rem; margin-top:6px; }
.cnp-ukho-link {
  display: inline-block;
  margin-top: 6px;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.65rem;
}

/* Badge de sesión en header */
.session-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 2px;
  transition: all 0.15s;
}
.session-badge:hover { border-color: var(--border-light); color: var(--text-primary); }
.session-role {
  font-size: 0.55rem;
  letter-spacing: 1px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 2px;
}
.role-superadmin { background: #1a0a2e; color: #c084fc; border: 1px solid #4a1a8e; }
.role-admin      { background: #0a1e3d; color: var(--cyan); border: 1px solid #0e3060; }
.role-user       { background: var(--bg-item); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Modo nocturno (night vision — preserva visión) ─────────────────────── */
html.night {
  --bg-base:      #020304;
  --bg-panel:     #060608;
  --bg-panel2:    #080a0c;
  --bg-item:      #0d0f10;
  --border:       #1a0a0a;
  --border-light: #2e0e0e;
  --accent:       #8b1a1a;
  --accent-dim:   #5c0f0f;
  --cyan:         #cc2200;
  --text-primary: #cc4422;
  --text-secondary:#7a2a1a;
  --text-muted:   #3d1410;
  --green:        #882200;
  --yellow:       #7a3300;
}
html.night .ol-zoom button {
  background: #0a0202 !important;
  color: #cc2200 !important;
  border-color: #2e0e0e !important;
}

/* ── OpenLayers overrides ────────────────────────────────────────────────── */
.ol-zoom { top: 48px !important; right: 10px !important; left: auto !important; }
.ol-zoom button {
  background: var(--bg-panel2) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-secondary) !important;
  border-radius: 2px !important;
  margin: 1px 0 !important;
}
.ol-zoom button:hover { background: var(--bg-item) !important; color: #fff !important; }
.ol-attribution { display: none !important; }

/* ── Scrollbars ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

/* ── App container — fills remaining viewport after body flex layout ──────── */
#app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
#app.hidden { display: none; }

/* ── Login Screen ────────────────────────────────────────────────────────── */
#login-screen {
  position: fixed; inset: 0;
  background: var(--bg-base);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
#login-screen.hidden { display: none; }
.ls-box {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 40px 36px 32px;
  width: 320px;
  display: flex; flex-direction: column; align-items: center;
}
.ls-logo {
  font-size: 1.6rem; font-weight: 700; letter-spacing: .12em;
  color: var(--text-primary);
}
.ls-logo span { color: var(--cyan); }
.ls-subtitle {
  font-size: 0.62rem; letter-spacing: .18em;
  color: var(--text-muted); margin-top: 4px;
}
.ls-version {
  font-size: 0.58rem; color: var(--border-light);
  margin-top: 2px; letter-spacing: .1em;
}
.ls-fields { width: 100%; margin-top: 28px; }
.ls-footer {
  margin-top: 24px; font-size: 0.58rem;
  color: var(--border-light); letter-spacing: .08em;
}

/* ── Nav Menu ────────────────────────────────────────────────────────────── */
#main-nav { display: flex; gap: 2px; }
.nav-item {
  position: relative;
  padding: 0 14px; height: 100%;
  display: flex; align-items: center;
  font-size: 0.7rem; font-weight: 600; letter-spacing: .1em;
  color: var(--text-secondary);
  cursor: pointer; user-select: none;
  border-radius: 2px;
  transition: background .15s, color .15s;
}
.nav-item:hover, .nav-item.open {
  background: var(--bg-item); color: var(--text-primary);
}
.nav-dropdown {
  display: none;
  position: absolute; top: 100%; left: 0;
  min-width: 200px;
  background: var(--bg-panel2);
  border: 1px solid var(--border-light);
  border-radius: 0 0 3px 3px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  z-index: 1000;
}
.nav-item.open .nav-dropdown { display: block; }
.dd-item {
  padding: 8px 14px;
  font-size: 0.7rem; letter-spacing: .06em;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .1s, color .1s;
}
.dd-item:hover { background: var(--bg-item); color: var(--cyan); }
.dd-sep { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; }

/* ── Port Search ─────────────────────────────────────────────────────────── */
.port-search-wrap { position: relative; }
.port-search-input {
  background: var(--bg-item);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-primary);
  font-family: inherit; font-size: 0.72rem;
  padding: 3px 8px; width: 200px;
  outline: none;
  transition: border-color .15s;
}
.port-search-input:focus { border-color: var(--cyan); }
.port-suggestions {
  position: absolute; top: calc(100% + 3px); left: 0;
  width: 280px;
  background: var(--bg-panel2);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  z-index: 2000; max-height: 260px; overflow-y: auto;
}
.port-suggestions.hidden { display: none; }
.port-item {
  padding: 7px 10px;
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.port-item:last-child { border-bottom: none; }
.port-item:hover { background: var(--bg-item); }
.port-name { font-size: 0.72rem; color: var(--text-primary); }
.port-country { font-size: 0.62rem; color: var(--text-muted); white-space: nowrap; }

/* ── Track warnings ─────────────────────────────────────────────────────── */
.track-warn {
  background: rgba(245,158,11,.1);
  border: 1px solid rgba(245,158,11,.4);
  border-radius: 2px;
  padding: 5px 8px;
  font-size: 0.7rem;
  color: #fcd34d;
  margin-bottom: 4px;
}
/* ── Evento titilante (pendiente de ACK) ─────────────────────────────────── */
@keyframes ev-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}
.ev-blinking { animation: ev-blink 1.2s ease-in-out infinite; }

/* ── ACK button ──────────────────────────────────────────────────────────── */
.ev-ack-btn {
  margin-top: 6px;
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  font-size: 0.62rem; font-family: var(--mono);
  letter-spacing: .08em;
  padding: 3px 10px; border-radius: 2px;
  cursor: pointer; opacity: .7;
  transition: opacity .15s;
}
.ev-ack-btn:hover { opacity: 1; }
.ev-ack-btn.ev-ack-done {
  opacity: .4; font-size: 0.58rem; cursor: default;
  border-style: dashed;
}

.ev-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
/* Same look as .ev-ack-btn — inherits color from the alert card */
.ev-report-btn {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  font-size: 0.62rem; font-family: var(--mono);
  letter-spacing: .08em;
  padding: 3px 10px; border-radius: 2px;
  cursor: pointer; opacity: .7;
  transition: opacity .15s;
}
.ev-report-btn:hover { opacity: 1; }

.ev-reported {
  margin-top: 4px;
  font-size: 0.6rem;
  color: #4caf50;
  font-family: var(--mono);
  letter-spacing: .04em;
}
.ev-reported.hidden { display: none; }
.event-item.ev-reported-state .ev-report-btn {
  opacity: .35;
  border-style: dashed;
}

.track-warn.track-alarm {
  background: rgba(229,57,53,.15);
  border-color: rgba(229,57,53,.5);
  color: #ff6b6b;
}

/* ── Wide modal (users) ──────────────────────────────────────────────────── */
.modal-wide { width: min(720px, 94vw); }

/* ── Status bar ──────────────────────────────────────────────────────────── */
#status-bar {
  height: 26px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 20px;
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: .04em;
}
.sb-group { display: flex; align-items: center; gap: 5px; }
.sb-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.sb-dot.green  { background: var(--green);  box-shadow: 0 0 4px var(--green); }
.sb-dot.yellow { background: var(--yellow); box-shadow: 0 0 4px var(--yellow); }
.sb-dot.grey   { background: var(--text-muted); }
.sb-label { color: var(--text-secondary); }
.sb-sep { flex: 1; }
.sb-user { color: var(--text-secondary); }

/* ── Settings tabs ───────────────────────────────────────────────────────── */
.settings-tabs {
  display: flex; gap: 0; margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.stab {
  background: transparent; border: none;
  padding: 7px 16px;
  font-size: 0.68rem; font-family: var(--sans);
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.stab:hover { color: var(--text-secondary); }
.stab.active { color: var(--cyan); border-bottom-color: var(--cyan); }
.stab-panel.hidden { display: none; }

/* ── Users table ─────────────────────────────────────────────────────────── */
.users-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.72rem;
}
.users-table thead th {
  text-align: left; padding: 6px 10px;
  font-size: 0.62rem; letter-spacing: .1em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
}
.users-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.users-table tbody tr:hover { background: var(--bg-item); }
.users-table td { padding: 7px 10px; color: var(--text-secondary); }
.users-table td:first-child { color: var(--text-primary); }

/* ── Equipment scanner ───────────────────────────────────────────────────── */
.eq-card {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.eq-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.eq-type {
  font-size: 0.78rem; font-family: var(--mono);
  font-weight: 600; letter-spacing: .08em;
}
.eq-port {
  font-size: 0.72rem; font-family: var(--mono);
  color: var(--accent); background: rgba(13,110,253,.12);
  padding: 1px 8px; border-radius: 3px;
}
.eq-desc {
  font-size: 0.72rem; color: var(--text-secondary); margin-bottom: 2px;
}
.eq-hwid {
  font-size: 0.62rem; color: var(--text-muted); margin-bottom: 6px;
}
.eq-sentences {
  background: #020810; border-radius: 4px;
  padding: 6px 8px; max-height: 110px; overflow-y: auto;
}
.eq-sentence {
  font-size: 0.62rem; font-family: var(--mono);
  color: var(--green); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; line-height: 1.7;
}

/* ── ATON telemetry panel ────────────────────────────────────────────────── */
.aton-badge {
  display: inline-block;
  background: #1a3550; color: var(--cyan);
  font-size: 0.58rem; font-family: var(--mono);
  letter-spacing: .12em; padding: 2px 8px;
  border-radius: 3px; margin-bottom: 8px;
}
.aton-virtual {
  font-size: 0.62rem; color: var(--yellow);
  letter-spacing: .1em; margin-top: 4px;
}
.aton-telemetry {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--bg-base); border-radius: 6px;
  padding: 8px 10px; margin-top: 6px;
}
.aton-telem-title {
  font-size: 0.62rem; font-family: var(--mono);
  letter-spacing: .1em; color: var(--text-muted);
  margin-bottom: 6px; display: flex; justify-content: space-between;
}
.aton-ts { color: var(--text-muted); font-size: 0.6rem; }
.aton-check {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; padding: 3px 0;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.aton-check:last-child { border-bottom: none; }
.aton-check:hover { background: rgba(13,110,253,0.04); }
.aton-check input[type=checkbox] {
  accent-color: var(--accent);
  width: 12px; height: 12px; flex-shrink: 0;
}
.aton-key {
  font-size: 0.62rem; font-family: var(--mono);
  letter-spacing: .08em; color: var(--text-muted);
  flex: 1;
}
.aton-val {
  font-size: 0.72rem; font-family: var(--mono);
  color: var(--text-primary); text-align: right;
}
.aton-ok   { color: var(--green); }
.aton-warn { color: var(--yellow); font-weight: 600; }

/* ── Battery history chart ───────────────────────────────────────────────── */
.batt-chart-hdr {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 6px;
}
.batt-range-btns { display: flex; gap: 4px; }
.batt-rb {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-secondary); border-radius: 2px;
  font-size: 0.6rem; font-family: var(--mono);
  padding: 2px 6px; cursor: pointer; transition: all .15s;
}
.batt-rb:hover  { border-color: var(--border-light); color: var(--text-primary); }
.batt-rb.active { background: var(--accent-dim); border-color: var(--accent); color: #fff; }
#batt-chart-wrap { margin-bottom: 8px; }
#batt-chart-svg  { width: 100%; }
.batt-stats {
  display: flex; flex-wrap: wrap; gap: 6px 12px;
  font-size: 0.68rem; color: var(--text-muted);
  margin-top: 4px; font-family: var(--mono);
}
.batt-stat      { color: var(--text-secondary); }
.batt-stat-eta  { color: var(--text-secondary); }
