/* Reset y variables - Estilo TIVOR Profesional */
:root {
  --primary-color: #0D47A1;
  --primary-dark: #0A3D8F;
  --primary-light: #1565C0;
  --secondary-color: #0D1B2A;
  --accent-color: #E74C3C;
  --success-color: #27AE60;
  --warning-color: #F39C12;
  --text-primary: #1A1A1A;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;
  --background-light: #FFFFFF;
  --background-gray: #F9FAFB;
  --background-dark: #F3F4F6;
  --border-color: #E5E7EB;
  --border-light: #F3F4F6;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --border-radius-xl: 16px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Tipografía profesional */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--background-gray);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header Profesional */
.header {
  background: var(--background-light);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 1001;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.95);
}

.header-content {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0.5rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 50px;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: transparent !important;
  position: relative;
  z-index: 1002;
}

.logo-img {
  height: 32px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  background: transparent !important;
}

.logo {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-color);
  font-family: var(--font-family);
  letter-spacing: -0.02em;
  margin: 0;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* Buttons Profesionales - Mejorados */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--border-radius);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-family);
  letter-spacing: 0.01em;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(13, 71, 161, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(13, 71, 161, 0.4);
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(13, 71, 161, 0.3);
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-secondary {
  background: var(--background-light);
  color: var(--text-primary);
  border: 1.5px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--background-gray);
  border-color: var(--primary-color);
  color: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-icon {
  padding: 0.625rem;
  background: var(--background-light);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}

.btn-icon:hover {
  background: var(--background-gray);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-danger {
  background: var(--accent-color);
  color: white;
  box-shadow: var(--shadow);
}

.btn-danger:hover {
  background: #c0392b;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Main Content */
.main-content {
  position: relative;
  height: calc(100vh - 80px);
  min-height: 600px;
}

@media (max-width: 480px) {
  .main-content {
    height: calc(100vh - 50px);
    min-height: calc(100vh - 50px);
  }
}

.view {
  display: none;
  height: 100%;
}

.view.active {
  display: block;
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2.5rem;
}

/* Map */
.map-container {
  position: relative;
  height: 100%;
  width: 100%;
}

.map {
  height: 100%;
  width: 100%;
  min-height: 600px;
  background: var(--background-gray);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

@media (max-width: 480px) {
  .map-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    width: 100%;
  }
  
  .map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    min-height: 100%;
    border-radius: 0;
  }
}

/* Search Bar Profesional - Fija para evitar movimiento */
.search-bar {
  position: fixed !important;
  top: 58px;
  left: 1.5rem;
  right: auto;
  max-width: 500px;
  width: calc(100% - 3rem);
  z-index: 999;
  display: flex !important;
  gap: 0.5rem;
  background: var(--background-light);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  pointer-events: auto;
  visibility: visible !important;
  opacity: 1 !important;
}

.search-input {
  flex: 1;
  padding: 0.875rem 1.25rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.9375rem;
  font-family: var(--font-family);
  transition: var(--transition);
  background: var(--background-light);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(13, 71, 161, 0.1);
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

  /* Resultados de búsqueda predictiva */
.address-results {
  position: absolute !important;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  background: var(--background-light);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  max-height: 50vh;
  overflow-y: auto;
  z-index: 1002 !important;
  box-shadow: var(--shadow-lg);
  -webkit-overflow-scrolling: touch;
  margin: 0;
}

@media (max-width: 480px) {
  .address-results {
    max-height: calc(100vh - 150px) !important;
    top: calc(100% + 0.25rem) !important;
  }
}

.search-result-item {
  padding: 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition);
  background: var(--background-light);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover,
.search-result-item:focus {
  background: var(--background-gray);
  outline: none;
}

.search-result-item:active {
  background: var(--background-dark);
}

.search-result-main {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9375rem;
  margin-bottom: 0.25rem;
}

.search-result-details {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.search-result-empty,
.search-result-error {
  padding: 1rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.search-result-error {
  color: var(--accent-color);
}

/* Loading state para búsqueda */
.address-results::before {
  content: 'Buscando...';
  display: block;
  padding: 1rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.address-results:not(:empty)::before {
  display: none;
}

/* Sidebar Profesional */
.sidebar {
  position: fixed;
  top: 80px;
  right: 1.5rem;
  width: 400px;
  max-height: calc(100vh - 100px);
  background: var(--background-light);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  z-index: 999;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  overflow: hidden;
  transform: translateX(calc(100% + 2rem));
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.98);
}

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

/* Overlay para móviles cuando sidebar está abierto - Solo fondo semitransparente */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* En móvil, el overlay permite cerrar el sidebar tocando fuera */
@media (max-width: 480px) {
  .sidebar-overlay.active {
    cursor: pointer;
  }
}

@media (min-width: 769px) {
  .sidebar-overlay {
    display: none;
  }
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  color: white;
}

.sidebar-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: white;
}

.btn-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.companies-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

/* Company Item Profesional */
.company-item {
  padding: 1.5rem;
  margin-bottom: 1rem;
  border-radius: var(--border-radius-lg);
  background: linear-gradient(135deg, var(--background-light) 0%, var(--background-gray) 100%);
  border: 2px solid var(--border-color);
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.company-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary-color);
  transform: scaleY(0);
  transition: transform 0.3s ease;
}

.company-item:hover::before {
  transform: scaleY(1);
}

.company-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-color);
  background: var(--background-light);
}

.company-item h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.company-item p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.company-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.company-actions .btn {
  flex: 1;
  min-width: 100px;
  font-size: 0.8125rem;
  padding: 0.5rem 0.75rem;
}

/* Forms Profesionales */
.form {
  background: var(--background-light);
  border-radius: var(--border-radius-xl);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  padding: 2.5rem;
  border: 1px solid var(--border-color);
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(249, 250, 251, 0.95) 100%);
}

