:root {
  --bg: #0a0d14;
  --surface: #111520;
  --surface2: #161b2e;
  --surface3: #1c2235;
  --border: #1e2640;
  --drom: #00e5ff;
  --comp: #ff4b6e;
  --gold: #f5c842;
  --text: #e8ecf5;
  --muted: #6b7694;
  --sidebar: 300px;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Syne', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1000;
  flex-shrink: 0;
}

.logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .1em;
  color: var(--drom);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  margin-right: auto;
}

.logo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--drom);
  box-shadow: 0 0 8px var(--drom);
  flex-shrink: 0;
}

.kpis {
  display: flex;
  height: 100%;
  align-items: stretch;
  overflow-x: auto;
}

.kpis::-webkit-scrollbar {
  display: none;
}

.kpi {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 13px;
  border-left: 1px solid var(--border);
  min-width: 85px;
  flex-shrink: 0;
}

.kpi-label {
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #ffffff;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.kpi-value {
  font-size: 16px;
  font-weight: 700;
  margin-top: 1px;
  white-space: nowrap;
}

.kpi-value.drom {
  color: var(--drom);
}

.kpi-value.comp {
  color: var(--comp);
}

.kpi-value.gold {
  color: var(--gold);
}

.menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}

.main {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.sidebar {
  width: var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 500;
  flex-shrink: 0;
  overflow: hidden;
  transition: transform .25s ease;
}

.right-sidebar {
  border-right: none;
  border-left: 1px solid var(--border);
  width: 260px;
  background: var(--bg);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 3px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.s-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.s-title {
  font-size: 8px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #c1c1c1;
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.s-title::after {
  content: '▼';
  transition: transform .2s;
  font-size: 8px;
  margin-left: 8px;
}

.collapsed .s-title::after {
  transform: rotate(-90deg);
}

.collapsed .sec-content {
  display: none !important;
}

.compare-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.compare-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.compare-label {
  font-size: 11px;
  color: #fffffff1;
  flex: 1;
}

.compare-val {
  font-size: 12px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.bar-bg {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 7px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width .7s ease;
}

.share-row {
  display: flex;
  justify-content: space-between;
}

.chip {
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  padding: 2px 7px;
  border-radius: 20px;
}

.chip.drom {
  background: rgba(0, 229, 255, .1);
  color: var(--drom);
}

.chip.comp {
  background: rgba(255, 75, 110, .1);
  color: var(--comp);
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .12s;
  margin-bottom: 2px;
  user-select: none;
}

.layer-row:hover {
  background: var(--surface2);
}

.l-icon {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.l-icon.drom {
  background: var(--drom);
}

.l-icon.comp {
  background: var(--comp);
}

.l-icon.heat {
  background: linear-gradient(90deg, #00e5ff, #f5c842, #ff4b6e);
  border-radius: 2px;
  height: 5px;
  width: 16px;
}

.l-name {
  font-size: 12px;
  font-weight: 600;
  flex: 1;
}

.l-count {
  font-size: 9px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
}

.sw {
  width: 28px;
  height: 16px;
  border-radius: 8px;
  background: var(--border);
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}

.sw.on-drom {
  background: var(--drom);
}

.sw.on-comp {
  background: var(--comp);
}

.sw.on-heat {
  background: var(--gold);
}

.sw.on-prox {
  background: var(--gold);
}

.sw::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: left .2s;
}

.sw.on-drom::after,
.sw.on-comp::after,
.sw.on-heat::after,
.sw.on-prox::after {
  left: 14px;
}

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

.reset-btn {
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 20px;
  cursor: pointer;
  transition: all .15s;
}

.reset-btn:hover {
  color: var(--comp);
  border-color: var(--comp);
}

.layer-sel-row {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}

.lsel-btn {
  flex: 1;
  padding: 5px 2px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-family: 'Syne', sans-serif;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all .15s;
}

.lsel-btn.act-all {
  background: var(--surface3);
  border-color: #4a5568;
  color: var(--text);
}

.lsel-btn.act-drom {
  background: rgba(0, 229, 255, .12);
  border-color: var(--drom);
  color: var(--drom);
}

.lsel-btn.act-comp {
  background: rgba(255, 75, 110, .12);
  border-color: var(--comp);
  color: var(--comp);
}

.sdd {
  position: relative;
  margin-bottom: 6px;
}

.sdd-label {
  font-size: 8px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sdd-lv {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.sdd-wrap {
  position: relative;
}

.sdd-inp {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 26px 6px 9px;
  border-radius: 7px;
  font-family: 'Syne', sans-serif;
  font-size: 11px;
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sdd-inp:focus,
.sdd-inp:hover:not(.off) {
  border-color: rgba(0, 229, 255, .4);
}

.sdd-inp.active {
  border-color: var(--drom);
  background: rgba(0, 229, 255, .05);
}

.sdd-inp.off {
  opacity: .38;
  cursor: not-allowed;
  pointer-events: none;
}

.sdd-ico {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 10px;
  pointer-events: none;
}

.sdd-x {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  display: none;
  line-height: 1;
}

.sdd-x:hover {
  color: var(--comp);
}

.sdd.has-val .sdd-x {
  display: block;
}

.sdd.has-val .sdd-ico {
  display: none;
}

.sdd-drop {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 3000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .55);
  display: none;
  overflow: hidden;
}

.sdd-drop.open {
  display: block;
}

.sdd-srch {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

.sdd-srch input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  border-radius: 5px;
  font-family: 'Syne', sans-serif;
  font-size: 11px;
  outline: none;
}

.sdd-srch input:focus {
  border-color: var(--drom);
}

.sdd-list {
  max-height: 155px;
  overflow-y: auto;
}

.sdd-list::-webkit-scrollbar {
  width: 3px;
}

.sdd-list::-webkit-scrollbar-thumb {
  background: var(--border);
}

.sdd-opt {
  padding: 7px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: background .1s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sdd-opt:hover {
  background: var(--surface2);
}

.sdd-opt.sel {
  background: rgba(0, 229, 255, .08);
  color: var(--drom);
}

.sdd-opt-ct {
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--muted);
}

.sdd-empty {
  padding: 10px;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
}

.casc-line {
  width: 1px;
  height: 5px;
  background: var(--border);
  margin: 0 0 6px 11px;
}

.ranking {
  padding: 10px 14px;
}

.rank-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 7px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
  margin-bottom: 1px;
}

.rank-item:hover {
  background: var(--surface2);
}

.rank-num {
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--muted);
  width: 13px;
  text-align: right;
  flex-shrink: 0;
}

.rank-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--drom);
  flex-shrink: 0;
}

.rank-info {
  flex: 1;
  min-width: 0;
}

.rank-name {
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-city {
  font-size: 9px;
  color: var(--muted);
}

.rank-sales {
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--gold);
  flex-shrink: 0;
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 13, 20, .92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 12px;
}

.loading-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--drom);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 11px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
}

#map {
  flex: 1;
  z-index: 1;
  position: relative;
  cursor: crosshair;
}

