/* 스마트 팜 통합 대시보드 - 프리미엄 글래스모피즘 디자인 시스템 */
:root {
    --bg-grad: linear-gradient(135deg, #070f18 0%, #0d1b2a 50%, #070f18 100%);
    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: rgba(0, 0, 0, 0.5);
    
    --primary: #4caf50;
    --primary-glow: rgba(76, 175, 80, 0.35);
    --water: #00b4d8;
    --water-glow: rgba(0, 180, 216, 0.35);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.35);
    --text-main: #f8f9fa;
    --text-sub: #8a99ad;
    --accent: #ffb703;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-grad);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
}

/* 컨테이너 */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* 헤더 및 접속 상태 */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 5px 24px 5px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 25px;
}

.header-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

header h1 {
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, #ffffff 0%, #cfd8dc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.time-display {
    font-size: 1.05rem;
    color: #a0aec0;
    font-weight: 600;
    letter-spacing: -0.2px;
}

/* 📹 CCTV 타포 앱 퀵 바로가기 버튼 */
.cctv-header-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(0, 180, 216, 0.25) 0%, rgba(76, 175, 80, 0.3) 100%);
    border: 1.5px solid rgba(0, 180, 216, 0.5);
    color: #ffffff;
    padding: 9px 20px;
    border-radius: 25px;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 180, 216, 0.25);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.cctv-header-btn:hover {
    background: linear-gradient(135deg, rgba(0, 180, 216, 0.45) 0%, rgba(76, 175, 80, 0.45) 100%);
    border-color: rgba(0, 180, 216, 0.8);
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 6px 22px rgba(0, 180, 216, 0.45);
}

.cctv-header-btn:active {
    transform: translateY(0) scale(0.98);
}

.cctv-btn-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.cctv-btn-text {
    letter-spacing: -0.2px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 0.95rem;
    font-weight: 700;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--danger);
    box-shadow: 0 0 8px var(--danger-glow);
    transition: all 0.3s ease;
}

.status-dot.connected {
    background-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.header-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.25rem;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.25);
    transform: scale(1.08);
}

/* 메인 대시보드 2열 그리드 (모니터/PC 기준) */
.dashboard-grid {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* 글래스 카드 스타일 */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 22px;
    box-shadow: 0 8px 32px 0 var(--glass-shadow);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.6);
}

.card-title {
    font-size: 1.35rem;
    color: var(--text-main);
    font-weight: 800;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    letter-spacing: -0.3px;
}

.card-title span.badge {
    font-size: 0.88rem;
    padding: 4px 10px;
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
    color: var(--text-sub);
    font-weight: 600;
}

/* 1. 물탱크 수위 카드 (1열, 1~2행에 걸쳐 배치) */
.card-tank {
    grid-column: 1;
    grid-row: 1 / 3;
    min-height: 480px;
}

/* 2. 토양 수분 및 대기 온습도 카드 (2열 1행) */
.card-soil-weather {
    grid-column: 2;
    grid-row: 1;
}

/* 3. 관수 제어 카드 (2열 2행) */
.card-control {
    grid-column: 2;
    grid-row: 2;
}

/* 4. 관수 시간 설정 카드 (3행 전체) */
.card-sched-timer {
    grid-column: 1 / -1;
    grid-row: 3;
}

/* 5. 최근 7일 온습도 수분 변화 (4행 전체) */
.card-chart {
    grid-column: 1 / -1;
    grid-row: 4;
}

/* 6. 시스템 로그 (5행 전체) */
.card-log {
    grid-column: 1 / -1;
    grid-row: 5;
}

.tank-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    flex-grow: 1;
    gap: 20px;
}

/* 3D 원통형 글래스 물탱크 (폭 35% 확장: 110px -> 150px) */
.water-tank {
    position: relative;
    width: 150px;
    height: 380px;
    border: 2.5px solid rgba(255, 255, 255, 0.28);
    border-radius: 75px / 20px; /* 상하 실린더형 타원 */
    overflow: hidden;
    background: linear-gradient(90deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.02) 100%);
    box-shadow: inset 0 0 24px rgba(0,0,0,0.65), 0 12px 35px rgba(0,0,0,0.45);
}