.form::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
  border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0;
}

.form h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: var(--text-primary);
  text-align: center;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.875rem 1.25rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.9375rem;
  font-family: var(--font-family);
  transition: var(--transition);
  background: var(--background-light);
  color: var(--text-primary);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(13, 71, 161, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.form-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

/* Modal Profesional */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  background: var(--background-light);
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border-color);
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--background-gray);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
  z-index: 10;
}

.modal-close:hover {
  background: var(--accent-color);
  color: white;
  transform: rotate(90deg);
}

#modal-content {
  padding: 2.5rem;
}

#modal-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

/* Dashboard Cards - Diseño Profesional */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.dashboard-card {
  background: var(--background-light);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  padding: 2rem;
  border: 1px solid var(--border-color);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 1) 100%);
}

.dashboard-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.dashboard-card:hover::after {
  opacity: 1;
}

.dashboard-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border-color: var(--primary-color);
}

.dashboard-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-light);
}

.dashboard-card-icon {
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(13, 71, 161, 0.1), rgba(21, 101, 192, 0.1));
  border-radius: var(--border-radius);
  flex-shrink: 0;
}

.dashboard-card h3 {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  flex: 1;
}

.dashboard-card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.dashboard-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dashboard-field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dashboard-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  background: var(--background-gray);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-light);
}

  .dashboard-field-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  @media (min-width: 481px) {
    .dashboard-field-row {
      grid-template-columns: 1fr 1fr;
    }
  }

.dashboard-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(13, 71, 161, 0.05), rgba(21, 101, 192, 0.05));
  border-radius: var(--border-radius);
  border: 1px solid rgba(13, 71, 161, 0.1);
}

.dashboard-stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.dashboard-stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.dashboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 180px;
  overflow-y: auto;
}

.dashboard-list-item {
  padding: 0.75rem 1rem;
  background: var(--background-gray);
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  transition: var(--transition);
}

.dashboard-list-item:hover {
  background: var(--background-light);
  border-color: var(--primary-color);
  transform: translateX(4px);
}

.dashboard-list-item-more {
  padding: 0.75rem 1rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-style: italic;
}

.dashboard-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.875rem;
  font-style: italic;
}

/* Estilos premium removidos temporalmente */

.dashboard-card p {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Tables Profesionales */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--background-light);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
}

.table th {
  background: var(--background-gray);
  padding: 1rem 1.25rem;
  text-align: left;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border-color);
}

.table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9375rem;
  color: var(--text-primary);
}

.table tr:hover {
  background: var(--background-gray);
}