.leaflet-tile {
  filter: none;
}

.leaflet-container {
  background: var(--bg) !important;
}

.map-sb {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  width: 340px;
  max-width: calc(100vw - 40px);
  display: flex;
  align-items: center;
}

.map-sb-inp {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 38px 9px 14px;
  border-radius: 24px;
  font-family: 'Syne', sans-serif;
  font-size: 12px;
  outline: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .5);
  transition: border-color .15s;
}

.map-sb-inp:focus {
  border-color: var(--drom);
}

.map-sb-inp::placeholder {
  color: var(--muted);
}

.map-sb-icon {
  position: absolute;
  right: 13px;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

.map-sb-res {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .6);
  display: none;
  overflow: hidden;
  max-height: 60vh;
  overflow-y: auto;
}

.map-sb-res.open {
  display: block;
}

.map-sb-res::-webkit-scrollbar {
  width: 4px;
}

.map-sb-res::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.map-sb-item {
  padding: 9px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: background .1s;
  border-bottom: 1px solid var(--border);
}

.map-sb-item:last-child {
  border-bottom: none;
}

.map-sb-item:hover {
  background: var(--surface2);
}

.map-sb-name {
  font-weight: 600;
  color: var(--text);
}

.map-sb-sub {
  font-size: 10px;
  color: var(--muted);
  margin-top: 1px;
}

