:root {
    --bg-color: #090b0e;
    --card-bg: rgba(17, 22, 29, 0.75);
    --border-color: rgba(55, 65, 81, 0.4);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --accent-green: #10b981;
    --accent-blue: #3b82f6;
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
    --glow-green: rgba(16, 185, 129, 0.2);
    --glow-blue: rgba(59, 130, 246, 0.2);
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 5% 5%, rgba(16, 185, 129, 0.04) 0%, transparent 35%),
        radial-gradient(circle at 95% 95%, rgba(59, 130, 246, 0.04) 0%, transparent 35%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 15px;
    padding-bottom: 60px;
}

/* 헤더 디자인 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 5px;
}
.header h1 {
    font-size: 1.7em;
    font-weight: 800;
    background: linear-gradient(135deg, #ffffff 40%, var(--accent-green) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.connection-badge {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--accent-green);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}
.connection-badge::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--accent-green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-green);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.5; }
}

/* 상단 탭 네비게이션 */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none; /* Firefox */
}
.tabs::-webkit-scrollbar { display: none; } /* Chrome */
.tab-btn {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 12px 22px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-size: 1.05em;
}
.tab-btn.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    border-color: var(--accent-green);
    box-shadow: 0 0 12px var(--glow-green);
}

.grid-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}
@media(min-width: 768px) {
    .grid-container { grid-template-columns: repeat(2, 1fr); }
    .full-width { grid-column: 1 / -1; }
}

.tab-content { display: none !important; }
.tab-content.active { display: grid !important; }

/* 카드 디자인 (Glassmorphism) */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: border-color 0.2s;
}
.card:hover {
    border-color: rgba(16, 185, 129, 0.35);
}
.card-title {
    font-size: 1.15em;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
}

/* 센서 그리드 배치 */
.sensor-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.sensor-row:last-child { margin-bottom: 0; }
.sensor-label { color: var(--text-secondary); font-size: 0.95em; }
.sensor-val { font-size: 1.25em; font-weight: 600; color: #fff; }
.unit { font-size: 0.75em; color: var(--text-secondary); margin-left: 2px; }

/* 제어 폼 필드 */
.form-group {
    margin-bottom: 12px;
}
.form-group:last-child { margin-bottom: 0; }
.form-label {
    display: block;
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}
.form-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: #fff;
    padding: 10px 12px;
    font-size: 1em;
    outline: none;
    transition: border-color 0.2s;
}
.form-input:focus {
    border-color: var(--accent-green);
}
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

/* 버튼 양식 */
.btn {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}
.btn:hover {
    background: var(--accent-green);
    color: var(--bg-color);
    box-shadow: 0 0 12px var(--glow-green);
}
.btn:active { transform: scale(0.98); }

.btn-blue {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}
.btn-blue:hover {
    background: var(--accent-blue);
    color: #fff;
    box-shadow: 0 0 12px var(--glow-blue);
}

.btn-toggle {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border-color);
    color: var(--text-secondary);
}
.btn-toggle.active {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--accent-green);
    color: var(--accent-green);
    box-shadow: 0 0 8px var(--glow-green);
}

/* 슬라이더 제어 */
.slider-group {
    margin-top: 15px;
}
.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.slider-bar-container {
    display: flex;
    align-items: center;
    gap: 10px;
}
input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    background: #1c232e;
    height: 6px;
    border-radius: 3px;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green);
    cursor: pointer;
}

/* 게이지 진행 바 */
.progress-container {
    width: 100%;
    background: #1c232e;
    height: 8px;
    border-radius: 4px;
    margin-top: 6px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-green));
    width: 0%;
    transition: width 0.4s ease;
}

/* 물탱크 물결 애니메이션 */
@keyframes wave {
    0% { transform: translateX(-50%) rotate(0deg); }
    100% { transform: translateX(-50%) rotate(360deg); }
}

/* 알람 로그 터미널 */
.terminal {
    background: #050608;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    height: 380px;
    overflow-y: auto;
    padding: 15px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.88em;
    line-height: 1.5;
    color: #d1d5db;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.8);
}
.terminal-row {
    margin-bottom: 6px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.terminal-time {
    color: #4b5563;
    flex-shrink: 0;
    white-space: nowrap;
}
.terminal-msg {
    word-break: break-all;
}

/* 알림 토스트 */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid var(--accent-green);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9em;
    font-weight: 600;
    z-index: 1000;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast.show {
    transform: translateX(-50%) translateY(0);
}

.hidden {
    display: none !important;
}

/* 테이블 서식 */
table th, table td {
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
