/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-weight: 400;
    line-height: 1.5;
    color: #1a1a1a;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    min-height: 100vh;
    overflow: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-container {
    text-align: center;
    max-width: 520px;
    width: 90%;
    padding: 2.5rem;
}

/* Logo */
.logo-container {
    margin-bottom: 1.5rem;
}

.logo {
    color: white;
}

.logo-icon {
    margin-bottom: 1.5rem;
    animation: logoFloat 4s ease-in-out infinite;
}

.logo-icon svg {
    color: #60a5fa;
    filter: drop-shadow(0 4px 12px rgba(96, 165, 250, 0.3));
}

.logo h1 {
    font-size: 2.8rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin: 0 0 0.5rem 0;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.logo-subtitle {
    font-size: 1.1rem;
    font-weight: 300;
    color: #cbd5e1;
    margin: 0;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-family: monospace;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-8px) rotate(1deg); }
    75% { transform: translateY(-4px) rotate(-1deg); }
}

/* Loading Animation */
.loading-animation {
    margin: 1rem 0;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(96, 165, 250, 0.2);
    border-top: 3px solid #60a5fa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.3);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Status Container */
.status-container {
    margin-top: 0.5rem;
    height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.status-text {
    color: #e2e8f0;
    font-size: 1rem;
    font-weight: 400;
    margin-bottom: 1rem;
    min-height: 1.5rem;
    font-family: monospace;
    letter-spacing: 0.3px;
    opacity: 0.95;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(96, 165, 250, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
    border: 1px solid rgba(96, 165, 250, 0.2);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #60a5fa, #3b82f6, #2563eb);
    border-radius: 4px;
    transition: width 0.4s ease;
    width: 0%;
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.4);
}

/* Retry Container */
.retry-container {
    margin: 1rem 0;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.retry-container.hidden {
    opacity: 0;
    pointer-events: none;
    height: 0;
    overflow: hidden;
}

.error-message {
    background: rgba(239, 68, 68, 0.08);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    color: white;
    position: relative;
}

.error-icon {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
}

.error-icon svg {
    color: #f87171;
    filter: drop-shadow(0 2px 8px rgba(248, 113, 113, 0.3));
}

.error-message h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    color: #fecaca;
    text-align: center;
}

.error-message p {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
    text-align: center;
}

.error-details {
    font-size: 0.85rem !important;
    opacity: 0.75 !important;
    font-family: monospace;
}

.error-details code {
    background: rgba(15, 23, 42, 0.6);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #60a5fa;
    border: 1px solid rgba(96, 165, 250, 0.2);
}

/* Retry Button */
.retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.25);
    backdrop-filter: blur(8px);
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(59, 130, 246, 0.35);
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.retry-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.25);
}

.retry-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.retry-icon {
    animation: retryRotate 0.6s ease;
}

@keyframes retryRotate {
    from { transform: rotate(-180deg); }
    to { transform: rotate(0deg); }
}

/* Main Dashboard */
.main-dashboard {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f8fafc;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease 0.2s;
    z-index: 100;
    overflow-y: auto;
}

.main-dashboard.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Header */
.dashboard-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 200;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo svg {
    color: #60a5fa;
    filter: drop-shadow(0 2px 8px rgba(96, 165, 250, 0.3));
}

.header-title h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: white;
}

.header-subtitle {
    font-size: 0.875rem;
    color: #cbd5e1;
    font-family: monospace;
    letter-spacing: 0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse 2s infinite;
}

.status-indicator.online .status-dot {
    background: #22c55e;
}

.status-indicator.offline .status-dot {
    background: #ef4444;
}

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

.last-update {
    font-size: 0.875rem;
    color: #cbd5e1;
    font-family: monospace;
}

/* Main Content */
.dashboard-main {
    flex: 1;
    background: #f8fafc;
    min-height: calc(100vh - 80px);
}

.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Overview Stats */
.overview-section {
    margin-bottom: 3rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.stat-content {
    flex: 1;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: #1f2937;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

/* Nodes Section */
.nodes-section {
    margin-bottom: 3rem;
}

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

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.section-actions {
    display: flex;
    gap: 1rem;
}

.refresh-btn {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.refresh-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35);
}

.refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: linear-gradient(135deg, #9ca3af, #6b7280);
    box-shadow: 0 2px 8px rgba(107, 114, 128, 0.2);
}

.nodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
}