/* 물탱크 상단 내부 림 효과 */
.water-tank::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 20px;
    border: 1.5px solid rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    z-index: 5;
    box-sizing: border-box;
}

.water {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%; /* 실시간 수위 높이 */
    background: linear-gradient(90deg, #005f73 0%, #0a9396 50%, #005f73 100%);
    transition: height 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 18px rgba(10, 147, 150, 0.45);
}

/* 3D 물 수면 타원 효과 */
.water-surface {
    position: absolute;
    top: -10px;
    left: 0;
    width: 100%;
    height: 20px;
    background: #94d2bd;
    border-radius: 50%;
    box-shadow: 0 0 12px #94d2bd;
    opacity: 0.9;
}

.tank-info-panel {
    text-align: center;
    width: 100%;
}

.huge-value {
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
}

.value-unit {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-sub);
    margin-left: 2px;
}

.sub-value {
    font-size: 1.15rem;
    font-weight: 600;
    color: #cbd5e1;
    margin-top: 6px;
}

.volume-display {
    font-size: 0.9rem;
    color: var(--text-sub);
    margin-top: 8px;
    font-weight: 600;
    background: rgba(0,0,0,0.2);
    padding: 6px 12px;
    border-radius: 8px;
    display: inline-block;
}

/* 2. 토양 수분 & 온습도 통합 레이아웃 */
.soil-weather-layout {
    display: flex;
    gap: 24px;
    align-items: stretch;
    justify-content: space-between;
    width: 100%;
    flex-grow: 1;
}

.env-layout-divider {
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    height: 100%;
    min-height: 180px;
}

.soil-gauges-section {
    display: flex;
    gap: 30px;
    align-items: center;
    justify-content: space-around;
    flex: 1.2;
}

.soil-gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    position: relative;
}

.soil-label {
    font-size: 1.15rem;
    color: #cbd5e1;
    font-weight: 800;
    letter-spacing: -0.2px;
}

/* 대형 수분 게이지 (크기 확대) */
.soil-gauge {
    position: relative;
    width: 140px;
    height: 80px;
    overflow: hidden;
}

.gauge-svg {
    width: 140px;
    height: 140px;
    transform: rotate(0deg);
}

.gauge-track-arc {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 22;
    stroke-linecap: butt;
}

.gauge-color-arc {
    fill: none;
    stroke: url(#gaugeGrad);
    stroke-width: 22;
    stroke-linecap: butt;
    opacity: 0.85;
}

.gauge-needle-group {
    transform-origin: 70px 70px;
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 게이지 하단 대형 수분 % 표시 */
.soil-pct-display {
    font-size: 2.1rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.1;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 2px;
    margin-top: -6px;
}

.soil-pct-display .unit {
    font-size: 1.2rem;
    font-weight: 700;
    color: #94a3b8;
}

/* 대기 온습도 섹션 (좌우 균형 맞춤) */
.weather-compact-section {
    display: flex;
    gap: 16px;
    flex: 1;
    align-items: stretch;
}

.weather-compact-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.22);
    padding: 20px 16px;
    border-radius: 16px;
    flex: 1;
    border: 1px solid rgba(255, 255, 255, 0.04);
    min-height: 180px;
}

.weather-item-icon {
    font-size: 2.1rem;
    line-height: 1;
}

.weather-compact-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.weather-compact-text .weather-item-label {
    font-size: 1.25rem;
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: -0.2px;
}

.weather-compact-text .weather-item-val {
    font-size: 2.3rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.1;
}

.weather-compact-text .weather-item-val .unit {
    font-size: 1.25rem;
    font-weight: 700;
    color: #94a3b8;
    margin-left: 2px;
}

