/* ============================================================
   TaihuGuard — BD-2 单屏三态 · 亮色玻璃拟态
   全屏卫星地图 + 白色毛玻璃浮层
   ============================================================ */

:root {
    --blue: #2563eb;
    --blue-soft: rgba(37, 99, 235, 0.1);
    --ink: #0f172a;
    --ink-2: #475569;
    --ink-3: #94a3b8;
    --glass-bg: rgba(255, 255, 255, 0.78);
    --glass-bg-solid: rgba(255, 255, 255, 0.94);
    --glass-border: rgba(255, 255, 255, 0.65);
    --glass-shadow: 0 8px 32px rgba(15, 23, 42, 0.14);
    --radius: 16px;
    --radius-sm: 10px;
    --green: #22c55e;
    --lime: #84cc16;
    --yellow: #eab308;
    --orange: #f97316;
    --red: #ef4444;
    --dark-red: #991b1b;
    --gray: #6b7280;
    --dock-h: 64px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

[hidden] { display: none !important; }

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    color: var(--ink);
    background: #eef4f8;
    -webkit-font-smoothing: antialiased;
}

/* ==================== 地图 ==================== */
#mapWrap { position: fixed; inset: 0; }
.map-pane { position: absolute; inset: 0; }
#mapB { visibility: hidden; }
body.comparing #mapB { visibility: visible; }

.mapboxgl-ctrl-logo { opacity: 0.5; }
.mapboxgl-ctrl-attrib { font-size: 10px; opacity: 0.75; }

/* 卷帘手柄 */
.mapboxgl-compare {
    background: rgba(255, 255, 255, 0.9);
    width: 3px;
    box-shadow: 0 0 12px rgba(15, 23, 42, 0.35);
}
.mapboxgl-compare .compare-swiper-vertical {
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.3);
    width: 44px; height: 44px; margin: -22px;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6 3 12l6 6M15 6l6 6-6 6'/%3E%3C/svg%3E");
    background-size: 22px; background-repeat: no-repeat; background-position: center;
}

/* ==================== 玻璃基类 ==================== */
.glass {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(18px) saturate(1.35);
    backdrop-filter: blur(18px) saturate(1.35);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: var(--radius);
}

