* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: #12171d;
    color: #e0e0e0;
    font-family: "Microsoft YaHei", sans-serif;
    font-size: clamp(12px, 0.85vw, 15px);
}

/* ========== 顶部导航栏 ========== */
.nav-bar {
    height: 3em;
    line-height: 3em;
    padding: 0 1.25em;
    background: #1a1f27;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.nav-left {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1.5em;
}
.nav-time {
    font-size: 0.95em;
    color: #e0e0e0;
}
.nav-weather {
    display: flex;
    align-items: center;
    gap: 0.6em;
    font-size: 0.9em;
}
.nav-weather .temp {
    color: #4fc3f7;
    font-weight: bold;
    font-size: 1.05em;
}
.nav-title {
    font-size: 1.25em;
    color: #4fc3f7;
    font-weight: bold;
    flex: 1;
    text-align: center;
}
.nav-links {
    flex: 1;
    text-align: right;
    font-size: 0.875em;
}
.nav-links a {
    color: #90caf9;
    text-decoration: none;
    margin-left: 1.375em;
    cursor: pointer;
}
.nav-links a:hover {
    color: #4fc3f7;
}
.user-info {
    color: #4fc3f7;
    margin-left: 1.375em;
    cursor: pointer;
    display: inline-block;
}
.user-info:hover {
    text-decoration: underline;
}

/* ========== 网格容器 ========== */
.grid-container {
    height: calc(100vh - 3em);
    padding: 0.5em;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(5, minmax(145px, auto));
    gap: 0.5em;
    overflow-y: auto;
    overflow-x: hidden;
    align-content: start;
}

/* 滚动条美化 */
.grid-container::-webkit-scrollbar,
.lamp-list::-webkit-scrollbar {
    width: 6px;
}
.grid-container::-webkit-scrollbar-thumb,
.lamp-list::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}
.grid-container::-webkit-scrollbar-track,
.lamp-list::-webkit-scrollbar-track {
    background: #1a1f27;
}

/* ========== 通用卡片样式 ========== */
.card {
    background: #22262b;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 0.4em 0.5em;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.2s ease;
    min-height: 145px;
}
.card-empty {
    background: #1a1f27;
    border: 1px dashed #2a2f37;
    opacity: 0.3;
}

