/* Claudia Dashboard v2.0 - Estilos Mejorados */

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    --accent-purple: #8b5cf6;
    --accent-orange: #f97316;
    --border-color: #475569;
}

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

/* Asegurar que todo el texto sea seleccionable */
body, div, p, span, td, th, h1, h2, h3, h4, h5, h6 {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

/* Elementos específicos que deben ser fácilmente copiables */
.server-ip,
.dns-ip,
.api-balance,
.server-name,
.dns-domain,
.alert-message,
code,
pre {
    cursor: text;
    user-select: all !important;
    -webkit-user-select: all !important;
    -moz-user-select: all !important;
    -ms-user-select: all !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

.dashboard {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header - Unified across all pages */
.header,
.main-header {
    background: var(--bg-secondary);
    padding: 0.75rem 2rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.logo-section {
    justify-content: flex-start;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 0 0 150px;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-blue);
    white-space: nowrap;
}

.nav-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex: 1;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    flex: 0 0 350px;
}

.search-input {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    width: 200px;
}

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

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

/* Navigation Links - Unified across ALL pages */
.nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-btn {
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    background: transparent;
    border: 1px solid transparent;
}

.nav-btn:hover {
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent-blue);
}

.nav-btn.active {
    color: white;
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}

/* Mobile hamburger menu */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background 0.2s;
}

.mobile-menu-toggle:hover {
    background: rgba(59, 130, 246, 0.1);
}

/* Mobile navigation overlay */
.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

.mobile-nav-overlay.active {
    display: block;
}

/* Mobile navigation menu */
.mobile-nav {
    display: none;
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background: var(--bg-secondary);
    z-index: 999;
    transition: left 0.3s ease;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.mobile-nav.active {
    left: 0;
}

.mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.mobile-nav-header h2 {
    font-size: 1.2rem;
    color: var(--accent-blue);
}

.mobile-nav-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
}

.mobile-nav-close:hover {
    color: var(--accent-red);
}

.mobile-nav-links {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 0.5rem;
}

.mobile-nav-links .nav-btn {
    width: 100%;
    text-align: left;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-nav-links .nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--text-secondary);
}

.mobile-nav-links .nav-btn:hover .nav-icon {
    color: var(--accent-blue);
}

.mobile-nav-links .nav-btn.active .nav-icon {
    color: white;
}

.last-update {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Summary Cards */
.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1.5rem 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border-color);
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-2px);
}

.card-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.servers-online {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-green);
}

.servers-offline {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
}

.alerts-warning {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent-yellow);
}

.alerts-critical {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
}

.card-content h3 {
    font-size: 2rem;
    font-weight: 700;
}

.card-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3 columnas base para layout 2/3 + 1/3 */
    gap: 1.5rem;
    padding: 0 2rem 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.full-width {
    grid-column: 1 / -1;
}

.section h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Section Icon Styling */
.section-icon {
    font-size: 1.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8rem;
    height: 1.8rem;
    margin-right: 0.3rem;
    line-height: 1;
}

/* Infrastructure Section - Optimized Layout */
.infrastructure-section {
    grid-column: span 2; /* Ocupa 2/3 del espacio */
}

.api-credits-section {
    grid-column: span 1; /* Ocupa 1/3 del espacio */
}

.infra-count {
    font-size: 0.9rem;
    color: var(--accent-blue);
    font-weight: 600;
}

.infrastructure-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); /* Más compacto */
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.infrastructure-summary {
    padding: 0.75rem;
    background: rgba(31, 41, 55, 0.3);
    border-radius: 6px;
    margin-top: 0.5rem;
}

/* Infrastructure Summary Stats - Enhanced */
.infra-summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    font-size: 0.85rem;
    margin-top: 1rem;
    padding: 0.5rem 0;
}

.infra-stat-group {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
}

.infra-stat-group-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-color);
}

.infra-stat-row {
    display: flex;
    gap: 0.75rem;
    justify-content: space-around;
}

.infra-stat-mini {
    flex: 1;
    text-align: center;
}