/* ==================== 品牌 ==================== */
.brand-pill {
    position: fixed; top: 14px; left: 14px; z-index: 30;
    display: flex; align-items: center; gap: 10px;
    padding: 9px 16px 9px 12px;
}
.brand-logo { width: 30px; height: 30px; flex: none; }
.brand-title { font-size: 15px; font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { font-size: 10.5px; color: var(--ink-3); letter-spacing: 0.06em; margin-top: 1px; }

/* ==================== 每日简报 ==================== */
.briefing-pill {
    position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
    z-index: 29; max-width: min(680px, calc(100vw - 480px));
    padding: 9px 18px; display: flex; align-items: center; gap: 8px;
    border-radius: 999px; cursor: default;
}
.briefing-text {
    font-size: 12.5px; color: var(--ink-2); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.briefing-text strong { color: var(--ink); }
.briefing-text .b-warn { color: var(--orange); font-weight: 600; }
.briefing-text .b-ok { color: var(--green); font-weight: 600; }

/* ==================== 更新时间 ==================== */
.update-chip {
    position: fixed; top: 14px; right: 14px; z-index: 30;
    display: flex; align-items: center; gap: 7px;
    padding: 8px 14px; border-radius: 999px;
    font-size: 11.5px; color: var(--ink-2);
}
.pulse-dot {
    width: 7px; height: 7px; border-radius: 50%; background: var(--green);
    animation: pulse-soft 2.4s infinite;
}
@keyframes pulse-soft {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    50% { box-shadow: 0 0 0 5px rgba(34, 197, 94, 0); }
}

/* ==================== 左侧图标栏 ==================== */
.rail {
    position: fixed; left: 14px; top: 50%; transform: translateY(-50%);
    z-index: 28; display: flex; flex-direction: column; gap: 4px;
    padding: 8px 6px;
}
.rail-btn {
    position: relative; width: 42px; height: 42px; border: none; background: transparent;
    border-radius: 12px; cursor: pointer; color: var(--ink-2);
    display: flex; align-items: center; justify-content: center;
    transition: background 0.18s, color 0.18s;
}
.rail-btn svg { width: 21px; height: 21px; }
.rail-btn:hover { background: rgba(37, 99, 235, 0.08); color: var(--blue); }
.rail-btn.active { background: var(--blue); color: #fff; }
.rail-badge {
    position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px;
    border-radius: 8px; background: var(--red); color: #fff;
    font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
    padding: 0 4px;
}

/* ==================== 浮层面板 ==================== */
.flyout {
    position: fixed; left: 72px; top: 50%; transform: translateY(-50%);
    z-index: 27; width: 250px; padding: 16px;
    max-height: 76vh; overflow-y: auto;
}
.flyout-wide { width: 320px; }
.flyout-title {
    font-size: 13px; font-weight: 700; margin-bottom: 12px;
    display: flex; align-items: baseline; gap: 8px;
}
.flyout-sub { font-size: 10.5px; font-weight: 400; color: var(--ink-3); }

.layer-row {
    display: flex; align-items: center; gap: 9px; padding: 8px 4px;
    font-size: 13px; cursor: pointer; border-radius: 8px;
}
.layer-row:hover { background: rgba(37, 99, 235, 0.05); }
.layer-row input { accent-color: var(--blue); width: 15px; height: 15px; }
.layer-row em { margin-left: auto; font-style: normal; font-size: 11px; color: var(--ink-3); }
.layer-row input:disabled + span { color: var(--ink-3); }
.layer-sub {
    display: flex; align-items: center; gap: 8px; padding: 8px 4px 2px 28px;
    font-size: 12px; color: var(--ink-2);
}
.layer-note { font-size: 11px; color: var(--ink-3); padding: 8px 4px 0; line-height: 1.5; }

.sel {
    border: 1px solid rgba(15, 23, 42, 0.14); border-radius: 8px;
    background: rgba(255, 255, 255, 0.85); color: var(--ink);
    font-size: 12px; padding: 5px 8px; outline: none; cursor: pointer;
}
.sel:focus { border-color: var(--blue); }

.stats-donut { width: 100%; height: 170px; }
.stats-list { display: flex; flex-direction: column; gap: 5px; margin-top: 4px; }
.stats-item {
    display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2);
}
.stats-item .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.stats-item .cnt { margin-left: auto; font-weight: 600; color: var(--ink); }

.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    background: rgba(255, 255, 255, 0.65); border-radius: var(--radius-sm);
    border-left: 3px solid var(--yellow); cursor: pointer;
    transition: transform 0.15s;
}
.alert-item:hover { transform: translateX(2px); }
.alert-item .a-name { font-size: 13px; font-weight: 600; }
.alert-item .a-basin { font-size: 11px; color: var(--ink-3); }
.alert-item .a-chip {
    margin-left: auto; font-size: 11px; font-weight: 600; padding: 3px 9px;
    border-radius: 999px;
}
.alert-empty { font-size: 12px; color: var(--ink-3); padding: 10px 4px; line-height: 1.6; }

.about-body p { font-size: 12.5px; color: var(--ink-2); line-height: 1.7; margin-bottom: 10px; }
.about-body strong { color: var(--ink); }
.about-foot { font-size: 11px !important; color: var(--ink-3) !important; border-top: 1px solid rgba(15,23,42,0.08); padding-top: 10px; }

/* ==================== 右侧信息列 ==================== */
.right-col {
    position: fixed; top: 64px; right: 14px; z-index: 26;
    width: 300px; display: flex; flex-direction: column; gap: 12px;
    max-height: calc(100vh - 64px - var(--dock-h) - 28px);
    overflow-y: auto; scrollbar-width: none;
}
.right-col::-webkit-scrollbar { display: none; }

.card { padding: 14px 16px; }
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 13px; font-weight: 700; margin-bottom: 10px;
}
.card-sub { font-size: 10.5px; font-weight: 400; color: var(--ink-3); }
.card-count {
    min-width: 20px; height: 20px; border-radius: 10px; background: var(--red);
    color: #fff; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center;
    padding: 0 6px;
}
.card-count.zero { background: var(--green); }