/* Node Cards */
.node-card {
    background: white;
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.node-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

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

.node-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.node-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.node-status.online {
    background: #22c55e;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.4);
}

.node-status.offline {
    background: #ef4444;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

.node-status .status-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: inherit;
    opacity: 0.3;
    animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
    75%, 100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

.node-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.node-details h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 0.25rem 0;
    flex: 1;
}

.node-actions {
    display: flex;
    gap: 0.25rem;
}

.node-settings-btn,
.node-semantic-btn,
.node-charts-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.node-semantic-btn {
    color: #10b981;
}

.node-charts-btn {
    color: #3b82f6;
}

.node-settings-btn:hover,
.node-semantic-btn:hover,
.node-charts-btn:hover {
    background: #f3f4f6;
}

.node-settings-btn:hover {
    color: #6b7280;
}

.node-semantic-btn:hover {
    color: #059669;
}

.node-charts-btn:hover {
    color: #2563eb;
}

.node-settings-btn:active,
.node-semantic-btn:active,
.node-charts-btn:active {
    background: #e5e7eb;
}

.node-location {
    font-size: 0.875rem;
    color: #6b7280;
    font-family: monospace;
    margin: 0;
}

.node-error {
    font-size: 0.75rem;
    color: #f87171;
    font-style: italic;
    margin: 0.25rem 0 0 0;
}

.node-actions {
    display: flex;
    gap: 0.5rem;
}

.node-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.node-action-btn:hover {
    background: #f3f4f6;
    color: #374151;
    border-color: #d1d5db;
}

/* Node Stats */
.node-stats {
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stats-group {
    display: flex;
    justify-content: space-around;
    padding: 0.75rem;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.climate-group,
.pm-group,
.co2-group,
.other-sensors-group {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.co2-group {
    justify-content: center;
}

.other-sensors-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 0.75rem;
    padding: 1rem;
}

@media (max-width: 480px) {
    .other-sensors-group {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(6, 1fr);
    }
}

.no-other-sensors {
    text-align: center;
    color: #6b7280;
    font-style: italic;
    padding: 1rem;
}

.other-sensor-display {
    text-align: center;
    flex: 1;
}

.other-sensor-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
    color: #4338ca;
}

/* High-contrast sensor values for 4th group */
.other-sensor-display:nth-child(1) .other-sensor-value { color: #7c3aed; } /* Strong Purple */
.other-sensor-display:nth-child(2) .other-sensor-value { color: #0891b2; } /* Strong Cyan */
.other-sensor-display:nth-child(3) .other-sensor-value { color: #be185d; } /* Strong Pink */
.other-sensor-display:nth-child(4) .other-sensor-value { color: #0d9488; } /* Strong Teal */
.other-sensor-display:nth-child(5) .other-sensor-value { color: #854d0e; } /* Strong Brown */
.other-sensor-display:nth-child(6) .other-sensor-value { color: #1e40af; } /* Strong Indigo */

.other-sensor-label {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.other-sensor-display.sensor-inactive .other-sensor-value {
    color: #9ca3af;
}

.other-sensor-display.sensor-inactive .other-sensor-label {
    color: #9ca3af;
}

.temp-display, .humidity-display, .pm25-display, .pm10-display, .co2-display {
    text-align: center;
    flex: 1;
}

.temp-value, .humidity-value, .pm25-value, .pm10-value, .co2-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.temp-value {
    color: #dc2626; /* Strong Red */
}

.humidity-value {
    color: #2563eb; /* Strong Blue */
}

.pm25-value {
    color: #ea580c; /* Strong Orange */
}

.pm10-value {
    color: #d97706; /* Strong Amber */
}

.co2-value {
    color: #059669; /* Strong Green */
}

.temp-label, .humidity-label, .pm25-label, .pm10-label, .co2-label {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Sensor Items */

.sensor-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.sensor-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.sensor-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1f2937;
    font-family: monospace;
}

/* Sensor Status Classes */
.sensor-item.sensor-active {
    background: #ecfdf5;
    border-color: #bbf7d0;
}

.sensor-item.sensor-active .sensor-name {
    color: #065f46;
}

.sensor-item.sensor-active .sensor-value {
    color: #047857;
}

.sensor-item.sensor-inactive {
    background: #f9fafb;
    border-color: #e5e7eb;
    opacity: 0.7;
}

.sensor-item.sensor-inactive .sensor-name {
    color: #9ca3af;
}

.sensor-item.sensor-inactive .sensor-value {
    color: #6b7280;
}

/* Node Footer */
.node-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.last-reading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #9ca3af;
    font-family: monospace;
}

.last-seen-label {
    font-weight: 500;
    color: #6b7280;
}

.semantic-info {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 0.3rem;
    border: 1px solid rgba(16, 185, 129, 0.2);
    cursor: help;
}

.error-info {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 0.3rem;
    border: 1px solid rgba(239, 68, 68, 0.2);
    cursor: help;
}
}

.last-reading svg {
    opacity: 0.6;
}

/* Status Card */
.status-card {
    grid-column: 1 / -1;
    background: white;
    border-radius: 20px;
    padding: 3rem 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.status-icon {
    margin-bottom: 2rem;
    color: #9ca3af;
}

.status-content h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 1rem 0;
}

.status-content p {
    color: #6b7280;
    margin: 0 0 1rem 0;
    line-height: 1.6;
}

.status-help {
    font-weight: 500 !important;
    color: #374151 !important;
    margin-top: 1.5rem !important;
}

.status-content code {
    display: block;
    background: #f3f4f6;
    color: #1f2937;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.875rem;
    margin: 1rem 0 2rem 0;
    border: 1px solid #e5e7eb;
}

.status-refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.status-refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35);
}

.status-refresh-btn svg {
    transition: transform 0.3s ease;
}

.status-refresh-btn:hover svg {
    transform: rotate(-180deg);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .loading-container {
        padding: 1.5rem;
        max-width: 95%;
    }

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

    .logo-subtitle {
        font-size: 0.95rem;
    }

    .spinner {
        width: 56px;
        height: 56px;
    }

    .status-text {
        font-size: 0.9rem;
    }

    .error-message {
        padding: 1.5rem;
    }

    .error-message h3 {
        font-size: 1.1rem;
    }

    .retry-btn {
        padding: 0.875rem 1.5rem;
        font-size: 0.9rem;
        gap: 0.5rem;
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 600px;
    max-height: 80vh;
    width: 90vw;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.download-csv-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.download-csv-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.download-csv-btn:active {
    transform: translateY(0);
}

.download-csv-btn svg {
    flex-shrink: 0;
}

.download-csv-btn:disabled {
    background: #93c5fd;
    cursor: not-allowed;
    transform: none;
}

.download-csv-btn:disabled:hover {
    background: #93c5fd;
    transform: none;
    box-shadow: none;
}

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

.spinning {
    animation: spin 1s linear infinite;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: #6b7280;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #e5e7eb;
    color: #374151;
}

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

/* Device Configuration Modal Styles */
.config-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 1rem;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.config-loading p {
    margin: 0;
    color: #6b7280;
    font-size: 0.875rem;
}

.config-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    gap: 1rem;
}

.config-error .error-icon {
    color: #ef4444;
}

.config-error h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
}

.config-error p {
    margin: 0;
    color: #6b7280;
    font-size: 0.875rem;
}

.config-container {
    padding: 0;
}

.config-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
}

.config-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-indicator.active {
    color: #059669;
}

.status-indicator.active svg {
    color: #10b981;
}

.status-indicator.expired {
    color: #dc2626;
}

.status-indicator.expired svg {
    color: #ef4444;
}

.config-timestamp {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #64748b;
    font-family: monospace;
}

.config-timestamp svg {
    flex-shrink: 0;
}

.config-params-list {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.config-category {
    background: white;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.category-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: relative;
}

.category-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.category-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    flex: 1;
}

.category-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    backdrop-filter: blur(10px);
}

.category-params {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.config-param {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.config-param:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.param-main {
    padding: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.param-info {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
}

.param-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    color: #64748b;
}

.param-details {
    flex: 1;
    min-width: 0;
}

.param-name {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    line-height: 1.4;
}

.param-description {
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.4;
    margin: 0;
}

.param-value-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    min-width: 0;
}

.param-value {
    font-family: monospace;
    font-weight: 600;
    font-size: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: white;
    white-space: nowrap;
    line-height: 1;
}

.param-value.numeric {
    color: #3b82f6;
    background: #eff6ff;
    border-color: #dbeafe;
}

.param-value.positive {
    color: #059669;
    background: #ecfdf5;
    border-color: #bbf7d0;
}

.param-value.negative,
.param-value.warning {
    color: #dc2626;
    background: #fef2f2;
    border-color: #fecaca;
}

.param-value.text {
    color: #7c2d12;
    background: #fefbf3;
    border-color: #fed7aa;
}

.param-value.object {
    color: #7c3aed;
    background: #f5f3ff;
    border-color: #ddd6fe;
}

.param-value.location {
    color: #059669;
    background: #ecfdf5;
    border-color: #bbf7d0;
}

.param-unit {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
}

.param-additional {
    padding: 0 1.25rem 1.25rem;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
}

.param-additional code {
    background: #1e293b;
    color: #f1f5f9;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: monospace;
}

.sensor-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.sensor-tag {
    background: #059669;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 500;
}

.no-sensors {
    color: #dc2626;
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

.json-display {
    background: #1e293b;
    color: #f1f5f9;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.75rem;
    line-height: 1.4;
    overflow-x: auto;
    margin-top: 0.75rem;
    font-family: monospace;
}

.config-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    gap: 1.5rem;
}

.empty-icon {
    color: #94a3b8;
    opacity: 0.7;
}

.config-empty h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
}

.config-empty p {
    margin: 0;
    color: #64748b;
    font-size: 0.875rem;
    max-width: 300px;
    line-height: 1.5;
}

/* Location Display Styles */
.location-display {
    width: 100%;
}

.location-map-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.location-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: white;
}

.location-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.location-info h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.location-coords {
    margin: 0.25rem 0 0 0;
    font-size: 0.875rem;
    opacity: 0.9;
    font-family: monospace;
}

.location-map {
    height: 200px;
    width: 100%;
    background: #f8fafc;
}

.location-fallback {
    padding: 1.25rem;
    text-align: center;
    background: #f8fafc;
}

.location-fallback.hidden {
    display: none;
}

.fallback-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #64748b;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.fallback-message svg {
    color: #f59e0b;
}

.location-coordinates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.coord-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.coord-label {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.coord-value {
    font-size: 1rem;
    font-weight: 600;
    color: #059669;
    font-family: monospace;
}

/* Responsive adjustments for location display */
@media (max-width: 640px) {
    .location-coordinates {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .location-map {
        height: 150px;
    }

    .location-header {
        padding: 0.875rem 1rem;
    }

    .location-icon {
        width: 36px;
        height: 36px;
    }
}

/* Semantic Descriptor Modal Styles */
.semantic-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.semantic-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.semantic-content.no-tabs {
    padding: 1.5rem;
}

.semantic-json {
    background: #1e293b;
    color: #f1f5f9;
    padding: 1.5rem;
    border-radius: 8px;
    font-size: 0.875rem;
    line-height: 1.6;
    overflow-x: auto;
    font-family: monospace;
    margin: 0;
}

/* Charts Modal Styles */
.charts-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    padding: 1.5rem;
    width: 100%;
}

.chart-wrapper {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chart-wrapper:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

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

.chart-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 20px;
    border-radius: 2px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.chart-reset-btn {
    padding: 0.5rem;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-reset-btn:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
    color: #374151;
}

.chart-reset-btn:active {
    transform: scale(0.95);
}

.chart-reset-btn svg {
    display: block;
}

.sensor-chart {
    width: 100%;
    height: 250px !important;
    display: block;
}

/* View Controls */
.charts-view-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 0 1.5rem;
    border-bottom: 2px solid #f3f4f6;
}

.view-tabs {
    display: flex;
    gap: 0.5rem;
}

.view-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.2s ease;
    margin-bottom: -2px;
}

.view-tab:hover {
    color: #374151;
    background: #f9fafb;
}

.view-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.view-tab svg {
    width: 16px;
    height: 16px;
}

/* Time Range Selector */
.time-range-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: -2px;
}