.infra-stat-mini .infra-stat-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.65rem;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.infra-stat-mini .infra-stat-value {
    display: block;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .infra-summary-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .infra-summary-stats {
        grid-template-columns: 1fr;
    }

    .infra-stat-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .infra-stat-mini {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.25rem 0;
    }

    .infra-stat-mini .infra-stat-label {
        text-align: left;
        margin-bottom: 0;
    }

    .infra-stat-mini .infra-stat-value {
        text-align: right;
    }
}


/* Servers Grid - Enhanced - Compact Version */
.servers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

/* Compact Infrastructure Card */
.infra-server-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    cursor: pointer;
}

.infra-server-card:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.infra-server-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.infra-server-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.infra-server-role {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.infra-server-metrics {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.75rem;
}

.infra-metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.infra-metric-label {
    color: var(--text-secondary);
}

.infra-metric-value {
    font-family: monospace;
    font-weight: 600;
}

.infra-metric-bar {
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 2px;
}

.infra-metric-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s, background-color 0.3s;
}

/* Critical Services Section */
.services-section {
    grid-column: 1 / -1; /* Full width */
}

.services-count {
    font-size: 0.9rem;
    color: var(--accent-blue);
    font-weight: 600;
}

/* Services Header Controls */
.services-header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.services-header-controls h2 {
    margin: 0;
}

.services-search-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.services-search-input {
    width: 250px;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.services-search-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.services-search-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Services Filters */
.services-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.2rem;
}

.service-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-left-width: 4px;
    transition: all 0.3s ease;
}

.service-card.online {
    border-left-color: var(--accent-green);
}

.service-card.offline {
    border-left-color: var(--accent-red);
}

.service-card.unknown {
    border-left-color: var(--text-secondary);
    opacity: 0.85;
}

.service-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.service-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.service-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.service-status-badge {
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.service-status-badge.online {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-green);
}

.service-status-badge.offline {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
}

.service-status-badge.unknown {
    background: rgba(107, 114, 128, 0.2);
    color: var(--text-secondary);
}

.service-info {
    margin-bottom: 0.6rem;
}