/* ========== 卡片状态色 ========== */
/* 汤池 */
.pool-card-normal { border-color: #2e7d32; }
.pool-card-nodata { background-color: #c62828; border-color: #b71c1c; }
.pool-card-offline { background-color: #c62828; border-color: #b71c1c; opacity: 0.95; }

/* 大罐 */
.card.tank-card.tank-card-normal { border-color: #2e7d32 !important; }
.card.tank-card.tank-card-warning { background-color: #3d2f0b !important; border-color: #b8860b !important; }
.card.tank-card.tank-card-offline { background-color: #2b1a1a !important; border-color: #c62828 !important; opacity: 0.95 !important; }

/* 管道 */
.pipe-card-normal { border-color: #2e7d32 !important; }
.pipe-card-warning { background-color: #3d2f0b !important; border-color: #b8860b !important; }
.pipe-card-offline { background-color: #2b1a1a !important; border-color: #c62828 !important; opacity: 0.95 !important; }

/* 浴场 */
.card.bath-card.bath-card-normal { border-color: #2e7d32 !important; }
.card.bath-card.bath-card-warning { background-color: #3d2f0b !important; border-color: #b8860b !important; }
.card.bath-card.bath-card-offline { background-color: #2b1a1a !important; border-color: #c62828 !important; opacity: 0.95 !important; }

/* 路灯分组 */
.lamp-card-normal { border-color: #2e7d32; }
.lamp-card-warning { border-color: #b71c1c; }
.lamp-card-offline { border-color: #b71c1c; opacity: 0.95; }

/* ========== 卡片头部（通用） ========== */
.pool-header-row,
.tank-header-row,
.pipe-header-row,
.bath-header-row {
    padding-bottom: 0.25em;
    border-bottom: 1px dashed #333;
    margin-bottom: 0.2em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
}

.pool-header-row .pool-name,
.tank-header-row .tank-name,
.pipe-header-row .pipe-name,
.bath-header-row .bath-name {
    font-size: 1em;
    color: #4fc3f7;
    font-weight: bold;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pool-header-row .pool-ip,
.tank-header-row .tank-ip,
.pipe-header-row .pipe-ip,
.bath-header-row .bath-ip {
    font-size: 0.75em;
    color: #9e9e9e;
    font-weight: normal;
    flex-shrink: 0;
}

.ctrl-btn {
    font-size: 0.75em;
    padding: 0.2em 0.6em;
    background: #1976d2;
    color: #fff;
    border-radius: 3px;
    cursor: pointer;
    flex-shrink: 0;
    border: none;
    white-space: nowrap;
}
.ctrl-btn:hover {
    background: #1565c0;
}

/* ========== 汤池头部操作按钮 ========== */
.pool-ctrl-btns {
    flex-shrink: 0;
    display: inline-flex;
    gap: 4px;
    vertical-align: middle;
}
.mini-btn {
    padding: 2px 6px;
    font-size: 12px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    color: #ffffff;
    line-height: 1.4;
    white-space: nowrap;
    flex-shrink: 0;
}
.mini-btn:hover {
    opacity: 0.9;
}
.run-btn {
    background-color: #2e7d32;
}
.stop-btn {
    background-color: #c62828;
}

/* ========== 卡片内容通用 ========== */
.card-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 3px;
    justify-content: flex-start;
}
.card-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    line-height: 1.4;
    white-space: nowrap;
}
.card-row > span {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
}
.card-label {
    color: #9e9e9e;
    font-size: 0.85em;
}
.card-value {
    color: #e0e0e0;
    text-align: right;
    font-size: 0.85em;
}

/* 通用状态色 */
.status-online { color: #4caf50; }
.status-offline { color: #f44336; }
.val-on { color: #4caf50; }
.val-off { color: #9e9e9e; }

/* 汤池大字温度 */
.pool-card .pv-temp {
    font-size: clamp(15px, 1.6vw, 22px);
    font-weight: bold;
    color: #ffffff;
    line-height: 1.1;
}
.pool-card .card-value.alarm {
    color: #f44336;
    font-weight: 500;
}

/* 更新时间行 */
.update-time-row .card-label,
.update-time-row .card-value,
.tank-time-row .card-label,
.tank-time-row .card-value,
.pipe-time-row .card-label,
.pipe-time-row .card-value,
.bath-time-row .card-label,
.bath-time-row .card-value {
    font-size: 0.7em;
    color: #757575;
}

/* ========== 大罐卡片 ========== */
.tank-big-value {
    font-size: clamp(15px, 1.6vw, 22px);
    font-weight: bold;
    color: #ffffff;
    white-space: nowrap;
    display: inline-block;
}
.tank-card .val-normal { color: #4caf50; }
.tank-card .val-alarm { color: #f44336; }

/* 三相电区域 */
.tank-phase-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 2px;
    margin-top: 2px;
    border-top: 1px solid #2a2f37;
    font-size: 0.82em;
}
.tank-phase-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.tank-phase-label {
    color: #a0a0a0;
    font-size: 0.85em;
    width: 4.5em;
    flex-shrink: 0;
}
.tank-phase-items {
    display: flex;
    gap: 0.6em;
    flex: 1;
    justify-content: flex-end;
}
.tank-phase-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    line-height: 1.2;
    min-width: 3.8em;
    text-align: right;
}

/* 三相电数值颜色 */
.phase-val-normal {
    color: #4caf50;
    font-weight: 500;
}
.phase-val-alarm {
    color: #f44336;
    font-weight: 500;
}

/* ========== 管道卡片 ========== */
.pipe-card .pipe-header-row {
    padding-bottom: 0.25em;
    border-bottom: 1px dashed #333;
    margin-bottom: 0.3em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
}

.pipe-card .pipe-name {
    font-size: 1em;
    color: #4fc3f7;
    font-weight: bold;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pipe-card .pipe-ip {
    font-size: 0.75em;
    color: #9e9e9e;
    font-weight: normal;
    flex-shrink: 0;
}

/* 核心数值区：水位 + 温度 左右分栏 */
.pipe-core-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin: 0.2em 0 0.3em;
}

.pipe-core-item {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.pipe-big-value {
    font-size: clamp(18px, 1.8vw, 26px);
    font-weight: bold;
    color: #ffffff;
    line-height: 1.1;
}

.pipe-unit {
    font-size: 0.75em;
    color: #9e9e9e;
}

/* 参数状态区：水位设定 + 阀门状态 */
.pipe-info-row {
    display: flex;
    justify-content: space-between;
    padding-top: 0.3em;
    border-top: 1px solid #2a2f37;
    margin-top: 0.2em;
}

.pipe-info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pipe-info-label {
    font-size: 0.75em;
    color: #9e9e9e;
}

.pipe-info-value {
    font-size: 0.85em;
    color: #e0e0e0;
}

/* 阀门状态色 */
.pipe-card .valve-on { color: #4caf50; font-weight: 500; }
.pipe-card .valve-off { color: #9e9e9e; }

/* 更新时间 */
.pipe-time-row {
    margin-top: auto;
    padding-top: 0.3em;
}

.pipe-time-row .card-label,
.pipe-time-row .card-value {
    font-size: 0.7em;
    color: #757575;
}

/* 卡片状态色 */
.pipe-card-normal { border-color: #2e7d32 !important; }
.pipe-card-warning { background-color: #3d2f0b !important; border-color: #b8860b !important; }
.pipe-card-offline { background-color: #2b1a1a !important; border-color: #c62828 !important; opacity: 0.95 !important; }

/* ========== 浴场卡片 ========== */
.bath-big-state {
    font-size: clamp(15px, 1.6vw, 24px);
    font-weight: bold;
}

/* 有人状态红色高亮（与JS的person-on类对应） */
.bath-card .person-on {
    color: #f44336;
}

/* ========== 路灯分组卡片 ========== */
.card-title {
    font-size: 1em;
    color: #4fc3f7;
    margin-bottom: 0.4em;
    padding-bottom: 0.3em;
    border-bottom: 1px dashed #333;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-title .tag {
    float: right;
    font-size: 0.7em;
    padding: 0.1em 0.35em;
    border-radius: 3px;
    background: #2a2f37;
    color: #ffb74d;
    font-weight: normal;
}

.lamp-list {
    flex: 1;
    overflow-y: auto;
}
.lamp-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3em 0;
    border-bottom: 1px solid #2a2f37;
    font-size: 0.78em;
}
.lamp-item:last-child {
    border-bottom: none;
}
.lamp-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.4em;
}
.lamp-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #e0e0e0;
    font-size: 1em;
}
.lamp-ip {
    font-size: 0.75em;
    color: #757575;
    flex-shrink: 0;
}
.lamp-right {
    display: flex;
    align-items: center;
    gap: 0.5em;
    flex-shrink: 0;
}
.lamp-online-tag {
    font-size: 0.7em;
    padding: 1px 4px;
    border-radius: 2px;
}
.lamp-online-tag.online { color: #4caf50; background: rgba(76,175,80,0.1); }
.lamp-online-tag.nodata { color: #ffb74d; background: rgba(255,183,77,0.1); }
.lamp-online-tag.offline { color: #f44336; background: rgba(244,67,54,0.1); }
.lamp-states {
    display: flex;
    gap: 0.4em;
}
.lamp-states span {
    font-size: 0.72em;
    padding: 1px 4px;
    border-radius: 2px;
    min-width: 2em;
    text-align: center;
}

/* ========== 弹窗通用 ========== */
.modal-mask {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    justify-content: center;
    align-items: center;
    z-index: 999;
}
.modal {
    background: #22262b;
    border: 1px solid #333;
    border-radius: 6px;
    width: 31.25em;
    max-height: 85vh;
    padding: 1.375em;
    overflow-y: auto;
}
.modal-title {
    font-size: 1.125em;
    color: #4fc3f7;
    margin-bottom: 1.125em;
    padding-bottom: 0.75em;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: -1.375em;
    background: #22262b;
    padding-top: 0.75em;
}
.modal-close {
    cursor: pointer;
    color: #9e9e9e;
    font-size: 1.25em;
}
.modal-close:hover {
    color: #fff;
}

.form-row {
    display: flex;
    align-items: center;
    margin-bottom: 0.875em;
    gap: 0.75em;
}
.form-label {
    width: 6.25em;
    font-size: 0.875em;
    color: #aaa;
    flex-shrink: 0;
}
.form-input {
    flex: 1;
    background: #2a2f37;
    border: 1px solid #444;
    color: #e0e0e0;
    padding: 0.4375em 0.75em;
    border-radius: 4px;
    outline: none;
    font-size: 0.875em;
}
.form-input:focus {
    border-color: #1976d2;
}
.form-btn {
    width: 4.6875em;
    padding: 0.4375em 0;
    background: #1976d2;
    border: none;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    flex-shrink: 0;
}
.form-btn:hover {
    background: #1565c0;
}
.form-btn:disabled {
    background: #555;
    cursor: not-allowed;
}

/* ========== 响应式适配 ========== */
/* 平板/小屏电脑 */
@media screen and (max-width: 1200px) {
    .grid-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* 手机横屏/大屏手机 */
@media screen and (max-width: 768px) {
    .grid-container {
        grid-template-columns: repeat(3, 1fr);
    }
    .pool-ip, .tank-ip, .pipe-ip, .bath-ip {
        display: none;
    }
    .mini-btn {
        padding: 2px 4px;
        font-size: 11px;
    }
    .ctrl-btn {
        padding: 2px 5px;
        font-size: 11px;
    }
}

/* 手机竖屏 */
@media screen and (max-width: 480px) {
    .grid-container {
        grid-template-columns: repeat(2, 1fr);
        padding: 0.3em;
        gap: 0.3em;
    }
    .card {
        padding: 0.35em 0.4em;
        min-height: 130px;
    }
    .mini-btn {
        padding: 1px 3px;
        font-size: 10px;
    }
    .ctrl-btn {
        padding: 1px 3px;
        font-size: 10px;
    }
    .pool-ctrl-btns {
        gap: 2px;
    }
}

/* 低高度屏幕适配 */
@media screen and (max-height: 850px) {
    html, body { font-size: 12px; }
    .grid-container {
        grid-template-rows: repeat(5, minmax(135px, auto));
    }
    .card {
        min-height: 135px;
        padding: 0.35em 0.45em;
    }
}
/* 三相电数值颜色 */
.phase-val-normal {
    color: #4caf50;
}
.phase-val-alarm {
    color: #f44336;
}
.tank-phase-item {
    text-align: right;
    min-width: 3.8em;
    line-height: 1.4;
}
/* 汤池头部按钮组 */
.pool-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-wrap: nowrap;
    gap: 6px;
    padding-bottom: 4px;
    border-bottom: 1px dashed #333;
    margin-bottom: 4px;
}

.pool-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1em;
    color: #4fc3f7;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pool-ip {
    font-size: 0.75em;
    color: #9e9e9e;
    font-weight: normal;
}

.pool-ctrl-btns {
    flex-shrink: 0;
    display: inline-flex;
    gap: 4px;
    vertical-align: middle;
}

.mini-btn {
    padding: 2px 6px;
    font-size: 12px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    color: #ffffff;
    line-height: 1.4;
    white-space: nowrap;
}

.mini-btn:hover {
    opacity: 0.9;
}

.run-btn {
    background-color: #2e7d32;
}

.stop-btn {
    background-color: #c62828;
}

.ctrl-btn {
    flex-shrink: 0;
    font-size: 0.75em;
    padding: 0.2em 0.6em;
    background: #1976d2;
    color: #fff;
    border-radius: 3px;
    cursor: pointer;
    border: none;
}

/* 移动端适配 */
@media screen and (max-width: 768px) {
    .pool-ip {
        display: none;
    }
    .mini-btn {
        padding: 2px 4px;
        font-size: 11px;
    }
    .ctrl-btn {
        padding: 2px 5px;
        font-size: 11px;
    }
}
/* ========== 统一离线状态 - 鲜红底色（不含路灯卡片） ========== */
/* 汤池/大罐/管道/浴场 离线：鲜红底色 + 白字 */
.pool-card-offline,
.card.tank-card.tank-card-offline,
.pipe-card-offline,
.card.bath-card.bath-card-offline {
    background-color: #d32f2f !important;
    border-color: #b71c1c !important;
    box-shadow: 0 0 10px rgba(211, 47, 47, 0.6) inset !important;
    opacity: 1 !important;
}

/* 汤池/大罐/管道/浴场 离线：设备名称白色 */
.pool-card-offline .pool-name,
.tank-card-offline .tank-name,
.pipe-card-offline .pipe-name,
.bath-card-offline .bath-name {
    color: #ffffff !important;
}

/* 汤池/大罐/管道/浴场 离线：主数值白色 */
.pool-card-offline .pv-temp,
.tank-card-offline .tank-big-value,
.pipe-card-offline .pipe-big-value,
.bath-card-offline .bath-big-state {
    color: #ffffff !important;
}

/* 汤池/大罐/管道/浴场 离线：次要信息浅红 */
.pool-card-offline .card-label,
.pool-card-offline .card-value,
.tank-card-offline .card-label,
.tank-card-offline .card-value,
.pipe-card-offline .card-label,
.pipe-card-offline .card-value,
.bath-card-offline .card-label,
.bath-card-offline .card-value {
    color: #ffe0e0 !important;
}

/* 汤池/大罐/管道/浴场 离线：更新时间浅红 */
.pool-card-offline .update-time-row .card-label,
.pool-card-offline .update-time-row .card-value,
.tank-card-offline .tank-time-row .card-label,
.tank-card-offline .tank-time-row .card-value,
.pipe-card-offline .pipe-time-row .card-label,
.pipe-card-offline .pipe-time-row .card-value,
.bath-card-offline .bath-time-row .card-label,
.bath-card-offline .bath-time-row .card-value {
    color: #ffb3b3 !important;
}

/* ========== 路灯卡片离线：底色不变，仅边框文字变红 ========== */
.lamp-card-offline {
    border-color: #ff3333 !important;
    /* 背景保持原有深色，不做修改 */
    background-color: #22262b !important;
    opacity: 1 !important;
}

.lamp-card-offline .card-title {
    color: #ff7070 !important;
}

/* 路灯分组内离线子项标签 */
.lamp-online-tag.offline {
    color: #ffffff !important;
    background: #b71c1c !important;
}
/* ========== 汤池运行/停止按钮状态样式（强制生效） ========== */
/* 运行按钮：启用态 - 绿色 */
.pool-card .pool-ctrl-btns .mini-btn.run-btn {
    background-color: #2e7d32 !important;
    color: #ffffff !important;
    cursor: pointer !important;
    border: none !important;
}

/* 运行按钮：禁用态 - 灰色 */
.pool-card .pool-ctrl-btns .mini-btn.run-btn[disabled] {
    background-color: #616161 !important;
    color: #9e9e9e !important;
    cursor: not-allowed !important;
    opacity: 0.8 !important;
}

/* 停止按钮：启用态 - 红色 */
.pool-card .pool-ctrl-btns .mini-btn.stop-btn {
    background-color: #c62828 !important;
    color: #ffffff !important;
    cursor: pointer !important;
    border: none !important;
}

/* 停止按钮：禁用态 - 灰色 */
.pool-card .pool-ctrl-btns .mini-btn.stop-btn[disabled] {
    background-color: #616161 !important;
    color: #9e9e9e !important;
    cursor: not-allowed !important;
    opacity: 0.8 !important;
}
/* 阀门行标签文字放大 */
.pipe-card .pipe-valve-row .card-label {
    font-size: 1.1em;
}

/* 阀门状态文字进一步放大+加粗 */
.pipe-card .pipe-valve-open,
.pipe-card .pipe-valve-close {
    font-size: 1.4em !important;
    font-weight: 700;
}

.pipe-card .pipe-valve-open {
    color: #4caf50 !important;
}

.pipe-card .pipe-valve-close {
    color: #f44336 !important;
}
/* 汤池卡片：数据标签文字放大20% */
.pool-card .card-label {
    font-size: 1.02em;
}

/* 汤池卡片：普通数值文字放大20%（实时温度大数字除外） */
.pool-card .card-value:not(.pv-temp) {
    font-size: 1.02em;
}

/* 汤池卡片：更新时间文字放大20% */
.pool-card .update-time-row .card-label,
.pool-card .update-time-row .card-value {
    font-size: 0.84em;
}

/* 汤池卡片：头部设备名称放大20% */
.pool-card .pool-name {
    font-size: 1.2em;
}

/* 汤池卡片：头部IP地址放大20% */
.pool-card .pool-ip {
    font-size: 0.9em;
}