.map-sb-msg {
  padding: 12px 14px;
  font-size: 11px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
}

.map-sb-badge {
  display: inline-block;
  font-size: 8px;
  padding: 1px 5px;
  border-radius: 10px;
  margin-left: 4px;
  font-family: 'JetBrains Mono', monospace;
}

.map-sb-badge.drom {
  background: rgba(0, 229, 255, .15);
  color: var(--drom);
}

.map-sb-badge.comp {
  background: rgba(255, 75, 110, .15);
  color: var(--comp);
}

.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .7) !important;
  padding: 0 !important;
}

.leaflet-popup-tip {
  background: var(--surface) !important;
}

.leaflet-popup-close-button {
  color: var(--muted) !important;
  top: 10px !important;
  right: 10px !important;
  font-size: 18px !important;
}

.popup-body {
  padding: 14px 16px 12px;
  min-width: 210px;
}

.popup-badge {
  display: inline-block;
  font-size: 8px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: .15em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 7px;
}

.popup-badge.drom {
  background: rgba(0, 229, 255, .15);
  color: var(--drom);
}

.popup-badge.comp {
  background: rgba(255, 75, 110, .15);
  color: var(--comp);
}

.popup-name {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.3;
  color: #fff;
}

.popup-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 11px;
}

.popup-stat {
  background: var(--surface2);
  border-radius: 6px;
  padding: 7px 9px;
}

.popup-stat-label {
  font-size: 9px;
  color: #ffffff;
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 2px;
  text-transform: uppercase;
}

.popup-stat-value {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.popup-stat-value.gold {
  color: var(--gold);
}

.popup-stat-value.cyan {
  color: var(--drom);
}

.popup-btn {
  display: block;
  width: 100%;
  padding: 8px;
  background: #ffffff;
  color: #ffffff;
  border: none;
  border-radius: 7px;
  font-family: 'Syne', sans-serif;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: opacity .15s;
}

.popup-btn:hover {
  opacity: .85;
}

.popup-btn.comp {
  background: #4a5568;
  color: #ffffff;
}

.bottombar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 5px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 10px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  flex-shrink: 0;
  width: 100%;
  z-index: 1000;
  position: relative;
}

.bottombar span {
  color: var(--text);
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
  margin-right: 4px;
  box-shadow: 0 0 5px #4ade80;
}

.status-dot.loading {
  background: var(--gold);
  animation: pulse 1s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .4;
  }
}

.s-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 800;
}

.s-overlay.show {
  display: block;
}

.geo-btn {
  position: absolute;
  bottom: 90px;
  right: 10px;
  z-index: 1000;
  width: 34px;
  height: 34px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all .15s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}

.geo-btn:hover {
  border-color: var(--drom);
  color: var(--drom);
}

.geo-btn.active {
  border-color: var(--drom);
  background: rgba(0, 229, 255, .1);
}

.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 13, 20, 0.95);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 360px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}

.login-logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .15em;
  color: var(--drom);
  text-align: center;
  margin-bottom: 6px;
}

.login-sub {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 28px;
}

.login-field {
  margin-bottom: 14px;
}

.login-label {
  font-size: 9px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 5px;
  display: block;
}

.login-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}

.login-input:focus {
  border-color: var(--drom);
}

.login-btn {
  width: 100%;
  padding: 11px;
  background: var(--drom);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity .15s;
  letter-spacing: .05em;
}

.login-btn:hover {
  opacity: .85;
}

.login-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.login-error {
  color: var(--comp);
  font-size: 11px;
  text-align: center;
  margin-top: 10px;
  font-family: 'JetBrains Mono', monospace;
  min-height: 16px;
}

.login-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(10, 13, 20, .3);
  border-top-color: var(--bg);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* MODAL DE EDICIÓN AMPLIADO Y AJUSTADO */
.edit-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 999999;
  align-items: center;
  justify-content: center;
}

.edit-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.edit-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 15px;
  color: var(--drom);
  line-height: 1.3;
}