.soil-range-badge.dry {
    color: var(--accent);
    background: rgba(255, 183, 3, 0.12);
    border-color: rgba(255, 183, 3, 0.2);
}

.soil-range-badge.wet {
    color: var(--water);
    background: rgba(0, 180, 216, 0.12);
    border-color: rgba(0, 180, 216, 0.2);
}

.soil-control-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
}

/* 공용 칩 및 뱃지 */
.relay-chip {
    display: inline-block;
    font-size: 0.78rem;
    padding: 5px 12px;
    border-radius: 12px;
    font-weight: 700;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.06);
    color: var(--text-sub);
    transition: all 0.3s ease;
}

.relay-chip.active {
    color: var(--primary);
    border-color: rgba(76,175,80,0.3);
    background: rgba(76,175,80,0.12);
    box-shadow: 0 0 12px rgba(76,175,80,0.2);
}

.criteria-label {
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 700;
    text-align: right;
    background: rgba(76, 175, 80, 0.08);
    padding: 3px 6px;
    border-radius: 6px;
}

/* 3. 주변 날씨 카드 (참조용 스타일) */
.weather-content {
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-grow: 1;
    padding: 10px 0;
}

.weather-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.weather-item-icon {
    font-size: 1.4rem;
    margin-bottom: 2px;
}

.weather-item-label {
    font-size: 0.75rem;
    color: var(--text-sub);
    font-weight: 600;
}

.weather-item-val {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
}

.weather-divider {
    border-left: 1px solid rgba(255,255,255,0.08);
    height: 50px;
}

/* 5. 온실 컨트롤 카드 스타일 */
.control-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
    justify-content: center;
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.control-item-left {
    display: flex;
    flex-direction: column;
}

.control-item-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-main);
}

.control-item-sub {
    font-size: 0.7rem;
    color: var(--text-sub);
    margin-top: 1px;
}

.control-item-sub span.status-lbl {
    font-weight: 700;
    color: var(--text-sub);
}

.control-item-sub span.status-lbl.running {
    color: var(--primary);
}

/* 6. CCTV 타포 카메라 카드 (가로 와이드 레이아웃) */
.cctv-preview {
    position: relative;
    width: 100%;
    height: 120px;
    border-radius: 12px;
    overflow: hidden;
    background: #111a24;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.7);
}

.cctv-preview-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0.45;
    background: linear-gradient(rgba(18, 30, 49, 0.9), rgba(18, 30, 49, 0.9)),
                repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.05) 2px, rgba(255, 255, 255, 0.05) 4px);
    background-size: cover;
    transition: opacity 0.3s ease;
}

.cctv-preview:hover .cctv-preview-bg {
    opacity: 0.6;
}

.cctv-rec-dot {
    position: absolute;
    top: 8px;
    left: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--danger);
    z-index: 2;
}

.cctv-rec-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--danger);
    box-shadow: 0 0 6px var(--danger);
    animation: rec-blink 1.5s infinite;
}

@keyframes rec-blink {
    0% { opacity: 0.2; }
    50% { opacity: 1; }
    100% { opacity: 0.2; }
}

.cctv-play-btn {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 2;
    transition: transform 0.2s ease, background 0.2s ease;
}

.cctv-play-btn svg {
    width: 14px;
    height: 14px;
    fill: #0d1b2a;
    transform: translateX(1px);
}

.cctv-preview:hover .cctv-play-btn {
    transform: scale(1.1);
    background: #ffffff;
}

.cctv-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 0.72rem;
    color: var(--text-sub);
    font-weight: 600;
}

/* 7. 트렌드 차트 카드 */
.chart-container {
    width: 100%;
    height: 150px;
    position: relative;
    margin-top: 5px;
}

/* 8. 시스템 로그 카드 */
.log-console {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255,255,255,0.03);
    border-radius: 12px;
    height: 160px;
    overflow-y: auto;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.7);
}

.log-row {
    display: grid;
    grid-template-columns: 85px 1fr 105px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-size: 1.02rem;
    line-height: 1.4;
    transition: background 0.15s ease;
}

