:root {
    --primary: #00F2FF;
    --secondary: #F0BC02;
    --background: #000000;
    --surface: #1E1E1E;
    --surface-light: #2A2A2A;
    --text-main: #FFFFFF;
    --text-muted: #B9BABA;
    --error: #E02020;
    --success: #74B038;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 5%;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 40px;
}

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

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

.logo span {
    color: var(--primary);
    font-size: 36px;
    filter: drop-shadow(0 0 10px rgba(0, 242, 255, 0.5));
}

.logo h1 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #FFFFFF, #B9BABA);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.icon-button {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.icon-button:hover {
    background: var(--surface-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: rgba(30, 30, 30, 0.5);
    padding: 15px 20px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
}

.section-title h2 {
    font-size: 22px;
    font-weight: 600;
}

.status-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
}

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

.online-dot {
    background-color: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.offline-dot {
    background-color: var(--error);
}

.device-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 15px;
    overflow-x: auto;
}

.tab-button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 12px 24px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.tab-button.active {
    background: rgba(0, 242, 255, 0.15);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.2);
}

.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
}

.device-card {
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.device-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: transparent;
    transition: background 0.3s ease;
}

.device-card.is-online::before {
    background: linear-gradient(90deg, var(--success), transparent);
}

.device-card.is-offline::before {
    background: linear-gradient(90deg, var(--error), transparent);
}

.device-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6);
    border-color: rgba(0, 242, 255, 0.3);
}

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

.device-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--surface-light), var(--surface));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 28px;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.05);
}

.device-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status-online {
    background: rgba(116, 176, 56, 0.1);
    color: var(--success);
    border: 1px solid rgba(116, 176, 56, 0.2);
}

.status-offline {
    background: rgba(224, 32, 32, 0.1);
    color: var(--error);
    border: 1px solid rgba(224, 32, 32, 0.2);
}

.device-info h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 6px;
}

.device-info p {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 400;
}

.device-stats {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 14px;
    font-weight: 500;
}

.stat-value.highlight {
    color: var(--primary);
}

.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 242, 255, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(116, 176, 56, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(116, 176, 56, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(116, 176, 56, 0);
    }
}

.status-online .dot {
    animation: pulse 2s infinite;
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 20px;
    }

    .section-title {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
}

/* View Management */
.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

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

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

/* Login and Reg Screen */
#loginView,
#userAddView {
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

#loginView.active,
#userAddView.active {
    display: flex;
}

.login-card {
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 40px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5);
}

.login-card h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 30px;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 14px 15px 14px 45px;
    color: var(--text-main);
    font-size: 15px;
    font-family: inherit;
    text-align: left;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.2);
}

.primary-button {
    width: 100%;
    background: var(--primary);
    color: var(--background);
    border: none;
    padding: 15px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.primary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 242, 255, 0.3);
}

.secondary-button {
    width: 100%;
    background: transparent;
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 15px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.secondary-button:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.4);
}

.error-text {
    color: var(--error);
    font-size: 13px;
    margin-top: 15px;
}

/* Detail Grid */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

.temp-card {
    background: linear-gradient(135deg, rgba(0, 242, 255, 0.15), rgba(0, 242, 255, 0.05));
    border: 1px solid rgba(0, 242, 255, 0.2);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.temp-card-alt {
    background: linear-gradient(135deg, rgba(240, 188, 2, 0.15), rgba(240, 188, 2, 0.05));
    border: 1px solid rgba(240, 188, 2, 0.2);
}

.temp-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: rgba(255, 255, 255, 0.8);
}

.temp-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: flex-end;
    gap: 5px;
    line-height: 1;
}

.temp-unit {
    font-size: 16px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 4px;
}

/* Status Dots Container */
.status-dots-container {
    display: flex;
    justify-content: space-between;
    background: rgba(30, 30, 30, 0.5);
    padding: 15px 20px;
    border-radius: 16px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.status-dot-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.status-dot-item span {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.s-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.s-dot.active {
    background: var(--success);
    border-color: var(--success);
    box-shadow: 0 0 10px var(--success);
}

/* Controls Section */
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-group {
    background: rgba(30, 30, 30, 0.4);
    border-radius: 20px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.control-group h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--text-muted);
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
}

.control-btn {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 15px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.control-btn span {
    font-size: 28px;
    color: rgba(255, 255, 255, 0.4);
    transition: all 0.3s ease;
}

.control-btn.active {
    background: rgba(0, 242, 255, 0.15);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.2);
}

.control-btn.active span {
    color: var(--primary);
}

.control-btn.alt.active {
    background: rgba(240, 188, 2, 0.15);
    border-color: var(--secondary);
    box-shadow: 0 0 15px rgba(240, 188, 2, 0.2);
}

.control-btn.alt.active span {
    color: var(--secondary);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* Toast Messages */
#toastContainer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast-message {
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(10px);
    color: var(--text-main);
    padding: 15px 20px;
    border-radius: 12px;
    border-left: 4px solid var(--primary);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

.toast-message.error {
    border-left-color: var(--error);
}

.toast-message .material-symbols-rounded {
    font-size: 20px;
}

.toast-message.error .material-symbols-rounded {
    color: var(--error);
}

.toast-message:not(.error) .material-symbols-rounded {
    color: var(--primary);
}

/* Switches */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .4s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(24px); }
.slider.round { border-radius: 26px; }
.slider.round:before { border-radius: 50%; }

/* Settings Styles */
.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.setting-slider {
    padding: 15px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

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

.val-badge {
    background: rgba(0, 242, 255, 0.15);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: bold;
}

.setting-item-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.modern-select {
    background: rgba(0,0,0,0.3);
    color: var(--text-main);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 12px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 15px;
    width: 100%;
}

.control-group h3 {
    display: flex;
    align-items: center;
    gap: 8px;
}
.control-group h3 .material-symbols-rounded {
    font-size: 20px;
    color: var(--primary);
}

input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
}
input[type=range]:focus { outline: none; }
input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  background: rgba(255,255,255,0.1);
  border-radius: 5px;
}
input[type=range]::-webkit-slider-thumb {
  height: 20px;
  width: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -7px;
}

/* BUSY OVERLAY */
.busy-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(8px);
}

.busy-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.busy-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.busy-spinner {
    width: 80px;
    height: 80px;
    background: rgba(0, 242, 255, 0.1);
    border: 2px solid var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 30px rgba(0, 242, 255, 0.4);
    animation: pulseGlow 1.5s infinite alternate;
}

.busy-spinner .material-symbols-rounded {
    font-size: 38px;
    color: var(--primary);
    animation: floatIcon 1.5s infinite ease-in-out alternate;
}

.busy-text {
    font-family: 'Poppins', sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 0.5px;
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 20px rgba(0, 242, 255, 0.2); transform: scale(0.98); }
    100% { box-shadow: 0 0 50px rgba(0, 242, 255, 0.6); transform: scale(1.05); }
}

@keyframes floatIcon {
    0% { transform: translateY(0px); }
    100% { transform: translateY(-4px); }
}