.edit-input-group {
  margin-bottom: 12px;
}

.edit-input-group label {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 4px;
  font-family: 'JetBrains Mono', monospace;
}

.edit-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  outline: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.edit-input::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

.edit-input:focus {
  border-color: var(--drom);
}

.edit-btns {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.edit-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  font-family: 'Syne', sans-serif;
  font-size: 12px;
  transition: opacity 0.15s;
}

.edit-btn:hover {
  opacity: 0.85;
}

.edit-btn.save {
  background: var(--drom);
  color: #0a0d14;
}

.edit-btn.cancel {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-left: 1px solid var(--border);
  cursor: pointer;
  height: 100%;
  flex-shrink: 0;
}

.user-badge:hover {
  background: var(--surface2);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 229, 255, .2);
  border: 1.5px solid var(--drom);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--drom);
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.user-rol {
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: .1em;
}

.user-menu {
  position: absolute;
  top: 52px;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  z-index: 2000;
  min-width: 160px;
  display: none;
}

.user-menu.show {
  display: block;
}

.user-menu-item {
  padding: 10px 16px;
  font-size: 12px;
  cursor: pointer;
  transition: background .1s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-menu-item:hover {
  background: var(--surface2);
}

.user-menu-item.danger {
  color: var(--comp);
}

.store-banner {
  display: block;
  margin: 14px;
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  border: 1px solid var(--border);
  transition: transform 0.15s, border-color 0.15s;
}

.store-banner:hover {
  transform: translateY(-2px);
  border-color: var(--drom);
}

.store-banner img {
  width: 100%;
  height: auto;
  display: block;
}

.marker-logo {
  background-size: cover;
  background-position: center;
  background-color: #fff;
  border-radius: 50%;
  border: 2px solid #fff;
}

.marker-drom {
  border-color: transparent;
  box-shadow: none;
}

.marker-comp {
  border-color: var(--comp);
  box-shadow: 0 0 8px rgba(255, 75, 110, 0.6);
}

/* PANEL DE INFORME DESLIZABLE */
.informe-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 85vh;
  background: var(--bg);
  z-index: 9999;
  border-top: 1px solid var(--border);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.informe-panel.open {
  transform: translateY(0);
}

.informe-header {
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.informe-title {
  font-size: 24px;
  font-weight: 800;
  font-family: 'Syne', sans-serif;
  color: #fff;
}

.informe-sub {
  font-size: 11px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 4px;
  font-weight: 400;
  text-transform: uppercase;
}

.informe-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  transition: all 0.2s;
}

.informe-close:hover {
  color: var(--comp);
  border-color: var(--comp);
}

.informe-body {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
}

.informe-placeholder {
  border: 1px dashed var(--border);
  border-radius: 12px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(22, 27, 46, 0.3);
}

/* MÉTRICAS DE MERCADO POTENCIAL */
.prox-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
  text-align: left;
}

.prox-stat-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 8px;
}

.prox-val {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin-top: 4px;
  font-family: 'Syne', sans-serif;
}

/* ── LA MAGIA DEL RESPONSIVE MÓVIL ── */
@media (max-width: 1024px) {

  /* El panel derecho ahora se comporta igual que el izquierdo, pero del lado contrario */
  .right-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    left: auto;
    bottom: 0;
    transform: translateX(100%);
    z-index: 900;
    box-shadow: -4px 0 24px rgba(0, 0, 0, .6);
    transition: transform 0.25s ease;
    background: var(--bg);
  }

  .right-sidebar.open {
    transform: translateX(0);
  }

  /* Mostramos los botones de menú en tablets/móviles */
  .menu-btn {
    display: block;
  }
}

@media (max-width: 768px),
(max-height: 500px) and (orientation: landscape) {
  .kpi:nth-child(n+4) {
    display: none;
  }

  /* Especificamos el panel izquierdo (#sidebar) para que no haya conflictos con el derecho (.right-sidebar) */
  #sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 900;
    box-shadow: 4px 0 24px rgba(0, 0, 0, .6);
    transition: transform 0.25s ease;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  .hide-mobile {
    display: none;
  }

  .map-sb {
    width: calc(100vw - 80px);
  }

  :root {
    --sidebar: 88vw;
  }

  /* Ajustamos el ancho del panel derecho en móviles */
  .right-sidebar {
    width: 88vw;
  }
}