.health-tag {
    font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
    border: 1px solid transparent;
}
.health-body { display: flex; align-items: center; gap: 8px; }
.health-ring { width: 118px; height: 118px; flex: none; }
.health-breakdown { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.hb-item { font-size: 10.5px; color: var(--ink-3); }
.hb-item .hb-top { display: flex; justify-content: space-between; margin-bottom: 2px; }
.hb-item .hb-val { color: var(--ink-2); font-weight: 600; }
.hb-bar { height: 4px; border-radius: 2px; background: rgba(15, 23, 42, 0.07); overflow: hidden; }
.hb-fill { height: 100%; border-radius: 2px; background: var(--blue); }

.kpi-row {
    display: flex; justify-content: space-between; margin-top: 12px;
    padding-top: 10px; border-top: 1px solid rgba(15, 23, 42, 0.07);
}
.kpi { text-align: center; }
.kpi-v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-v small { font-size: 9.5px; font-weight: 500; color: var(--ink-3); margin-left: 1px; }
.kpi-l { font-size: 9.5px; color: var(--ink-3); margin-top: 1px; }

.alerts-mini { display: flex; flex-direction: column; gap: 7px; }
.alerts-mini .alert-item { padding: 8px 10px; }
.alerts-more { font-size: 11px; color: var(--blue); cursor: pointer; text-align: center; padding-top: 2px; }

.ind-list { display: flex; flex-direction: column; }
.ind-row {
    display: flex; align-items: center; gap: 8px; padding: 7px 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.05); font-size: 12.5px;
}
.ind-row:last-child { border-bottom: none; }
.ind-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.ind-name { color: var(--ink-2); }
.ind-unit { font-size: 10px; color: var(--ink-3); }
.ind-val { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.ind-trend { font-size: 10.5px; width: 44px; text-align: right; flex: none; }
.ind-trend.up { color: var(--orange); }
.ind-trend.down { color: var(--green); }
.ind-trend.flat { color: var(--ink-3); }

/* ==================== 站点抽屉 ==================== */
.drawer {
    position: fixed; top: 64px; right: 14px; bottom: calc(var(--dock-h) + 14px);
    z-index: 31; width: 360px; padding: 18px;
    display: flex; flex-direction: column; overflow-y: auto;
    background: var(--glass-bg-solid);
}
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; }
.drawer-name { font-size: 19px; font-weight: 800; }
.drawer-meta { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.icon-btn {
    border: none; background: rgba(15, 23, 42, 0.06); color: var(--ink-2);
    width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 13px;
}
.icon-btn:hover { background: rgba(15, 23, 42, 0.12); }
.drawer-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip {
    font-size: 11px; font-weight: 600; padding: 4px 11px; border-radius: 999px;
    border: 1px solid transparent;
}
.drawer-section-title {
    font-size: 12px; font-weight: 700; color: var(--ink-2);
    margin: 16px 0 8px; display: flex; justify-content: space-between; align-items: baseline;
}
.drawer-time { font-size: 10.5px; font-weight: 400; color: var(--ink-3); }
.drawer-table { width: 100%; border-collapse: collapse; }
.drawer-table td { padding: 6px 2px; font-size: 12.5px; border-bottom: 1px solid rgba(15, 23, 42, 0.05); }
.drawer-table td:nth-child(2) { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.drawer-table td:nth-child(2) small { font-size: 10px; font-weight: 400; color: var(--ink-3); }
.drawer-table td:nth-child(3) { text-align: right; width: 52px; }
.eval-chip {
    font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
}
.eval-high { background: rgba(249, 115, 22, 0.12); color: var(--orange); }
.eval-low { background: rgba(59, 130, 246, 0.12); color: var(--blue); }
.eval-ok { background: rgba(34, 197, 94, 0.12); color: #16a34a; }
.eval-na { background: rgba(107, 114, 128, 0.1); color: var(--gray); }
.drawer-chart { width: 100%; height: 180px; margin-top: 4px; }
.drawer-analyze {
    margin-top: 14px; border: none; width: 100%; padding: 10px;
    border-radius: var(--radius-sm); background: var(--blue); color: #fff;
    font-size: 13px; font-weight: 600; cursor: pointer;
}
.drawer-analyze:hover { background: #1d4ed8; }

/* ==================== 底部 dock ==================== */
.dock {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: calc(12px + var(--safe-bottom)); z-index: 32;
    width: min(880px, calc(100vw - 150px));
    padding: 4px 18px 10px;
    transition: width 0.25s ease;
}
body.sheet-open .dock { width: min(1080px, calc(100vw - 150px)); }
.dock-handle {
    display: flex; justify-content: center; padding: 5px 0 3px; cursor: pointer;
}
.dock-handle span {
    width: 42px; height: 4.5px; border-radius: 3px; background: rgba(15, 23, 42, 0.18);
    transition: background 0.2s;
}
.dock-handle:hover span { background: var(--blue); }

.timeline-row { display: flex; align-items: center; gap: 12px; }
.tl-play, .tl-reset {
    border: none; width: 32px; height: 32px; border-radius: 50%;
    background: var(--blue); color: #fff; cursor: pointer; font-size: 12px; flex: none;
}
.tl-reset { background: rgba(15, 23, 42, 0.08); color: var(--ink-2); font-size: 15px; }
.tl-track { flex: 1; position: relative; height: 34px; }
.tl-track input[type=range] {
    width: 100%; position: absolute; top: 4px; -webkit-appearance: none; appearance: none;
    height: 5px; border-radius: 3px; outline: none;
    background: linear-gradient(to right, rgba(148, 163, 184, 0.45) 0%, rgba(148, 163, 184, 0.45) 50%, rgba(37, 99, 235, 0.3) 50%, rgba(37, 99, 235, 0.3) 100%);
}
.tl-track input::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 17px; height: 17px; border-radius: 50%;
    background: #fff; border: 3.5px solid var(--blue); cursor: pointer;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
}
.tl-track input::-moz-range-thumb {
    width: 15px; height: 15px; border-radius: 50%;
    background: #fff; border: 3.5px solid var(--blue); cursor: pointer;
}
.tl-ticks { position: absolute; left: 0; right: 0; top: 18px; height: 14px; pointer-events: none; }
.tl-tick-label {
    position: absolute; transform: translateX(-50%); font-size: 9.5px; color: var(--ink-3);
    white-space: nowrap;
}
.tl-tick-label.now { color: var(--blue); font-weight: 700; }
.tl-date { font-size: 12px; font-weight: 600; min-width: 118px; text-align: center; flex: none; }
.tl-date .tl-tag { font-size: 10px; font-weight: 500; color: var(--ink-3); display: block; }

/* 分析面板 */
.sheet-body { padding-top: 8px; border-top: 1px solid rgba(15, 23, 42, 0.07); margin-top: 6px; }
.sheet-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.param-chips { display: flex; gap: 5px; flex-wrap: wrap; flex: 1; }
.p-chip {
    border: 1px solid rgba(15, 23, 42, 0.12); background: rgba(255, 255, 255, 0.6);
    color: var(--ink-2); font-size: 11.5px; font-weight: 600;
    padding: 5px 12px; border-radius: 999px; cursor: pointer; transition: all 0.15s;
}
.p-chip:hover { border-color: var(--blue); color: var(--blue); }
.p-chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.sheet-station { min-width: 170px; }
.sheet-chart { width: 100%; height: clamp(180px, 26vh, 260px); margin-top: 6px; }
.ai-strip {
    display: flex; align-items: center; gap: 10px; margin-top: 4px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    background: rgba(37, 99, 235, 0.06);
}
.ai-badge {
    flex: none; font-size: 10.5px; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    padding: 3px 9px; border-radius: 6px;
}
.ai-text { font-size: 12px; color: var(--ink-2); line-height: 1.5; }
.ai-conf { color: var(--ink-3); font-size: 11px; margin-left: auto; flex: none; }

/* ==================== 对比模式 ==================== */
.compare-bar {
    position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
    z-index: 33; display: flex; align-items: center; gap: 12px;
    padding: 9px 16px; border-radius: 999px;
}
.cmp-label { font-size: 12px; font-weight: 700; }
.cmp-left { color: var(--blue); }
.cmp-right { color: #16a34a; }
.cmp-exit {
    border: none; background: rgba(15, 23, 42, 0.08); color: var(--ink-2);
    font-size: 12px; font-weight: 600; padding: 6px 13px; border-radius: 999px; cursor: pointer;
}
.cmp-exit:hover { background: var(--red); color: #fff; }
body.comparing .right-col, body.comparing .drawer { display: none; }
body.comparing .briefing-pill { display: none; }

/* ==================== 图例 ==================== */
.legend-card {
    position: fixed; right: 14px; bottom: calc(var(--dock-h) + 26px + var(--safe-bottom)); z-index: 25;
    padding: 10px 14px; width: 190px;
}
body.comparing .legend-card { right: 60px; }
.legend-title { font-size: 11px; font-weight: 700; margin-bottom: 6px; }
.legend-ramp { height: 8px; border-radius: 4px; }
.legend-labels { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--ink-3); margin-top: 3px; }

/* ==================== 站点标记 ==================== */
.station-marker { will-change: transform; }
.station-dot.selected {
    transform: scale(1.35);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.35) !important;
}
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
    50% { box-shadow: 0 0 0 9px rgba(239, 68, 68, 0); }
}
.mapboxgl-popup-content {
    border-radius: 12px; padding: 12px 14px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.18);
    font-family: inherit;
}
.popup-title { font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.popup-level { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.popup-params { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 14px; margin: 8px 0; }
.popup-param { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-2); gap: 8px; }
.popup-param .val { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.popup-bloom { font-size: 11px; color: var(--ink-2); border-top: 1px solid rgba(15,23,42,0.07); padding-top: 6px; }

/* ==================== 移动端 ==================== */
@media (max-width: 860px) {
    .briefing-pill { display: none; }
    .rail {
        left: 10px; top: auto; bottom: calc(238px + var(--safe-bottom)); transform: none;
        padding: 6px 5px;
    }
    .rail-btn { width: 38px; height: 38px; }
    .flyout {
        left: 60px; right: 10px; top: auto; bottom: calc(238px + var(--safe-bottom));
        transform: none; width: auto; max-height: 44vh;
    }
    .right-col {
        top: auto; bottom: calc(76px + var(--safe-bottom)); right: 0; left: 0; width: auto;
        flex-direction: row; overflow-x: auto; overflow-y: hidden;
        padding: 0 10px; gap: 10px; max-height: none;
        scroll-snap-type: x mandatory;
    }
    .right-col .card { flex: none; width: 262px; scroll-snap-align: start; max-height: 148px; overflow-y: auto; }
    .health-ring { width: 88px; height: 88px; }
    .health-breakdown { gap: 3px; }
    .kpi-row { margin-top: 8px; padding-top: 7px; }
    .drawer {
        top: 90px; left: 10px; right: 10px; bottom: calc(76px + var(--safe-bottom));
        width: auto; z-index: 40;
    }
    .dock {
        width: calc(100vw - 20px); bottom: calc(8px + var(--safe-bottom));
        padding: 3px 12px 8px;
    }
    body.sheet-open .dock { width: calc(100vw - 20px); }
    body.sheet-open .right-col { display: none; }
    .tl-date { min-width: 86px; font-size: 11px; }
    .tl-ticks { display: none; }
    .tl-track { height: 22px; }
    .tl-track input[type=range] { top: 8px; }
    .sheet-chart { height: 190px; }
    .sheet-station { min-width: 130px; }
    .ai-conf { display: none; }
    .update-chip { top: auto; bottom: calc(226px + var(--safe-bottom)); right: 10px; display: none; }
    .compare-bar { top: 70px; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 20px); }
    .legend-card { bottom: calc(200px + var(--safe-bottom)); right: 10px; width: 150px; }
    body.comparing .right-col { display: none; }
}