.log-row:hover {
    background: rgba(255,255,255,0.04);
}

.log-time {
    color: #94a3b8;
    font-weight: 600;
    font-size: 0.95rem;
}

.log-action {
    color: #f1f5f9;
    font-weight: 600;
    font-size: 1.02rem;
}

.log-row.event-row .log-action {
    color: #86efac;
}

.log-source {
    text-align: right;
    font-weight: 700;
    color: var(--primary);
    font-size: 0.88rem;
    background: rgba(76, 175, 80, 0.12);
    padding: 3px 8px;
    border-radius: 6px;
    justify-self: end;
}

.log-source.system {
    color: var(--text-sub);
    background: rgba(255,255,255,0.05);
}

.log-source.error {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
}

/* 경보 인디케이터 */
.alert-bar {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 12px;
    padding: 12px 18px;
    margin-bottom: 20px;
    font-size: 0.85rem;
    color: #fca5a5;
    display: none; /* 에러 시 block 처리 */
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.15);
}

.alert-bar.visible {
    display: flex;
}

.alert-icon {
    animation: pulse-red 1.5s infinite;
    font-weight: bold;
}

@keyframes pulse-red {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* 설정용 사이드 드로어 */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 998;
    display: none;
    backdrop-filter: blur(4px);
    transition: all 0.3s ease;
}

.drawer-overlay.open {
    display: block;
}

.drawer {
    position: fixed;
    top: 0;
    right: -340px;
    width: 340px;
    height: 100%;
    background: rgba(13, 27, 42, 0.85);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 999;
    box-shadow: -10px 0 40px rgba(0,0,0,0.6);
    transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
}

.drawer.open {
    right: 0;
}

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

.drawer-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

.drawer-close {
    background: none;
    border: none;
    color: var(--text-sub);
    font-size: 1.4rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.drawer-close:hover {
    color: var(--text-main);
}

.drawer-body {
    padding: 24px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.drawer-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.drawer-section-title {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1.5px dashed rgba(76, 175, 80, 0.2);
    padding-bottom: 5px;
    margin-bottom: 5px;
}

.drawer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.drawer-select {
    background: rgba(0,0,0,0.4);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    width: 130px;
}

.threshold-slider-group {
    margin-bottom: 10px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 6px;
    color: var(--text-sub);
}

.slider-header span.val {
    color: var(--text-main);
    font-weight: 700;
}

.range-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 3px;
    background: rgba(255,255,255,0.12);
    outline: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-main);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    transition: background 0.15s;
}

.range-slider::-webkit-slider-thumb:hover {
    background: var(--primary);
}

.btn-apply {
    display: block;
    width: 100%;
    padding: 11px 0;
    background: rgba(76, 175, 80, 0.15);
    border: 1px solid rgba(76,175,80,0.3);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 5px;
    text-align: center;
}

.btn-apply:hover {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
}

.btn-apply:active {
    transform: scale(0.98);
}

.info-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.8rem;
    background: rgba(0,0,0,0.2);
    padding: 12px;
    border-radius: 10px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    padding-bottom: 5px;
}

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

.info-row span:first-child {
    color: var(--text-sub);
}

.info-row span:last-child {
    color: var(--text-main);
    font-weight: 600;
}

.setting-card-content {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    flex-grow: 1;
    gap: 12px;
    margin-top: 10px;
}

.setting-value {
    font-size: 2.1rem;
    font-weight: 800;
    color: var(--text-main);
}

.setting-value .unit {
    font-size: 1rem;
    color: var(--text-sub);
    margin-left: 2px;
}

.setting-slider-container {
    width: 100%;
}