/* ══════════════════════════════════════════
   MASTER PANEL
══════════════════════════════════════════ */
.master-tab {
  transition: all .15s;
}

.master-tab:hover {
  background: var(--surface2);
}

.master-tab.active {
  color: var(--drom) !important;
  border-bottom-color: var(--drom) !important;
}

.master-user-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.master-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 229, 255, .1);
  border: 1.5px solid var(--drom);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--drom);
  flex-shrink: 0;
}

.master-user-info {
  flex: 1;
  min-width: 0;
}

.master-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.master-user-email {
  font-size: 10px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
}

.master-rol-badge {
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(0, 229, 255, .1);
  color: var(--drom);
  border: 1px solid rgba(0, 229, 255, .2);
  white-space: nowrap;
}

.master-action-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 10px;
  cursor: pointer;
  transition: all .15s;
  font-family: 'JetBrains Mono', monospace;
}

.master-action-btn:hover {
  border-color: var(--comp);
  color: var(--comp);
}

/* ==========================================================================
   📊 DASHBOARD - ESTILOS BASE
   ========================================================================== */

/* Contenedores Generales */
.miya-body {
  padding: 20px 30px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.miya-header-controls {
  display: flex;
  gap: 10px;
  margin-right: 20px;
  margin-left: auto;
  align-items: center;
}

.miya-section-grid-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.miya-section-grid-1-1 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.miya-panel-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.miya-panel-card.no-pad {
  padding: 0;
  overflow: hidden;
}

.miya-panel-card.flex-col {
  display: flex;
  flex-direction: column;
}

.miya-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.miya-panel-header.pad-15 {
  padding: 15px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

.miya-panel-title {
  margin: 0;
  color: #fff;
  font-size: 14px;
  font-family: 'Syne', sans-serif;
}

.miya-panel-subtitle {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}

/* Selector de Mes y Filtros */
.miya-active-filter {
  display: none;
  background: rgba(245, 200, 66, 0.1);
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  align-items: center;
  gap: 8px;
}

.miya-filter-text {
  font-weight: bold;
}

.miya-btn-clear {
  background: none;
  border: none;
  color: var(--gold);
  cursor: pointer;
  font-size: 12px;
}

.miya-month-selector-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: 8px;
}

.miya-month-label {
  font-size: 10px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
}

.miya-month-select {
  width: auto;
  margin-top: 0;
  padding: 4px 6px;
  font-size: 11px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--drom);
  font-weight: bold;
  cursor: pointer;
}

/* Tarjetas KPI */
.miya-kpis-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); 
    gap: 16px; /* Más espacio entre cajas */
    margin-bottom: 24px; 
}

.miya-kpi-card { 
    background: var(--surface2); 
    border: 1px solid var(--border); 
    border-radius: 10px; 
    padding: 24px 16px; /* Más aire vertical (24px) */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.miya-kpi-card.highlight-mat { 
    border-color: var(--drom); 
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.05); 
}

.miya-kpi-title { 
    font-size: 10px; 
    color: var(--muted); 
    font-family: 'JetBrains Mono', monospace; 
    text-transform: uppercase; 
    margin-bottom: 4px;
}

.miya-kpi-value { 
    font-size: 19px; /* Reducimos el tamaño para que quepan todos los dígitos */
    font-weight: 700; /* Un poco menos tosco */
    font-family: 'JetBrains Mono', monospace; /* Letra más angosta y limpia para números */
    margin: 8px 0; 
    white-space: nowrap; /* 🔥 MAGIA: Obliga a que todo el número y la "M" se queden en la misma línea */
    letter-spacing: -0.5px; /* Acerca sutilmente los números para ahorrar espacio */
    overflow: hidden;
    text-overflow: ellipsis;
}
.miya-kpi-delta {
  font-size: 10px;
}

.miya-kpi-desc {
  font-size: 10px;
  color: var(--muted);
}

