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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Header */
header {
    background: white;
    padding: 24px 32px;
    border-radius: 16px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 28px;
    color: #667eea;
    font-weight: 700;
}

.status-badge {
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.status-badge.connected {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.status-badge.disconnected {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-sm {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: #f3f4f6;
    color: #4b5563;
    transition: all 0.2s;
}

.btn-sm:hover {
    background: #e5e7eb;
    color: #1f2937;
}

/* Tabs */
.tabs {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 24px;
    display: flex;
    padding: 12px;
    gap: 12px;
}

.tab {
    flex: 1;
    padding: 14px 24px;
    border: none;
    background: transparent;
    color: #666;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    border-radius: 12px;
    transition: all 0.3s;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab:hover {
    background: #f3f4f6;
    transform: translateY(-2px);
}

.tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Content */
main {
    display: block;
}

.screen,
.tab-content {
    min-height: 400px;
}

.hidden {
    display: none !important;
}

/* Cards */
.card {
    background: white;
    padding: 32px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
}

.card h2,
.card h3 {
    margin-bottom: 24px;
    color: #1f2937;
    font-weight: 700;
}

.card h2 {
    font-size: 24px;
    border-bottom: 3px solid #667eea;
    padding-bottom: 12px;
    display: inline-block;
}

.card h3 {
    font-size: 20px;
}

/* Two Column Layout for Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #374151;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.3s;
    background: #f9fafb;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    min-height: 100px;
}

.row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* Radio & Checkbox */
.radio-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.radio-label,
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 10px;
    border: 2px solid #e5e7eb;
    transition: all 0.3s;
}

.radio-label:hover,
.checkbox-label:hover {
    background: #f3f4f6;
    border-color: #667eea;
}

.radio-label input,
.checkbox-label input {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Buttons */
button {
    font-family: inherit;
}

.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 14px 32px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(107, 114, 128, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

.button-group {
    display: flex;
    gap: 16px;
    margin-top: 24px;
    margin-top: 24px;
    flex-wrap: wrap;
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px auto;
}

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

    100% {
        transform: rotate(360deg);
    }
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Connect Screen */
#connectScreen {
    text-align: center;
    padding: 80px 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

#connectBtn {
    padding: 20px 48px;
    font-size: 18px;
}

/* Quick View */
.quick-view {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.quick-view-item {
    padding: 16px 20px;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border-radius: 12px;
    font-size: 14px;
    transition: all 0.3s;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    border: 2px solid transparent;
    border-left: none;
}

.quick-view-item.selected {
    border-color: #667eea;
    background: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.quick-view-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.quick-view-item span {
    font-weight: 700;
    color: #667eea;
    font-size: 15px;
}

/* Sensor Config Special */
.sensor-config {
    background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
    padding: 24px;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
    margin: 20px 0;
}

/* Status Message */
.status-message {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 18px 28px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
    transform: translateY(150px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    font-weight: 600;
    z-index: 1000;
}

.status-message.show {
    transform: translateY(0);
    opacity: 1;
}

.status-message.error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.4);
}

/* Enhanced spacing for sections */
#tab-network .card,
#tab-time .card,
#tab-sensors .card {
    animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Screen Status Grid */
.screen-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.screen-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.screen-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.screen-module {
    display: block;
    font-weight: 600;
    color: var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 0 10px;
    }

    .card {
        padding: 20px;
    }

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

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

    .radio-group {
        grid-template-columns: 1fr;
    }

    .tabs {
        flex-direction: column;
    }

    .button-group {
        flex-direction: column;
    }

    .button-group button {
        width: 100%;
    }

    header {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }

    .quick-view {
        grid-template-columns: 1fr;
    }
}

/* Large screens - use even more space */
@media (min-width: 1400px) {
    .app-container {
        max-width: 1600px;
    }

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