.btn-card-apply {
    width: 100%;
    padding: 9px 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-card-apply:hover {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.btn-card-apply:active {
    transform: scale(0.98);
}

/* 토양 수분 및 관수 제어 상세 레이아웃 */
.soil-card-layout {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    flex-grow: 1;
}

.soil-gauges-section {
    display: flex;
    gap: 25px;
    align-items: center;
    justify-content: center;
    flex: 1.2;
}

.soil-layout-divider {
    border-left: 1px solid rgba(255,255,255,0.08);
    height: 110px;
}

.soil-controls-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-left: 5px;
    width: 100%;
}

.control-row-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.limit-control-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.limit-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.15rem;
    font-weight: 700;
    color: #e2e8f0;
}

.limit-val-wet {
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: 800;
}

.limit-val-dry {
    color: #ff7096;
    font-size: 1.25rem;
    font-weight: 800;
}

.soil-inner-divider {
    border-top: 1px solid rgba(255,255,255,0.06);
    width: 100%;
}

.pump-control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 2px 0;
}

.pump-status-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.pump-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pump-title-wrap .control-item-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

.pump-status-info .control-item-sub {
    font-size: 0.98rem;
    font-weight: 600;
    color: #94a3b8;
}

.pump-switch-wrap {
    display: flex;
    align-items: center;
}

.pump-switch-wrap .switch {
    transform: scale(1.1);
}

.pump-mode-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.05rem;
    background: rgba(0,0,0,0.25);
    padding: 8px 12px;
    border-radius: 8px;
    width: 100%;
}

.pump-mode-label {
    color: #cbd5e1;
    font-weight: 600;
    font-size: 1.05rem;
}

.pump-mode-label span {
    color: var(--primary);
    margin-left: 6px;
    font-weight: 800;
}

.pump-mode-dropdown {
    background: rgba(0,0,0,0.4);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.98rem;
    font-weight: 700;
    outline: none;
    cursor: pointer;
}

.card-sched-timer {
    grid-column: span 2;
}
.card-sched-timer:hover { border-color: var(--primary-glow); }
.card-soil-wet:hover { border-color: var(--primary-glow); }
.card-soil-dry:hover { border-color: rgba(181, 23, 158, 0.3); }

/* =========================================================================
   📱 완벽한 반응형 미디어 쿼리 (모바일 & 태블릿 최적화)
   ========================================================================= */

/* 태블릿 (1024px 이하) */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    .card-tank {
        grid-column: 1;
        grid-row: span 2;
        min-height: 480px;
    }
    .card-soil {
        grid-column: 2;
        grid-row: 1;
    }
    .card-weather {
        grid-column: 2;
        grid-row: 2;
    }
    .card-cctv {
        grid-column: 1;
    }
    .card-sched-timer {
        grid-column: span 2;
    }
    .card-chart, .card-log {
        grid-column: span 2;
    }
}