.miya-kpi-progress-bg {
  background: var(--bg);
  height: 4px;
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.miya-kpi-progress-fill {
  background: var(--drom);
  height: 100%;
  transition: width 1s;
}

/* Controles de Gráficas y Buscador */
.miya-chart-controls {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  display: flex;
}

.miya-chart-btn {
  padding: 4px 10px;
  font-size: 10px;
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
  transition: 0.2s;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.miya-chart-container {
  height: 220px;
  position: relative;
  width: 100%;
}

.miya-chart-container.small {
  height: 200px;
}

.miya-search-input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  outline: none;
  width: 220px;
}

.miya-select-small {
  width: auto;
  margin-top: 0;
  padding: 4px 8px;
  font-size: 10px;
  background: var(--bg);
}

/* Tablas de Datos */
.miya-table-header {
  padding: 10px 15px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 9px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
}

.miya-table-body {
  max-height: 220px;
  overflow-y: auto;
  padding: 10px;
}

.miya-table-body.large {
  max-height: 300px;
}

/* Rejillas de Tablas (Grid) */
.grid-share {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
}

.grid-rank {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
}

.grid-detail {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
}

/* Filas Inyectadas por JS */
.miya-row {
  padding: 10px 15px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  align-items: center;
  transition: 0.2s;
}

.miya-row.share {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  cursor: pointer;
  padding: 8px 15px;
}

.miya-row.share:hover {
  background: var(--surface2);
}

.miya-row.rank {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  padding: 8px 15px;
}

.miya-row.detail {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  cursor: pointer;
}

.miya-row.detail:hover {
  background: var(--surface);
}

/* Barras de Share */
.miya-share-bar-bg {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  display: flex;
  overflow: hidden;
}

.miya-share-bar-drom {
  background: var(--drom);
}

.miya-share-bar-comp {
  background: var(--comp);
}

/* Utilidades de Texto */
.text-drom {
  color: var(--drom);
}

.text-gold {
  color: var(--gold);
}

.text-white {
  color: #fff;
}

.text-comp {
  color: var(--comp);
}

.text-right {
  text-align: right;
}

/* ==========================================================================
   📱 RESPONSIVE MIYAGUI (MÓVILES)
   ========================================================================== */
@media (max-width: 768px) {

  /* 1. Ajustes del Encabezado Principal */
  .miya-body {
    padding: 10px;
  }

  .informe-title {
    font-size: 22px;
    line-height: 1.2;
  }

  .informe-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
    height: auto;
    padding: 20px 15px;
    position: relative;
  }

  .miya-header-controls {
    margin-left: 0;
    flex-wrap: wrap;
    width: 100%;
    gap: 8px;
    justify-content: flex-start;
  }

  .informe-close {
    position: absolute;
    top: 15px;
    right: 15px;
  }

  /* 2. Colapsar las grillas a una sola columna */
  .miya-section-grid-2-1,
  .miya-section-grid-1-1 {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  /* 3. Arreglar los encabezados de las tarjetas para que no aplasten el texto */
  .miya-panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .miya-panel-header>div {
    width: 100%;
  }

  .miya-panel-header>div[data-html2canvas-ignore] {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    gap: 8px;
  }

  /* 4. Buscadores y botones a ancho completo */
  .miya-search-input {
    width: 100% !important;
  }

  .miya-chart-controls {
    width: 100%;
    justify-content: space-between;
    margin-top: 10px;
  }

  .miya-chart-btn {
    flex: 1;
    text-align: center;
  }

  /* 🚨 5. MAGIA PARA LAS TABLAS (Scroll Horizontal) 🚨 */
  .miya-panel-card.no-pad {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Scroll suave en iOS */
  }

  /* Forzamos un ancho mínimo para que las columnas respiren, si no caben, se hace scroll */
  .grid-detail,
  .miya-row.detail {
    min-width: 650px;
  }

  .grid-share,
  .miya-row.share {
    min-width: 450px;
  }

  .grid-rank,
  .miya-row.rank {
    min-width: 400px;
  }

  /* Reducir ligeramente el tamaño del gráfico en móviles */
  .miya-chart-container {
    height: 180px;
  }
}