.time-range-selector label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
}

.time-range-selector label svg {
    width: 14px;
    height: 14px;
    color: #667eea;
}

.time-range-dropdown {
    padding: 0.5rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.time-range-dropdown:hover {
    border-color: #667eea;
}

.time-range-dropdown:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Analytics Container */
.analytics-container {
    padding: 1.5rem;
    width: 100%;
}

.analytics-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.analytics-section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 1.5rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e5e7eb;
}

.analytics-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.analytics-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.analytics-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #f3f4f6;
}

.analytics-card-header h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
}

.analytics-trend {
    font-size: 1.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    background: #f3f4f6;
}

.analytics-trend.trend-up {
    color: #10b981;
    background: #d1fae5;
}

.analytics-trend.trend-down {
    color: #ef4444;
    background: #fee2e2;
}

.analytics-trend.trend-stable {
    color: #6b7280;
    background: #f3f4f6;
}

.analytics-metrics {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.metric-row:last-child {
    border-bottom: none;
}

.metric-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #6b7280;
}

.metric-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Consolas', monospace;
}

/* Table Container */
.table-container {
    padding: 1.5rem;
    width: 100%;
}

.table-wrapper {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 2px solid #f3f4f6;
    background: #fafafa;
}

.table-info {
    font-size: 0.9rem;
    font-weight: 500;
    color: #6b7280;
}

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