/* 스마트폰 / 소형 화면 (768px 이하) */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
    }

    body {
        padding: 12px 10px;
    }

    .container {
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin: 0;
    }

    /* 헤더 모바일 정렬 */
    header {
        flex-direction: column;
        align-items: center;
        gap: 14px;
        padding: 8px 2px 18px 2px;
        margin-bottom: 18px;
    }

    .header-title-wrap {
        text-align: center;
        align-items: center;
    }

    header h1 {
        font-size: 1.55rem;
        text-align: center;
    }

    .time-display {
        font-size: 0.95rem;
        text-align: center;
    }

    .header-right {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px;
    }

    .cctv-header-btn {
        padding: 8px 16px;
        font-size: 0.95rem;
    }

    .status-badge {
        padding: 6px 14px;
        font-size: 0.88rem;
    }

    .header-btn {
        width: 38px;
        height: 38px;
        font-size: 1.15rem;
    }

    /* 1열 세로 스택 그리드 */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
        width: 100%;
    }

    /* 모든 카드를 1열로 꽉 차게 */
    .card,
    .card-tank,
    .card-soil-weather,
    .card-control,
    .card-sched-timer,
    .card-chart,
    .card-log {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
        width: 100% !important;
        min-height: auto !important;
        box-sizing: border-box !important;
        padding: 18px 14px !important;
    }

    /* 1. 물탱크 카드 모바일 가로형 컴팩트 배치 */
    .card-tank .tank-content {
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        width: 100%;
        gap: 15px;
        padding: 10px 0;
    }

    .water-tank {
        width: 105px;
        height: 220px;
        border-radius: 52px / 15px;
    }

    .water-tank::before {
        height: 15px;
    }

    .tank-info-panel {
        text-align: center;
        flex: 1;
    }

    .huge-value {
        font-size: 2.6rem;
    }

    .sub-value {
        font-size: 1.05rem;
    }

    /* 2. 토양 수분 및 대기 온습도 모바일 배치 */
    .soil-weather-layout {
        flex-direction: column !important;
        gap: 14px !important;
        width: 100% !important;
    }

    .soil-gauges-section {
        width: 100% !important;
        gap: 15px !important;
        justify-content: space-around !important;
    }

    .soil-gauge-container {
        gap: 8px;
    }

    .soil-gauge {
        width: 130px;
        height: 80px;
    }

    .gauge-svg {
        width: 130px;
        height: 130px;
    }

    .soil-label {
        font-size: 1.05rem;
    }

    .soil-pct-display {
        font-size: 1.85rem;
    }

    .env-layout-divider {
        width: 100% !important;
        height: 1px !important;
        border-left: none !important;
        border-top: 1px solid rgba(255,255,255,0.08) !important;
        margin: 4px 0 !important;
    }

    .weather-compact-section {
        width: 100% !important;
        gap: 10px !important;
    }

    .weather-compact-item {
        min-height: auto !important;
        padding: 14px 10px !important;
        gap: 8px !important;
    }

    .weather-item-icon {
        font-size: 1.6rem;
    }

    .weather-compact-text .weather-item-label {
        font-size: 1.1rem;
    }

    .weather-compact-text .weather-item-val {
        font-size: 1.85rem;
    }

    /* 3. 관수 제어 카드 모바일 */
    .soil-controls-section {
        padding-left: 0 !important;
        width: 100% !important;
        gap: 10px !important;
    }

    .limit-label-row {
        font-size: 0.88rem;
    }

    .control-item-name {
        font-size: 0.88rem;
    }

    .pump-mode-box {
        font-size: 0.8rem;
        padding: 6px 8px;
    }

    /* 4. 관수 시간 설정 테이블 모바일 스크롤 & 폰트 최적화 */
    .setting-card-content {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .setting-card-content table {
        min-width: 290px;
        font-size: 0.85rem !important;
    }

    .setting-card-content th,
    .setting-card-content td {
        padding: 8px 4px !important;
    }

    .setting-card-content td span {
        font-size: 0.9rem !important;
    }

    .btn-card-apply {
        padding: 4px 8px !important;
        font-size: 0.78rem !important;
        margin-left: 5px !important;
    }

    /* 사이드 드로어 모바일 전체폭 */
    .drawer {
        width: 100%;
        right: -100%;
    }
}

/* 초소형 스마트폰 (360px 이하) */
@media (max-width: 360px) {
    body {
        padding: 8px 5px;
    }
    .card {
        padding: 14px 10px !important;
    }
    header h1 {
        font-size: 1.15rem;
    }
}

/* 깜빡임 애니메이션 (관수 가동중 타이머용) */
@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

.sched-timer-label {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(255, 112, 150, 0.12);
    border: 1px solid rgba(255, 112, 150, 0.25);
    color: #ff7096;
    font-weight: 700;
    font-size: 0.82rem;
    vertical-align: middle;
    animation: blink 1.2s infinite;
}

/* 실시간 관수 펌프 LED 표시등 */
.led-indicator.running {
    background: #4caf50 !important;
    box-shadow: 0 0 10px #4caf50, 0 0 20px #4caf50 !important;
}
.led-indicator.stopped {
    background: #e63946 !important;
    box-shadow: 0 0 6px #e63946 !important;
}