.table tr:last-child td {
  border-bottom: none;
}

/* Badges Profesionales */
.badge {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-success {
  background: rgba(39, 174, 96, 0.1);
  color: var(--success-color);
  border: 1px solid rgba(39, 174, 96, 0.2);
}

.badge-warning {
  background: rgba(243, 156, 18, 0.1);
  color: var(--warning-color);
  border: 1px solid rgba(243, 156, 18, 0.2);
}

.badge-danger {
  background: rgba(231, 76, 60, 0.1);
  color: var(--accent-color);
  border: 1px solid rgba(231, 76, 60, 0.2);
}

/* Admin Tabs Profesionales */
.admin-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--border-color);
  flex-wrap: wrap;
}

.admin-tab {
  padding: 0.875rem 1.5rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
  font-family: var(--font-family);
  position: relative;
  letter-spacing: 0.01em;
}

.admin-tab:hover {
  color: var(--primary-color);
  background: var(--background-gray);
}

.admin-tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  background: var(--background-light);
}

/* Responsive - Mobile First Approach */
@media (max-width: 480px) {
  /* Header móvil - más compacto y profesional */
  .header {
    position: sticky;
    top: 0;
    z-index: 1001;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.98);
  }

  .header-content {
    padding: 0.625rem 1rem;
    flex-wrap: nowrap;
    gap: 0.5rem;
    min-height: 56px;
    max-height: 56px;
    align-items: center;
  }

  .logo-container {
    flex: 0 0 auto;
    min-width: 0;
    position: relative;
    z-index: 1003;
  }

  .logo-img {
    height: 32px;
  }

  .logo {
    font-size: 1.125rem;
  }

  .nav {
    gap: 0.25rem;
    flex-wrap: nowrap;
    width: auto;
    justify-content: flex-end;
    flex: 0 0 auto;
  }

  .nav .btn {
    padding: 0.375rem 0.625rem;
    font-size: 0.6875rem;
    white-space: nowrap;
    min-width: auto;
  }

  /* Barra de búsqueda móvil - visible y bien posicionada */
  .search-bar {
    position: fixed !important;
    top: 50px !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
    max-width: none !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: calc(100% - 1rem) !important;
    padding: 0.5rem !important;
    gap: 0.5rem !important;
    border-radius: var(--border-radius) !important;
    z-index: 1000 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: var(--background-light) !important;
  }

  .search-input {
    padding: 0.625rem 0.875rem !important;
    font-size: 0.875rem !important;
    min-height: 40px;
  }

  .btn-icon {
    min-width: 40px !important;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    font-size: 1.125rem !important;
    flex-shrink: 0;
  }

  /* Ajustar controles de Leaflet en móvil - más abajo para no tapar búsqueda */
  .leaflet-top.leaflet-left {
    top: 100px !important;
    left: 5px !important;
  }
  
  .leaflet-right.leaflet-top {
    top: 100px !important;
    right: 5px !important;
  }

  .leaflet-control {
    margin: 5px;
  }

  .leaflet-control-zoom a {
    width: 32px;
    height: 32px;
    line-height: 32px;
    font-size: 16px;
  }

  .leaflet-draw-toolbar a {
    width: 32px;
    height: 32px;
    line-height: 32px;
    font-size: 14px;
  }

  .leaflet-control-measure a {
    width: 32px;
    height: 32px;
    line-height: 32px;
    font-size: 14px;
  }

  /* Sidebar móvil - Panel lateral que no tapa todo el mapa */
  .sidebar {
    position: fixed;
    top: 100px;
    right: 0;
    bottom: 0;
    width: 75%;
    max-width: 320px;
    min-width: 280px;
    max-height: calc(100vh - 100px);
    border-radius: var(--border-radius-lg) 0 0 var(--border-radius-lg);
    z-index: 1002;
    transform: translateX(100%);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
    border-left: 2px solid var(--border-color);
  }

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

  /* Ajustar mapa cuando sidebar está abierto - El mapa se reduce pero sigue visible */
  .map-container {
    transition: padding-right 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Cuando el sidebar está abierto, el mapa se ajusta realmente */
  .map-container.sidebar-open {
    padding-right: min(75%, 320px);
    width: calc(100% - min(75%, 320px));
  }
  
  #map-view.sidebar-open .map-container {
    padding-right: min(75%, 320px);
    width: calc(100% - min(75%, 320px));
  }

  /* Asegurar que el mapa se vea correctamente */
  .map-container.sidebar-open .map {
    width: 100% !important;
    height: 100% !important;
  }

  .sidebar-header {
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--background-light);
  }

  .sidebar-header h2 {
    font-size: 1rem;
    margin: 0;
  }

  .companies-list {
    padding: 0.75rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
  }

  /* Contenedor principal */
  .main-content {
    padding: 0 !important;
    margin: 0 !important;
    height: calc(100vh - 50px) !important;
    overflow: hidden;
    position: relative;
  }

  .map-container {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    height: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 1;
    transition: padding-right 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Cuando el sidebar está abierto, el mapa se ajusta realmente */
  .map-container.sidebar-open {
    padding-right: min(75%, 320px);
    width: calc(100% - min(75%, 320px));
  }
  
  #map-view.sidebar-open .map-container {
    padding-right: min(75%, 320px);
    width: calc(100% - min(75%, 320px));
  }

  /* Asegurar que el mapa se vea correctamente */
  .map-container.sidebar-open .map {
    width: 100% !important;
    height: 100% !important;
  }

  .map {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    border-radius: 0 !important;
    z-index: 1;
  }
  
  /* Asegurar que el mapa no tenga padding superior */
  #map-view {
    padding: 0 !important;
    margin: 0 !important;
    height: calc(100vh - 50px) !important;
    overflow: hidden;
    position: relative;
  }
  
  .view {
    height: 100%;
    position: relative;
  }

  /* Formularios móviles */
  .container {
    padding: 1rem;
  }

  .form {
    padding: 1rem;
  }

  .form-group {
    margin-bottom: 1rem;
  }

  .form-label {
    font-size: 0.875rem;
  }

  .form-input,
  .form-select,
  .form-textarea {
    padding: 0.75rem;
    font-size: 0.875rem;
  }

  /* Cards móviles */
  .card {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .card-header h3 {
    font-size: 1rem;
  }

  /* Tablas móviles */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table {
    font-size: 0.75rem;
  }

  .table th,
  .table td {
    padding: 0.5rem;
  }

  /* Modales móviles */
  .modal {
    width: 95%;
    max-width: 95%;
    max-height: 90vh;
    margin: 5vh auto;
    padding: 1rem;
  }

  .modal-header h2 {
    font-size: 1.25rem;
  }

  /* Dashboard móvil */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding: 0;
    margin-bottom: 1.5rem;
  }

  .dashboard-card {
    padding: 1.5rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
  }

  .dashboard-card-header {
    margin-bottom: 1.25rem;
    padding-bottom: 0.875rem;
  }

  .dashboard-card h3 {
    font-size: 0.9375rem;
    margin-bottom: 1rem;
    line-height: 1.4;
  }

  .dashboard-card-icon {
    width: 36px;
    height: 36px;
    font-size: 1.25rem;
  }

  .dashboard-stat-number {
    font-size: 2rem;
  }

  .dashboard-stat-label {
    font-size: 0.6875rem;
  }

  /* Admin tabs móvil */
  .admin-tabs {
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .admin-tab {
    padding: 0.625rem 1rem;
    font-size: 0.75rem;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  /* Tablets - Diseño optimizado */
  .header-content {
    padding: 1rem 1.75rem;
  }

  .logo-img {
    height: 44px;
  }

  .nav {
    gap: 0.625rem;
  }

  .btn {
    padding: 0.625rem 1.125rem;
    font-size: 0.875rem;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .dashboard-card {
    padding: 1.75rem;
  }

  .container {
    padding: 1.5rem;
  }

  .form {
    padding: 2rem;
  }

  .search-bar {
    top: 80px;
    left: 1rem;
    right: auto;
    max-width: 500px;
    width: calc(100% - 2rem);
    padding: 0.75rem;
  }

  .leaflet-top.leaflet-left {
    top: 140px;
    left: 10px;
  }

  .sidebar {
    width: 380px;
    top: 75px;
    max-height: calc(100vh - 95px);
    border-radius: var(--border-radius-lg);
  }

  .map-container {
    margin-top: 0;
  }

  .map {
    min-height: 500px;
    border-radius: var(--border-radius-lg);
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  /* Tablets grandes - Diseño mejorado */
  .header-content {
    padding: 1.25rem 2rem;
  }

  .search-bar {
    top: 85px;
    left: 1.5rem;
    max-width: 600px;
    padding: 0.75rem 1rem;
  }

  .sidebar {
    width: 400px;
    top: 85px;
    max-height: calc(100vh - 105px);
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }

  .container {
    padding: 2rem;
  }
}

@media (min-width: 1025px) {
  /* Desktop - Diseño profesional completo */
  .header-content {
    padding: 1.5rem 2.5rem;
  }

  .search-bar {
    top: 100px;
    left: 2rem;
    max-width: 650px;
  }

  .sidebar {
    width: 420px;
    top: 100px;
    right: 2rem;
    max-height: calc(100vh - 120px);
  }

  .dashboard-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
  }

  .container {
    padding: 2.5rem;
    max-width: 1400px;
  }

  .form {
    max-width: 700px;
    padding: 3rem;
  }

  /* Ajustes cuando hay sidebar abierto */
  .map-container {
    padding-right: 0;
    transition: padding-right 0.3s ease;
  }

  .sidebar.open ~ .map-container {
    padding-right: 0;
  }
}

/* Mejoras generales responsive */
@media (max-width: 768px) {
  /* Ajustar padding del body cuando hay sidebar abierto */
  body.sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }

  /* Mejorar scroll en móviles */
  .companies-list {
    -webkit-overflow-scrolling: touch;
    padding: 0.75rem;
  }

  /* Ajustar botones de acción */
  .btn-action {
    padding: 0.625rem 1rem;
    font-size: 0.8125rem;
    min-height: 44px;
  }

  /* Mejorar visibilidad de badges */
  .badge {
    font-size: 0.6875rem;
    padding: 0.3125rem 0.625rem;
  }

  /* Mejorar tablas en móvil */
  .table-container {
    margin: 0 -1rem;
    padding: 0 1rem;
  }

  .table {
    font-size: 0.8125rem;
    min-width: 600px;
  }

  /* Mejorar formularios */
  .form-group {
    margin-bottom: 1.25rem;
  }

  .form-actions {
    flex-direction: column-reverse;
    gap: 0.75rem;
  }

  .form-actions .btn {
    width: 100%;
  }
}

/* Mejoras de accesibilidad táctil */
@media (hover: none) and (pointer: coarse) {
  /* Aumentar área táctil en móviles */
  .btn {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
  }

  .btn-close {
    min-width: 44px;
    min-height: 44px;
  }

  .btn-icon {
    min-width: 44px;
    min-height: 44px;
  }

  /* Mejorar feedback táctil */
  .btn:active {
    transform: scale(0.96);
    opacity: 0.9;
  }

  .company-item:active {
    transform: scale(0.98);
  }

  /* Mejorar inputs táctiles */
  input, select, textarea {
    font-size: 16px; /* Previene zoom en iOS */
    min-height: 44px;
  }
}

/* Leaflet overrides profesionales */
.leaflet-container {
  font-family: var(--font-family);
  z-index: 1;
}

/* Ajustar tamaño de controles de Leaflet */
.leaflet-control {
  margin: 10px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  background: var(--background-light);
}

.leaflet-control-zoom {
  border-radius: var(--border-radius);
}

.leaflet-control-zoom a {
  width: 34px;
  height: 34px;
  line-height: 34px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--background-light);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.leaflet-control-zoom a:hover {
  background: var(--background-gray);
  color: var(--primary-color);
}

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
  border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.leaflet-control-zoom-out {
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  border-top: none;
}

/* Ajustar herramientas de dibujo */
.leaflet-draw-toolbar {
  margin-top: 10px;
  border-radius: var(--border-radius);
}

.leaflet-draw-toolbar a {
  width: 36px;
  height: 36px;
  line-height: 36px;
  font-size: 16px;
  background: var(--background-light);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  transition: var(--transition);
  border-radius: var(--border-radius);
  margin-bottom: 4px;
}

.leaflet-draw-toolbar a:hover {
  background: var(--background-gray);
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.leaflet-draw-toolbar-top {
  margin-top: 10px;
}

/* Ajustar control de medición */
/* TIVOR Premium - Vistas y Tabs */
.view-tab {
  transition: all 0.2s ease;
}

.view-tab:hover {
  background: var(--background-gray);
  border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.network-view {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.port-slot {
  transition: all 0.2s ease;
}

.port-slot:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* OZMAP Sidebar Styles */
.ozmap-sidebar {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.ozmap-sidebar::-webkit-scrollbar {
  width: 6px;
}

.ozmap-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.ozmap-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.sidebar-section {
  margin-bottom: 0.5rem;
}

.sidebar-item, .sidebar-subitem {
  padding: 0.75rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: background 0.2s;
  user-select: none;
}

.sidebar-item:hover, .sidebar-subitem:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-item.expandable {
  justify-content: space-between;
}

.sidebar-icon {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.sidebar-arrow {
  font-size: 0.75rem;
  opacity: 0.7;
}

.sidebar-submenu {
  background: rgba(0, 0, 0, 0.2);
  padding-left: 1rem;
}

.sidebar-subitem {
  padding-left: 2.5rem;
  font-size: 0.8125rem;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Estilos OZMAP Toolbar */
.ozmap-toolbar-btn {
  background: #ecf0f1;
  border: 1px solid #bdc3c7;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: #2c3e50;
  transition: all 0.2s;
}

.ozmap-toolbar-btn:hover {
  background: #d5dbdb;
  border-color: #95a5a6;
}

.ozmap-icon-btn {
  background: #ecf0f1;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ozmap-icon-btn:hover {
  background: #d5dbdb;
}

/* Estilos OZMAP View Tabs */
.ozmap-view-tab {
  transition: all 0.2s;
}

.ozmap-view-tab:hover {
  background: #f8f9fa;
}

.ozmap-view-tab.active {
  border-bottom-color: #3498DB !important;
  color: #3498DB !important;
}

/* Estilos OZMAP Views */
.ozmap-view {
  display: none;
}

.ozmap-view.active {
  display: block;
}

/* Estilos OZMAP Panel Cards */
.ozmap-panel-card {
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Estilos para mensaje de agregar elemento */
.add-element-message {
  z-index: 2000;
  pointer-events: none;
}

.add-element-message > div {
  pointer-events: auto;
}

.leaflet-control-measure {
  margin-top: 10px;
}

.leaflet-control-measure a {
  width: 36px;
  height: 36px;
  line-height: 36px;
  font-size: 16px;
  background: var(--background-light);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.leaflet-control-measure a:hover {
  background: var(--background-gray);
  color: var(--primary-color);
  border-color: var(--primary-color);
}

/* Ajustar posición de controles para no interferir con barra de búsqueda */
.leaflet-top.leaflet-left {
  top: 135px;
  left: 10px;
}

/* Asegurar que los controles no se superpongan */
.leaflet-control-container {
  z-index: 400;
}

/* Ajustar tamaño de input en barra de búsqueda */
.search-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  font-family: var(--font-family);
  transition: var(--transition);
  background: var(--background-light);
}

/* Ajustar botón de ubicación */
.btn-icon {
  min-width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  border-radius: var(--border-radius);
  flex-shrink: 0;
}

.leaflet-popup-content-wrapper {
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.leaflet-popup-content {
  margin: 1rem;
  font-size: 0.9375rem;
}

.leaflet-draw-toolbar {
  margin-top: 10px;
}

.leaflet-draw-toolbar a {
  background-color: var(--background-light);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.leaflet-draw-toolbar a:hover {
  background-color: var(--background-gray);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Loading states - Mejorados */
.loading {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-color);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 0.8s linear infinite;
}

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.loading-spinner .loading {
  width: 32px;
  height: 32px;
  border-width: 4px;
}

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

/* Scrollbar personalizado - Mejorado */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--background-gray);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--border-color), var(--text-tertiary));
  border-radius: 5px;
  border: 2px solid var(--background-gray);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
}

/* Scrollbar para Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) var(--background-gray);
}