.table-search {
    padding: 0.5rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s ease;
    min-width: 250px;
}

.table-search:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.table-scroll {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f9fafb;
}

.data-table thead th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}

.data-table tbody tr {
    transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
    background-color: #f9fafb;
}

.data-table tbody tr:nth-child(even) {
    background-color: #fafbfc;
}

.data-table tbody tr:nth-child(even):hover {
    background-color: #f3f4f6;
}

.data-table tbody td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    color: #1e293b;
}

.data-table .row-number {
    font-weight: 600;
    color: #6b7280;
    text-align: center;
    width: 60px;
}

.data-table .timestamp {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    color: #6b7280;
    min-width: 180px;
    white-space: nowrap;
}

.data-table .sensor-value {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Consolas', monospace;
    font-weight: 500;
    text-align: right;
    min-width: 100px;
}

.table-empty {
    padding: 3rem;
    text-align: center;
    color: #6b7280;
    font-size: 1rem;
}

/* Make modal content area wider for charts */
.charts-container ~ .modal-content {
    max-width: 95vw !important;
}

/* Responsive modal */
@media (max-width: 640px) {
    .modal-content {
        width: 95vw;
        max-height: 90vh;
    }

    .modal-header {
        padding: 1rem;
    }

    .config-container {
        padding: 1rem;
    }

    .param-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .param-value {
        align-self: stretch;
        text-align: center;
    }

    .semantic-content.no-tabs {
        padding: 1rem;
    }

    .charts-container {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 1rem;
    }

    .sensor-chart {
        height: 200px !important;
    }

    .charts-view-controls {
        padding: 0 1rem;
        flex-wrap: wrap;
    }

    .view-tabs {
        flex: 1;
    }

    .view-tab {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .time-range-selector {
        flex-basis: 100%;
        justify-content: flex-end;
        padding-bottom: 0.5rem;
    }

    .time-range-dropdown {
        font-size: 0.8125rem;
        padding: 0.375rem 0.625rem;
    }

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

    .analytics-container {
        padding: 1rem;
    }

    .table-container {
        padding: 1rem;
    }

    .table-controls {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    .table-search {
        min-width: 100%;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table thead th,
    .data-table tbody td {
        padding: 0.5rem;
    }

    .data-table .timestamp {
        font-size: 0.75rem;
        min-width: 140px;
        white-space: nowrap;
    }
}

/* ===================================
   COMPREHENSIVE RESPONSIVE DESIGN
   =================================== */

/* Tablet Styles (768px - 1024px) */
@media (max-width: 1024px) {
    /* Header adjustments */
    .dashboard-header {
        padding: 0.875rem 0;
    }

    .header-content {
        padding: 0 1.5rem;
    }

    .header-title h1 {
        font-size: 1.25rem;
    }

    .header-subtitle {
        font-size: 0.75rem;
    }

    .header-logo svg {
        width: 28px;
        height: 28px;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1.25rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .stat-icon {
        font-size: 1.75rem;
    }

    .stat-number {
        font-size: 1.75rem;
    }

    /* Nodes grid */
    .nodes-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 1.5rem;
    }

    .node-card {
        padding: 1.25rem;
    }

    /* Modal adjustments */
    .modal-content {
        width: 92vw;
        max-height: 85vh;
    }

    .charts-container {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .analytics-stats-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* Tablet Portrait (768px) */
@media (max-width: 768px) {
    /* Base font size adjustment */
    body {
        font-size: 15px;
    }

    /* Header */
    .header-content {
        padding: 0 1rem;
    }

    .header-left {
        gap: 0.75rem;
    }

    .header-title h1 {
        font-size: 1.125rem;
    }

    .header-subtitle {
        display: none;
    }

    .system-status {
        flex-direction: column;
        gap: 0.25rem;
        align-items: flex-end;
    }

    .status-indicator {
        padding: 0.5rem 0.875rem;
        font-size: 0.8rem;
    }

    .last-update {
        font-size: 0.7rem;
    }

    /* Dashboard container */
    .dashboard-container {
        padding: 1.5rem 1rem;
    }

    /* Stats section */
    .overview-section {
        margin-bottom: 2rem;
    }

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

    .stat-card {
        padding: 1rem;
    }

    /* Section headers */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

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

    .refresh-btn {
        align-self: stretch;
        justify-content: center;
    }

    /* Node cards */
    .nodes-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .node-card {
        padding: 1.25rem;
    }

    .node-header h3 {
        font-size: 1.125rem;
    }

    .node-labels {
        gap: 0.375rem;
    }

    .label-tag {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }

    /* Sensor displays */
    .main-sensors-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .sensor-display {
        padding: 1rem;
    }

    .sensor-value {
        font-size: 1.75rem;
    }

    .sensor-label {
        font-size: 0.8rem;
    }

    .other-sensors-group {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .other-sensor-value {
        font-size: 1.25rem;
    }

    .other-sensor-label {
        font-size: 0.7rem;
    }

    /* Node actions */
    .node-actions {
        gap: 0.5rem;
    }

    .node-config-btn,
    .node-charts-btn {
        padding: 0.625rem;
    }

    /* Charts view controls */
    .charts-view-controls {
        flex-wrap: wrap;
        padding: 0 1rem;
        gap: 0.375rem;
    }

    .view-tabs {
        flex: 1 1 100%;
        display: flex;
        gap: 0.375rem;
    }

    .view-tab {
        flex: 1;
        min-width: calc(33.33% - 0.375rem);
        justify-content: center;
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .time-range-selector {
        flex-basis: 100%;
        justify-content: center;
        padding-bottom: 0.5rem;
    }

    .time-range-dropdown {
        font-size: 0.8125rem;
    }

    /* Modal */
    .modal-content {
        width: 95vw;
        max-height: 90vh;
    }

    .modal-header {
        padding: 1.25rem;
    }

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

    .modal-body {
        padding: 1.25rem;
    }

    /* Config forms */
    .config-tabs {
        gap: 0.375rem;
    }

    .config-tab {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .param-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Location map */
    .location-map {
        height: 250px;
    }
}

/* Mobile Landscape / Small Tablet (640px) */
@media (max-width: 640px) {
    /* Header */
    .header-logo svg {
        width: 24px;
        height: 24px;
    }

    .header-title h1 {
        font-size: 1rem;
    }

    /* Sensor grids - stack vertically on very small screens */
    .main-sensors-grid {
        grid-template-columns: 1fr;
    }

    .other-sensors-group {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }

    /* Charts */
    .chart-wrapper {
        padding: 1rem;
    }

    .chart-title {
        font-size: 0.9rem;
    }

    .sensor-chart {
        height: 220px !important;
    }

    /* Analytics */
    .analytics-card {
        padding: 1.25rem;
    }

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

    .metric-row {
        padding: 0.375rem 0;
    }

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

/* Mobile Portrait (480px and below) */
@media (max-width: 480px) {
    /* Loading screen */
    .loading-container {
        padding: 1rem;
        max-width: 90%;
    }

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

    .logo-subtitle {
        font-size: 0.85rem;
    }

    .spinner {
        width: 40px;
        height: 40px;
    }

    .status-text {
        font-size: 0.85rem;
    }

    .error-message {
        padding: 1.25rem;
    }

    .error-message h3 {
        font-size: 1rem;
    }

    .error-message p {
        font-size: 0.85rem;
    }

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

    .retry-btn,
    .configure-btn {
        width: 100%;
        padding: 0.75rem 1.25rem;
        font-size: 0.875rem;
    }

    /* Very compact header */
    .header-content {
        padding: 0 0.75rem;
    }

    .header-left {
        gap: 0.5rem;
    }

    .header-logo svg {
        width: 20px;
        height: 20px;
    }

    .header-title h1 {
        font-size: 0.95rem;
    }

    .system-status {
        align-items: flex-end;
    }

    .status-indicator {
        padding: 0.375rem 0.625rem;
        font-size: 0.75rem;
    }

    .status-indicator span {
        display: none;
    }

    .status-dot {
        margin-right: 0;
    }

    .last-update {
        font-size: 0.65rem;
    }

    /* Dashboard */
    .dashboard-container {
        padding: 1rem 0.75rem;
    }

    /* Stats */
    .stat-card {
        padding: 0.875rem;
    }

    .stat-icon {
        font-size: 1.5rem;
        width: 40px;
        height: 40px;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    /* Node cards */
    .node-card {
        padding: 1rem;
    }

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

    .node-labels {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .label-tag {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }

    /* Sensor displays */
    .sensor-display {
        padding: 0.75rem;
    }

    .sensor-value {
        font-size: 1.5rem;
    }

    .sensor-unit {
        font-size: 0.75rem;
    }

    .sensor-label {
        font-size: 0.75rem;
    }

    /* Other sensors - single column for very small screens */
    .other-sensors-group {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .other-sensor-display {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem;
        background: #f9fafb;
        border-radius: 6px;
    }

    .other-sensor-value {
        font-size: 1.125rem;
    }

    .other-sensor-label {
        font-size: 0.7rem;
        text-align: left;
    }

    /* Node actions */
    .node-actions {
        gap: 0.375rem;
    }

    .node-config-btn,
    .node-charts-btn {
        padding: 0.5rem;
        flex: 1;
    }

    /* View tabs - stack on very small screens */
    .charts-view-controls {
        flex-direction: column;
        padding: 0 0.75rem;
        gap: 0.5rem;
    }

    .view-tabs {
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
    }

    .view-tab {
        width: 100%;
        min-width: unset;
        padding: 0.75rem;
        justify-content: center;
    }

    .time-range-selector {
        width: 100%;
        justify-content: center;
        padding-bottom: 0.5rem;
    }

    .time-range-dropdown {
        flex: 1;
        max-width: 200px;
    }

    /* Modal */
    .modal-content {
        width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-header h2 {
        font-size: 1rem;
        gap: 0.5rem;
    }

    .download-csv-btn {
        padding: 0.375rem 0.625rem;
        font-size: 0.75rem;
    }

    .modal-body {
        padding: 1rem;
    }

    /* Config tabs */
    .config-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0.25rem;
    }

    .config-tab {
        white-space: nowrap;
        padding: 0.5rem 0.875rem;
        font-size: 0.8rem;
    }

    /* Param cards */
    .param-card {
        padding: 0.875rem;
    }

    .param-label {
        font-size: 0.8rem;
    }

    .param-value {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }

    /* Charts */
    .charts-container,
    .analytics-container,
    .table-container {
        padding: 0.75rem;
    }

    .chart-wrapper {
        padding: 0.875rem;
    }

    .sensor-chart {
        height: 200px !important;
    }

    /* Analytics */
    .analytics-section-title {
        font-size: 1.125rem;
    }

    .analytics-card {
        padding: 1rem;
    }

    .analytics-card-header h4 {
        font-size: 0.95rem;
    }

    .analytics-trend {
        font-size: 1.25rem;
        padding: 0.2rem 0.4rem;
    }

    /* Table */
    .table-wrapper {
        border-radius: 8px;
    }

    .table-controls {
        padding: 0.75rem;
    }

    .table-info {
        font-size: 0.8rem;
    }

    .table-search {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }

    .data-table {
        font-size: 0.75rem;
    }

    .data-table thead th,
    .data-table tbody td {
        padding: 0.5rem 0.375rem;
    }

    .data-table .row-number {
        width: 40px;
    }

    .data-table .timestamp {
        font-size: 0.7rem;
        min-width: 120px;
        white-space: nowrap;
    }

    .data-table .sensor-value {
        font-size: 0.75rem;
        min-width: 80px;
    }

    /* Server config form */
    .form-actions {
        flex-direction: column;
    }

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

    .config-preview {
        overflow-x: auto;
    }

    .config-preview code {
        font-size: 0.75rem;
        word-break: break-all;
    }
}

/* Extra Small Devices (320px) */
@media (max-width: 360px) {
    .header-title h1 {
        font-size: 0.875rem;
    }

    .stat-number {
        font-size: 1.25rem;
    }

    .sensor-value {
        font-size: 1.25rem;
    }

    .node-header h3 {
        font-size: 0.95rem;
    }

    .chart-title {
        font-size: 0.85rem;
    }

    .sensor-chart {
        height: 180px !important;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 600px) and (orientation: landscape) {
    .modal-content {
        max-height: 95vh;
    }

    .table-scroll {
        max-height: 400px;
    }

    .sensor-chart {
        height: 180px !important;
    }

    .dashboard-container {
        padding: 1rem;
    }

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

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .view-tab,
    .config-tab,
    .refresh-btn,
    .node-config-btn,
    .node-charts-btn,
    .chart-reset-btn {
        min-height: 44px;
    }

    .status-indicator {
        min-height: 44px;
    }

    /* Remove hover effects on touch devices */
    .stat-card:hover,
    .node-card:hover,
    .chart-wrapper:hover,
    .analytics-card:hover {
        transform: none;
    }

    /* Better scrolling */
    .table-scroll,
    .modal-body,
    .config-tabs {
        -webkit-overflow-scrolling: touch;
    }
}

/* Skeleton Loading Animation */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    display: inline-block;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-card {
    background: white;
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.skeleton-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.skeleton-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.skeleton-title {
    flex: 1;
    height: 24px;
    max-width: 200px;
}

.skeleton-subtitle {
    height: 16px;
    max-width: 150px;
    margin-top: 0.5rem;
}

.skeleton-stats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.skeleton-stat-group {
    display: flex;
    justify-content: space-around;
    padding: 0.75rem;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.skeleton-stat-item {
    text-align: center;
    flex: 1;
}

.skeleton-stat-value {
    height: 24px;
    width: 60px;
    margin: 0 auto 0.5rem;
}

.skeleton-stat-label {
    height: 12px;
    width: 50px;
    margin: 0 auto;
}

.skeleton-sensors-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.skeleton-sensor {
    text-align: center;
}

.skeleton-sensor-value {
    height: 24px;
    width: 50px;
    margin: 0 auto 0.5rem;
}

.skeleton-sensor-label {
    height: 12px;
    width: 40px;
    margin: 0 auto;
}

/* Skeleton for overview stats */
.stat-card.skeleton-loading {
    position: relative;
    overflow: hidden;
}

.stat-card.skeleton-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.8) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    z-index: 1;
}

.stat-card.skeleton-loading .stat-number,
.stat-card.skeleton-loading .stat-label {
    color: transparent;
    background: #e5e7eb;
    border-radius: 4px;
    position: relative;
}

.stat-card.skeleton-loading .stat-icon {
    opacity: 0.3;
}

/* Server Configuration Modal Styles */
.retry-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.configure-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(100, 116, 139, 0.2);
    color: white;
    border: 1px solid rgba(148, 163, 184, 0.3);
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
}

.configure-btn:hover {
    background: rgba(100, 116, 139, 0.3);
    border-color: rgba(148, 163, 184, 0.5);
    transform: translateY(-2px);
}

.configure-btn:active {
    transform: translateY(0);
}

.config-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    letter-spacing: 0.01em;
}

.form-group input {
    padding: 0.75rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: monospace;
    transition: all 0.2s ease;
    background: white;
}

.form-group input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.config-preview {
    background: #f9fafb;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    margin-top: 0.5rem;
}

.config-preview strong {
    font-size: 0.875rem;
    color: #6b7280;
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.config-preview code {
    display: block;
    font-family: monospace;
    font-size: 0.875rem;
    color: #3b82f6;
    word-break: break-all;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.primary-btn {
    flex: 1;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.primary-btn:active {
    transform: translateY(0);
}

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.secondary-btn {
    flex: 1;
    padding: 0.75rem 1.25rem;
    background: white;
    color: #3b82f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    background: #f9fafb;
    border-color: #3b82f6;
    transform: translateY(-1px);
}

.secondary-btn:active {
    transform: translateY(0);
}

.secondary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.connection-test-result {
    padding: 0.875rem 1rem;
    border-radius: 8px;
    margin-top: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    animation: slideIn 0.3s ease;
}

.connection-test-result.hidden {
    display: none;
    margin: 0;
}

.connection-test-result.success {
    background: #ecfdf5;
    border: 1px solid #86efac;
    color: #065f46;
}

.connection-test-result.error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.test-result-icon {
    font-size: 1.125rem;
    font-weight: bold;
    flex-shrink: 0;
}

.test-result-message {
    flex: 1;
    font-weight: 500;
    line-height: 1.4;
}

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

/* System Status Button Styles */
#system-status-btn.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

#system-status-btn.status-indicator:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

#system-status-btn.status-indicator:focus {
    outline: none;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .skeleton {
        animation: none;
        background: #f0f0f0;
    }
}