.service-server {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.service-port {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.service-uptime {
    font-size: 0.85rem;
    color: var(--accent-blue);
    font-weight: 600;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

.service-uptime-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: normal;
    margin-right: 0.3rem;
}

/* Nuevos estilos para servicios mejorados */
.service-icon {
    font-size: 1.2rem;
    margin-right: 0.5rem;
}

.service-description {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
    font-style: italic;
}

.service-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.service-footer {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.docker-badge,
.native-badge,
.web-badge {
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.docker-badge {
    background: rgba(33, 150, 243, 0.2);
    color: #2196F3;
    border: 1px solid rgba(33, 150, 243, 0.3);
}

.native-badge {
    background: rgba(156, 39, 176, 0.2);
    color: #9C27B0;
    border: 1px solid rgba(156, 39, 176, 0.3);
}

.web-badge {
    background: rgba(255, 152, 0, 0.2);
    color: #FF9800;
    border: 1px solid rgba(255, 152, 0, 0.3);
}

.service-card[style*="cursor: pointer"]:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    border-left-width: 6px;
}

/* Old server card (for fallback) */
.server-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

.server-card:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.server-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.server-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.server-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.status-online {
    background: var(--accent-green);
    box-shadow: 0 0 10px var(--accent-green);
}

.status-offline {
    background: var(--accent-red);
    box-shadow: 0 0 10px var(--accent-red);
}

.status-unknown {
    background: var(--text-secondary);
}

.server-ip {
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--accent-blue);
    cursor: text;
    padding: 2px 6px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 0.5rem;
    position: relative;
    transition: all 0.2s ease;
}

.server-ip:hover {
    background: rgba(59, 130, 246, 0.2);
}

.server-ip::after {
    content: "📋 Click to copy";
    position: absolute;
    left: 50%;
    bottom: -25px;
    transform: translateX(-50%);
    background: var(--bg-primary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    border: 1px solid var(--border-color);
}

.server-ip:hover::after {
    opacity: 1;
}

.server-role {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
}

.server-specs {
    font-size: 0.8rem;
    line-height: 1.8;
}

.server-specs div {
    display: flex;
    justify-content: space-between;
}

.server-specs .label {
    color: var(--text-secondary);
}

.server-specs .value {
    color: var(--text-primary);
    font-family: monospace;
}

.server-location {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Progress Bars */
.progress-bar {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-green {
    background: var(--accent-green);
}

.progress-yellow {
    background: var(--accent-yellow);
}

.progress-red {
    background: var(--accent-red);
}

/* API Credits Section */
.api-credits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.api-credit-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-left-width: 4px;
    transition: all 0.3s ease;
}

/* Bordes de color según fuente */
.api-credit-card[data-source="manual"] {
    border-left-color: #fbbf24;  /* Amarillo */
}

.api-credit-card[data-source="api"] {
    border-left-color: #10b981;  /* Verde */
}

.api-credit-card[data-source="none"] {
    border-left-color: #6b7280;  /* Gris */
    opacity: 0.85;
}

.api-credit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.api-provider {
    font-weight: 600;
    font-size: 1rem;
}

.api-status {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-green);
}

.api-balance {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-green);
    margin-bottom: 0.5rem;
}

.api-balance.low {
    color: var(--accent-red);
}

.api-balance.good {
    color: var(--accent-green);
}

.api-balance.no-api {
    color: var(--accent-yellow);
    font-size: 1.4rem;
}

.api-balance.not-configured {
    color: var(--text-secondary);
    font-size: 1.2rem;
}

.api-balance.error {
    color: var(--accent-red);
    font-size: 1.2rem;
}

.api-status.working {
    background: rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.api-note {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    padding: 2px 0;
}

.api-note.success {
    color: var(--accent-green);
    font-weight: 600;
}

.api-note.info {
    color: var(--accent-blue);
}

.api-note.warning {
    color: var(--accent-yellow);
}

.api-note.error {
    color: var(--accent-red);
}

.api-usage {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.api-last-charge {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Emoji de interrogación para balance desconocido */
.unknown-icon {
    font-size: 3.5rem;
    opacity: 0.3;
    display: block;
    text-align: center;
    margin: 1.5rem 0;
    line-height: 1;
}

/* Variantes de api-note */
.api-note.manual {
    color: #f59e0b;  /* Naranja/Amarillo */
    font-weight: 600;
}

.api-note.small {
    font-size: 0.7rem;
    margin-top: 0.25rem;
    opacity: 0.8;
}

.balance-timestamp {
    font-style: italic;
    color: #9ca3af;
}

/* Info bloqueada (para APIs automáticas) */
.action-info.locked {
    text-align: center;
    color: #6b7280;
    font-size: 0.8rem;
    padding: 0.6rem;
    margin-top: 1rem;
    border-top: 1px solid var(--border-color);
    opacity: 0.7;
}

/* DNS Section */
.dns-section {
    grid-column: 1 / -1; /* Full width */
}

/* DNS Header Controls */
.dns-header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.dns-title-wrapper h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.dns-count {
    font-size: 0.9rem;
    color: var(--accent-blue);
    font-weight: 600;
}

.dns-search-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.dns-search-input {
    padding: 0.5rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    width: 250px;
    font-size: 0.9rem;
}

.dns-search-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

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

/* DNS Filters */
.dns-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: rgba(31, 41, 55, 0.3);
    border-radius: 8px;
}

.filter-btn {
    padding: 0.4rem 0.8rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.filter-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

.filter-count {
    font-weight: 600;
    opacity: 0.8;
}

.dns-list {
    max-height: 450px; /* Altura óptima para 44 dominios */
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem; /* Espacio para scrollbar */
}

.dns-item {
    display: flex;
    flex-direction: column;
    padding: 0.4rem 0.75rem; /* Compacto */
    background: var(--bg-card);
    border-radius: 6px;
    margin-bottom: 0.25rem; /* Muy compacto */
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    min-height: 35px; /* Altura mínima fija */
}

.dns-item:hover {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.05);
}

.dns-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

/* DNS Domain Wrapper */
.dns-domain-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

/* DNS Domain Link (clickeable) */
.dns-domain-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
    color: inherit;
    flex: 1;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.dns-domain-link:hover {
    background: rgba(59, 130, 246, 0.1);
}

.dns-domain {
    font-family: monospace;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.dns-domain-link:hover .dns-domain {
    color: #60a5fa;
}

/* Link Icon */
.link-icon {
    opacity: 0;
    font-size: 0.7rem;
    transition: opacity 0.2s;
}

.dns-item:hover .link-icon {
    opacity: 0.8;
}

/* Category Badge */
.category-badge {
    font-size: 0.85rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.dns-item:hover .category-badge {
    opacity: 1;
}

.dns-details {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.dns-info {
    text-align: right;
    font-size: 0.8rem;
}

.dns-ip {
    color: var(--accent-blue);
    font-family: monospace;
    cursor: text;
    padding: 2px 4px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.dns-ip:hover {
    background: rgba(59, 130, 246, 0.15);
}

.dns-provider {
    color: var(--text-secondary);
}

.dns-separator {
    color: var(--border-color);
}

.dns-time {
    color: var(--text-secondary);
    font-weight: 600;
}

.dns-health-status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
}

.dns-health-online {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.dns-status-ok {
    color: var(--accent-green);
}

.dns-status-warning {
    color: var(--accent-yellow);
}

.dns-status-fail {
    color: var(--accent-red);
}

/* DNS Summary Section */
.dns-summary {
    margin-top: 1rem;
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
    background: rgba(31, 41, 55, 0.3);
    border-radius: 6px;
}

.dns-summary-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.dns-summary-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dns-stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
}

.dns-stat-label {
    color: var(--text-secondary);
}

.dns-stat-value {
    color: var(--text-primary);
    font-weight: 500;
}

/* Category Stats Section */
.dns-summary-categories {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.dns-category-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.category-stat-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.6rem;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 4px;
    font-size: 0.75rem;
    border: 1px solid rgba(59, 130, 246, 0.1);
}

.category-stat-emoji {
    font-size: 0.9rem;
}

.category-stat-name {
    color: var(--text-secondary);
    flex: 1;
}

.category-stat-value {
    font-weight: 600;
    font-family: monospace;
}

/* DNS Latency Color Indicators */
.latency-excellent {
    color: #10b981 !important; /* Verde - < 20ms excelente */
    font-weight: 600;
}

.latency-good {
    color: #fbbf24 !important; /* Amarillo - 20-50ms bueno */
    font-weight: 600;
}

.latency-fair {
    color: #f97316 !important; /* Naranja - 50-100ms aceptable */
    font-weight: 600;
}

.latency-poor {
    color: #ef4444 !important; /* Rojo - > 100ms lento */
    font-weight: 600;
}

/* DNS Item Animation */
.dns-item {
    animation: fadeInUp 0.3s ease-out;
    animation-fill-mode: backwards;
}

.dns-item:nth-child(1) { animation-delay: 0.05s; }
.dns-item:nth-child(2) { animation-delay: 0.1s; }
.dns-item:nth-child(3) { animation-delay: 0.15s; }
.dns-item:nth-child(4) { animation-delay: 0.2s; }
.dns-item:nth-child(5) { animation-delay: 0.25s; }
.dns-item:nth-child(6) { animation-delay: 0.3s; }
.dns-item:nth-child(7) { animation-delay: 0.35s; }
.dns-item:nth-child(8) { animation-delay: 0.4s; }

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

/* Alerts */
.alerts-container {
    max-height: 300px;
    overflow-y: auto;
}

/* Enhanced Alerts Section */
.alerts-section {
    min-height: 300px; /* Expandir tamaño */
}

.alerts-badge {
    font-size: 0.85rem;
    color: var(--accent-blue);
    font-weight: 600;
}

.alerts-container {
    max-height: 500px;
    overflow-y: auto;
}

.alert-item {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    border-left: 5px solid;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    transition: all 0.2s;
}

.alert-item:hover {
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.alert-critical {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(239, 68, 68, 0.05) 100%);
    border-color: var(--accent-red);
}

.alert-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(245, 158, 11, 0.05) 100%);
    border-color: var(--accent-yellow);
}

.alert-info {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0.05) 100%);
    border-color: var(--accent-blue);
}

.alert-content {
    flex: 1;
}

.alert-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.alert-icon {
    font-size: 1.2rem;
    font-weight: bold;
}

.alert-server {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.alert-message {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.alert-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.alert-time, .alert-type {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.alert-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.alert-actions .btn {
    white-space: nowrap;
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
}

.btn-xs {
    font-size: 0.7rem;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-xs:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

/* Knowledge Base */
.kb-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.kb-stat {
    text-align: center;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 8px;
}

.kb-stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-purple);
}

.kb-stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* SaaS Metering Widget */
.saas-metering-section {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, #1a2744 100%);
}

.saas-metering-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.metering-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.metering-stat {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.metering-stat:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.metering-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metering-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.metering-mrr {
    color: var(--accent-green);
}

.metering-chart-mini {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 60px;
    padding: 0.5rem;
    background: var(--bg-card);
    border-radius: 8px;
    gap: 4px;
}

.chart-bar {
    flex: 1;
    background: var(--accent-blue);
    border-radius: 3px 3px 0 0;
    height: var(--height, 50%);
    opacity: 0.6;
    transition: all 0.2s;
    cursor: pointer;
}

.chart-bar:hover {
    opacity: 1;
    transform: scaleY(1.05);
}

.chart-bar.active {
    background: var(--accent-green);
    opacity: 1;
}

.metering-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.metering-actions .btn {
    flex: 1;
    text-align: center;
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
}

/* Responsive metering widget */
@media (max-width: 768px) {
    .metering-stats {
        grid-template-columns: 1fr;
    }

    .metering-value {
        font-size: 1.2rem;
    }

    .metering-actions {
        flex-direction: column;
    }

    .metering-chart-mini {
        min-height: 50px;
    }
}

@media (max-width: 480px) {
    .saas-metering-section {
        padding: 15px;
    }

    .saas-metering-section h2 {
        font-size: 1rem;
    }

    .metering-stat {
        padding: 10px;
    }

    .metering-label {
        font-size: 0.7rem;
    }

    .metering-value {
        font-size: 1rem;
    }

    .metering-chart-mini {
        min-height: 40px;
        padding: 8px;
    }

    .chart-bar {
        border-radius: 2px;
    }

    .metering-actions .btn {
        padding: 8px 12px;
        font-size: 0.75rem;
    }
}

/* Quick Actions */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.8rem;
}

.action-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.action-btn:hover {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
}

.modal-content {
    background: var(--bg-secondary);
    margin: 5% auto;
    padding: 0;
    width: 80%;
    max-width: 800px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--accent-red);
}

.modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

/* Footer */
.footer {
    background: var(--bg-secondary);
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .content-grid {
        grid-template-columns: 1fr;
    }

    .servers-grid {
        grid-template-columns: 1fr;
    }

    .kb-stats {
        grid-template-columns: 1fr;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-secondary);
    border-radius: 50%;
    border-top-color: var(--accent-blue);
    animation: spin 1s linear infinite;
}

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

/* Copy Notification */
.copy-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--accent-green);
    color: white;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    animation: fadeInOut 2s forwards;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(20px); }
    20% { opacity: 1; transform: translateY(0); }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* ========== BALANCE MANAGEMENT STYLES ========== */

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
}

/* Balance Modal */
.balance-modal-content {
    position: relative;
    z-index: 1000;
    max-width: 500px;
    margin: 80px auto;
}

/* Platform Badge */
.platform-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* Form Groups */
.form-group {
    margin-bottom: 1.5rem;
}

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

/* Input Wrapper */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-prefix {
    position: absolute;
    left: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-green);
    pointer-events: none;
}

.input-wrapper input {
    flex: 1;
    padding: 0.8rem 1rem 0.8rem 2.2rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Help Text */
.help-text {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.help-text a {
    color: var(--accent-blue);
    text-decoration: none;
}

.help-text a:hover {
    text-decoration: underline;
}

/* Source Indicator */
.source-indicator {
    padding: 0.8rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 3px solid var(--accent-yellow);
}

.badge {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-manual {
    background: rgba(251, 191, 36, 0.2);
    color: var(--accent-yellow);
}

.source-indicator small {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Current Balance Info */
.current-balance {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

#currentBalanceValue {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-green);
}

.timestamp {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-primary);
}

/* Section Divider */
.section-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2rem 0;
}

/* Danger Zone */
.danger-zone {
    padding: 1rem;
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
}

.danger-zone h3 {
    color: var(--accent-red);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.danger-zone p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.btn-danger {
    background: var(--accent-red);
    color: white;
    border: none;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* API Credit Card States */
.api-balance.unknown {
    color: var(--text-secondary);
    font-style: italic;
}

.api-balance.critical {
    color: var(--accent-red);
    animation: pulse-critical 2s ease-in-out infinite;
}

@keyframes pulse-critical {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Small Buttons in Cards */
.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    margin-top: 0.8rem;
    width: 100%;
}

.btn-add {
    background: linear-gradient(135deg, var(--accent-green), #059669);
    color: white;
    border: none;
}

.btn-add:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-edit {
    background: linear-gradient(135deg, var(--accent-blue), #2563eb);
    color: white;
    border: none;
}

.btn-edit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* API Note Variations */
.api-note.info {
    color: var(--accent-blue);
}

.api-note.manual {
    color: var(--accent-yellow);
}

.api-note.success {
    color: var(--accent-green);
}

.api-note.small {
    font-size: 0.8rem;
    margin-top: 0.3rem;
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-weight: 500;
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.3s ease;
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-icon {
    font-size: 1.2rem;
    font-weight: 700;
}

.toast-success {
    background: var(--accent-green);
    color: white;
}

.toast-error {
    background: var(--accent-red);
    color: white;
}

.toast-info {
    background: var(--accent-blue);
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .balance-modal-content {
        margin: 20px;
        max-width: calc(100% - 40px);
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions button {
        width: 100%;
    }

    .toast-notification {
        right: 10px;
        left: 10px;
        top: 10px;
    }
}

/* ========== ENHANCED ALERTS STYLES ========== */

/* Alert Item Layout */
.alert-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 0.8rem;
    border-radius: 8px;
    border-left: 4px solid;
}

.alert-content {
    flex: 1;
}

/* Alert Source Badge */
.alert-source {
    display: inline-block;
    margin-top: 0.4rem;
    padding: 0.2rem 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Alert Actions */
.alert-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 140px;
}

/* Extra Small Buttons */
.btn-xs {
    padding: 0.4rem 0.7rem;
    font-size: 0.75rem;
    white-space: nowrap;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-xs.btn-primary {
    background: var(--accent-blue);
    color: white;
}

.btn-xs.btn-primary:hover {
    background: #2563eb;
}

.btn-xs.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-xs.btn-secondary:hover {
    background: var(--bg-primary);
}

/* ============================================
   RESPONSIVE DESIGN - MOBILE & TABLET
   ============================================ */

/* Pantallas grandes (> 1200px) - Layout optimizado 2/3 + 1/3 */
@media (min-width: 1200px) {
    .infrastructure-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); /* Mejor distribución en pantallas grandes */
    }

    .api-credits-grid {
        grid-template-columns: 1fr; /* API Credits en columna vertical en sidebar */
    }
}

/* Tablets y pantallas medianas (768px - 1024px) */
@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr; /* Una sola columna */
        gap: 1rem;
    }

    /* Secciones de layout optimizado - apiladas verticalmente en tablets */
    .infrastructure-section,
    .api-credits-section {
        grid-column: span 1; /* Ocupa toda la columna disponible */
    }

    .infrastructure-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .api-credits-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); /* Más espacio en tablets */
    }

    .services-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .dns-summary-stats {
        grid-template-columns: 1fr; /* Una columna en tablets */
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
}

/* Móviles (< 768px) */
@media (max-width: 768px) {
    /* Header ajustado para móvil - HAMBURGER A LA IZQUIERDA */
    .header,
    .main-header {
        flex-direction: row !important;
        justify-content: flex-start !important;
        padding: 0.75rem 1rem !important;
    }

    .logo h1 {
        font-size: 1.3rem;
    }

    .version {
        font-size: 0.7rem;
    }

    .subtitle {
        font-size: 0.7rem;
    }

    /* Hide desktop nav, show hamburger */
    .nav-links {
        display: none !important;
    }

    .mobile-menu-toggle {
        display: block !important;
        order: -1 !important;
        margin-right: 8px !important;
    }

    .mobile-nav {
        display: flex;
    }

    .logo-section {
        flex: 0 0 auto !important;
        justify-content: flex-start !important;
        gap: 8px !important;
    }

    .header-actions {
        flex: 0 0 auto !important;
        margin-left: auto !important;
        gap: 0.5rem;
    }

    /* Hide search and last-update on mobile header */
    .main-header .search-input,
    .main-header .last-update {
        display: none;
    }

    .main-header .header-actions {
        flex-direction: row;
        width: auto;
    }

    .search-input {
        width: 100%;
        font-size: 0.9rem;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    /* Summary cards - 2 columnas en móvil */
    .summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        padding: 1rem;
    }

    .card {
        padding: 0.75rem;
    }

    .card-icon {
        font-size: 1.5rem;
    }

    .card-content h3 {
        font-size: 1.2rem;
    }

    .card-content p {
        font-size: 0.75rem;
    }

    /* Content grid - una columna */
    .content-grid {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 1rem;
    }

    /* Secciones de layout optimizado - apiladas verticalmente en móviles */
    .infrastructure-section,
    .api-credits-section {
        grid-column: span 1; /* Ocupa toda la columna disponible */
    }

    /* Infrastructure grid más compacto en móvil */
    .infrastructure-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    /* API Credits más compacto en móvil */
    .api-credits-grid {
        grid-template-columns: 1fr; /* Una sola columna en móvil */
    }

    /* Sections */
    .section {
        padding: 1rem;
    }

    .section h2 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }

    /* Infrastructure grid - 2 columnas en móvil */
    .infrastructure-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .infra-server-card {
        padding: 0.5rem;
    }

    .infra-server-name {
        font-size: 0.85rem;
    }

    .infra-server-role {
        font-size: 0.65rem;
    }

    .infra-metric-label,
    .infra-metric-value {
        font-size: 0.7rem;
    }

    /* Services grid - una columna en móvil */
    .services-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .service-card {
        padding: 0.75rem;
    }

    .service-name {
        font-size: 0.9rem;
    }

    .service-status-badge {
        font-size: 0.65rem;
        padding: 2px 8px;
    }

    /* API Credits - ajustado */
    .api-credits-grid {
        gap: 0.75rem;
    }

    .api-credit-card {
        padding: 0.75rem;
    }

    .platform-name {
        font-size: 0.9rem;
    }

    .balance-amount {
        font-size: 1.1rem;
    }

    /* DNS Section */
    .dns-header-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .dns-search-wrapper {
        flex-direction: column;
        width: 100%;
    }

    .dns-search-input {
        width: 100%;
    }

    /* Services Section */
    .services-header-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .services-search-wrapper {
        flex-direction: column;
        width: 100%;
    }

    .services-search-input {
        width: 100%;
    }

    .dns-filters {
        flex-direction: column;
        gap: 0.5rem;
    }

    .filter-btn {
        width: 100%;
        text-align: center;
    }

    .dns-list {
        max-height: 300px; /* Reducir altura en móvil */
    }

    .dns-item {
        padding: 0.5rem;
    }

    .dns-domain {
        font-size: 0.75rem;
    }

    .dns-time {
        font-size: 0.75rem;
    }

    .dns-details {
        font-size: 0.7rem;
        gap: 0.3rem;
    }

    .dns-summary-stats {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .dns-category-stats {
        grid-template-columns: 1fr;
    }

    /* Alerts */
    .alert-item {
        flex-direction: column;
        padding: 0.75rem;
    }

    .alert-actions {
        width: 100%;
        flex-direction: row;
        gap: 0.5rem;
    }

    .alert-actions .btn-xs {
        flex: 1;
        font-size: 0.7rem;
    }

    .alert-message {
        font-size: 0.85rem;
    }

    /* KB Stats */
    .kb-stats {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    /* Actions grid */
    .actions-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .action-btn {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    /* Modals en móvil */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 1rem;
        max-height: 90vh;
    }

    .modal-body {
        max-height: 60vh;
        padding: 1rem;
    }

    /* Footer */
    .footer {
        padding: 1rem;
        font-size: 0.75rem;
    }

    /* Toast notifications - más grande en móvil */
    .toast-notification {
        min-width: 280px;
        max-width: 90%;
        font-size: 0.9rem;
        padding: 1rem;
    }

    /* Balance modal en móvil */
    .balance-modal-content {
        width: 95%;
        padding: 1rem;
    }

    .form-group input {
        font-size: 1rem; /* Evitar zoom en iOS */
    }

    /* Server detail modal */
    .server-detail-grid {
        grid-template-columns: 1fr;
    }

    /* Infra summary stats */
    .infra-summary-stats {
        flex-direction: column;
        gap: 0.5rem;
    }

    .infra-stat {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem;
        background: rgba(31, 41, 55, 0.3);
        border-radius: 4px;
    }
}

/* Móviles pequeños (< 480px) */
@media (max-width: 480px) {
    /* Summary cards - una columna en móviles pequeños */
    .summary {
        grid-template-columns: 1fr;
    }

    /* Infrastructure - una columna */
    .infrastructure-grid {
        grid-template-columns: 1fr;
    }

    /* Reducir padding general */
    .dashboard {
        padding: 0.5rem;
    }

    .section {
        padding: 0.75rem;
    }

    /* Títulos más pequeños */
    .logo h1 {
        font-size: 1.2rem;
    }

    .section h2 {
        font-size: 0.95rem;
    }

    /* DNS filters - más compactos */
    .filter-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }

    /* Ocultar elementos secundarios en pantallas muy pequeñas */
    .dns-separator {
        display: none;
    }

    .category-badge {
        font-size: 0.75rem;
    }

    /* Botones más touch-friendly */
    .btn,
    .action-btn,
    .filter-btn {
        min-height: 44px; /* Tamaño mínimo recomendado para touch */
    }
}

/* Landscape móvil (orientación horizontal) */
@media (max-width: 768px) and (orientation: landscape) {
    .summary {
        grid-template-columns: repeat(4, 1fr);
    }

    .infrastructure-grid {
        grid-template-columns: repeat(3, 1fr);
    }

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

    .dns-list {
        max-height: 200px;
    }
}

/* Pantallas grandes (> 1440px) */
@media (min-width: 1440px) {
    .dashboard {
        max-width: 1600px;
        margin: 0 auto;
    }

    .infrastructure-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .services-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }

    .dns-summary-stats {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Server Filters - New Styles */
.dns-filters-servers {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.filter-section-label {
    display: inline-block;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 10px;
    margin-bottom: 8px;
}

.filter-btn-server {
    background: linear-gradient(135deg, var(--bg-card) 0%, #2d3a4f 100%);
    border: 1px solid var(--border-color);
}

.filter-btn-server:hover {
    background: linear-gradient(135deg, #3d4a5f 0%, #4d5a6f 100%);
    border-color: var(--accent-blue);
    transform: translateY(-1px);
}

.filter-btn-server.active {
    background: linear-gradient(135deg, var(--accent-blue) 0%, #2563eb 100%);
    border-color: var(--accent-blue);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
}

/* FIX: Hamburger menu always visible and clickable */
.mobile-menu-toggle {
    position: relative !important;
    z-index: 1001 !important;
}

.main-header {
    z-index: 1000 !important;
}

.mobile-nav-overlay:not(.active) {
    display: none !important;
    pointer-events: none !important;
    opacity: 0 !important;
}

.mobile-nav-overlay.active {
    display: block !important;
    pointer-events: auto !important;
    z-index: 999 !important;
}

.mobile-nav.active {
    display: flex !important;
    z-index: 1000 !important;
}

/* Ensure hamburger is always on the left */
@media (max-width: 768px) {
    .logo-section {
        flex-direction: row !important;
        order: -1 !important;
    }
    
    .mobile-menu-toggle {
        order: -1 !important;
        margin-right: 10px !important;
    }
}
