/* 凉山州智慧森林与碳汇管理平台 — 继承城市雷达暗色玻璃拟态风格 */
:root {
    --header-h: 96px; --side-l: 272px; --side-r: 344px;
    --ease: cubic-bezier(.2, .8, .2, 1);
    --line: rgba(148, 163, 184, .16);
    --accent: #7dd3fc;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body, html {
    width: 100vw; height: 100vh; overflow: hidden;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background:
        radial-gradient(900px 420px at 0% 0%, rgba(14, 165, 233, .14), transparent 55%),
        #070d18;
    color: #e2e8f0;
    -webkit-font-smoothing: antialiased;
}

/* ─── Header ─── */
.header {
    position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
    background: rgba(8, 12, 22, 0.88); backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
    display: flex; align-items: center; align-content: center; flex-wrap: wrap;
    padding: 8px 14px 6px; z-index: 2000; gap: 8px 10px;
    box-shadow: 0 1px 0 rgba(255,255,255,.04);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; margin-right: auto; }
.brand-icon { font-size: 22px; }
.header h1 {
    font-size: 15px; font-weight: 700; color: #e0f2fe; letter-spacing: 0; white-space: nowrap;
    max-width: min(280px, 34vw); overflow: hidden; text-overflow: ellipsis;
}
.subtitle { font-size: 10px; color: #64748b; white-space: nowrap; max-width: min(360px, 40vw); overflow: hidden; text-overflow: ellipsis; }
.header-spacer { display: none; }
.module-tabs {
    display: flex; gap: 2px; margin-left: 0; min-width: 0; order: 5;
    flex: 1 0 100%; overflow-x: auto; scrollbar-width: none; max-width: none;
    background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06);
    border-radius: 999px; padding: 3px;
}
.module-tabs::-webkit-scrollbar { display: none; }
.module-tabs .tab {
    background: transparent; border: 1px solid transparent; color: #94a3b8;
    font-size: 12.5px; padding: 6px 11px; border-radius: 999px; cursor: pointer; white-space: nowrap;
    transition: background .2s var(--ease), color .2s var(--ease), transform .2s var(--ease);
}
.module-tabs .tab:hover { color: #e0f2fe; background: rgba(255,255,255,.06); }
.module-tabs .tab:active { transform: scale(.97); }
.module-tabs .tab.active { color: #f8fafc; background: rgba(14,165,233,.28); border-color: transparent; box-shadow: 0 4px 16px rgba(14,165,233,.25); }
.basemap-sel {
    background: rgba(10,18,35,.9); color: #cbd5e1; border: 1px solid rgba(148,163,184,.28);
    border-radius: 999px; padding: 6px 10px; font-size: 12px; cursor: pointer; max-width: 168px;
}
.btn-ghost {
    background: rgba(15,23,42,.4); border: 1px solid rgba(148,163,184,.28); color: #bae6fd;
    border-radius: 999px; padding: 6px 12px; font-size: 12px; cursor: pointer; white-space: nowrap;
    transition: background .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.btn-ghost:hover { background: rgba(14,165,233,.14); border-color: rgba(125,211,252,.45); }
.btn-ghost:active, .btn-primary:active, .panel-pin:active, .panel-opener:active { transform: scale(.97); }
.btn-ghost:focus-visible, .module-tabs .tab:focus-visible { outline: 2px solid rgba(125,211,252,.7); outline-offset: 2px; }

/* ─── Map ─── */
#map { position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 26px; background: #0a0f1e; }
.leaflet-container { background: #0a0f1e; }

/* ─── 左侧图层面板 ─── */
.layer-panel {
    position: fixed; top: calc(var(--header-h) + 12px); left: 12px; width: 248px; z-index: 1500;
    transition: transform .32s var(--ease);
    background: rgba(10, 16, 30, 0.78); backdrop-filter: blur(18px);
    border: 1px solid rgba(148, 163, 184, 0.16); border-radius: 16px;
    padding: 14px; color: #e2e8f0; max-height: calc(100vh - var(--header-h) - 48px); overflow-y: auto;
    box-shadow: 0 16px 40px rgba(0,0,0,.35);
}
.layer-panel h3 {
    font-size: 12.5px; font-weight: 600; color: #38bdf8; margin: 10px 0 6px;
    display: flex; align-items: center; gap: 6px;
}
.layer-panel h3:first-child { margin-top: 0; }
.layer-row {
    display: flex; align-items: center; gap: 8px; padding: 6px 6px; cursor: pointer;
    font-size: 12.5px; border-radius: 8px;
}
.layer-row:hover { background: rgba(148,163,184,.08); }
.layer-row:last-child { border-bottom: none; }
.layer-row input { accent-color: #38bdf8; }
.layer-row small { color: #64748b; margin-left: auto; font-size: 10px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: none; }
.tier-chip {
    font-size: 9px; color: #4ade80; border: 1px solid rgba(74,222,128,.4);
    padding: 1px 6px; border-radius: 8px; margin-left: auto;
}
.choro-row { margin-bottom: 8px; }
.legend { margin: 8px 0 4px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 11px; color: #cbd5e1; padding: 2px 0; }
.legend-color { width: 22px; height: 12px; border-radius: 2px; flex: none; }
.slider { width: 100%; accent-color: #38bdf8; }
.panel-note { font-size: 10px; color: #64748b; line-height: 1.5; margin-top: 8px; }

/* ─── 右侧面板 ─── */
.right-panel {
    position: fixed; top: calc(var(--header-h) + 12px); right: 12px; width: 320px; z-index: 1500;
    max-height: calc(100vh - var(--header-h) - 36px); overflow-y: auto;
    display: flex; flex-direction: column; gap: 10px;
    transition: transform .32s var(--ease);
}
.layer-panel.is-hidden { transform: translateX(calc(-100% - 20px)); }
.right-panel.is-hidden { transform: translateX(calc(100% + 20px)); }
.panel-pin, .panel-opener {
    border: 1px solid rgba(148,163,184,.28); background: rgba(8,12,22,.88); color: #bae6fd;
    border-radius: 999px; font-size: 11px; padding: 4px 10px; cursor: pointer;
}
.panel-pin { align-self: flex-end; margin: 0 0 8px auto; }
.layer-panel .panel-pin { position: sticky; top: 0; z-index: 1; }
.panel-opener { position: fixed; z-index: 1600; top: calc(var(--header-h) + 14px); display: none; }
.panel-opener.left { left: 56px; }
.panel-opener.right { right: 12px; }
.layer-panel.is-hidden ~ .panel-opener.left, .panel-opener.left.on,
.right-panel.is-hidden ~ .panel-opener.right, .panel-opener.right.on { display: inline-block; }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi-card {
    background: rgba(10, 16, 30, 0.78); backdrop-filter: blur(18px);
    border: 1px solid rgba(148, 163, 184, 0.16); border-radius: 16px; padding: 10px 12px;
    transition: transform .22s var(--ease), border-color .22s var(--ease);
}
.kpi-card:hover { transform: translateY(-2px); border-color: rgba(125,211,252,.4); }
.kpi-card .k-label { font-size: 10.5px; color: #94a3b8; line-height: 1.35; min-height: 24px; }
.kpi-card .k-value { font-size: 20px; font-weight: 700; color: #e0f2fe; margin-top: 3px; }
.kpi-card .k-value small { font-size: 10px; color: #64748b; font-weight: 400; margin-left: 2px; }
.kpi-card .k-tier { font-size: 9px; margin-top: 4px; display: inline-block; padding: 1px 6px; border-radius: 8px; }
.tier-OBSERVED { color: #4ade80; border: 1px solid rgba(74,222,128,.35); }
.tier-OFFICIAL { color: #38bdf8; border: 1px solid rgba(56,189,248,.35); }
.tier-ESTIMATED { color: #fbbf24; border: 1px solid rgba(251,191,36,.35); }
.tier-NA { color: #64748b; border: 1px solid rgba(100,116,139,.35); }
.k-source { font-size: 9px; color: #64748b; margin-top: 5px; line-height: 1.45; }

.county-detail {
    background: rgba(10, 16, 30, 0.78); backdrop-filter: blur(18px);
    border: 1px solid rgba(148, 163, 184, 0.16); border-radius: 16px; padding: 12px;
}
.cd-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cd-head h3 { font-size: 14px; color: #38bdf8; }
.cd-sec { font-size: 11px; font-weight: 700; color: #7dd3fc; margin: 10px 0 4px; }
.cd-row { display: flex; justify-content: space-between; font-size: 11.5px; padding: 3px 0; border-bottom: 1px dashed rgba(100,180,255,.08); }
.cd-row .v { color: #e0f2fe; font-weight: 600; }
.cd-row .src { font-size: 9px; color: #64748b; }
.tier-badge { font-size: 8.5px; padding: 0 5px; border-radius: 6px; margin-left: 4px; }
.tier-badge.OBSERVED { color: #4ade80; border: 1px solid rgba(74,222,128,.4); }
.tier-badge.ESTIMATED { color: #fbbf24; border: 1px solid rgba(251,191,36,.4); }
.tier-badge.OFFICIAL { color: #38bdf8; border: 1px solid rgba(56,189,248,.4); }
.cd-note { font-size: 9.5px; color: #94a3b8; line-height: 1.55; margin-top: 8px; background: rgba(251,191,36,.06); border-left: 2px solid rgba(251,191,36,.4); padding: 6px 8px; border-radius: 0 6px 6px 0; }

.rank-box {
    background: rgba(10, 16, 30, 0.78); backdrop-filter: blur(18px);
    border: 1px solid rgba(148, 163, 184, 0.16); border-radius: 16px; padding: 12px;
}
.rank-box h3 { font-size: 12.5px; color: #38bdf8; margin-bottom: 8px; }
.tier-row { display: flex; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.rank-list { display: flex; flex-direction: column; gap: 4px; }
.rank-item { display: flex; align-items: center; gap: 8px; font-size: 11px; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.rank-item:hover { background: rgba(56,189,248,.08); }
.rank-item .rn { color: #64748b; width: 16px; }
.rank-item .bar-wrap { flex: 1; height: 12px; background: rgba(56,189,248,.08); border-radius: 6px; overflow: hidden; }
.rank-item .bar { height: 100%; background: linear-gradient(90deg, #0ea5e9, #38bdf8); border-radius: 6px; }
.rank-item .rv { color: #cbd5e1; width: 70px; text-align: right; font-variant-numeric: tabular-nums; }

/* ─── 底部图表 ─── */
.bottom-panel {
    position: fixed; left: var(--side-l); right: var(--side-r); bottom: 34px; height: 200px; z-index: 1400;
    background: rgba(10, 16, 30, 0.82); backdrop-filter: blur(18px);
    border: 1px solid rgba(148, 163, 184, 0.16); border-radius: 16px;
    display: flex; flex-direction: column; transition: height .25s;
}
.bottom-panel.collapsed { height: 36px; }
.bp-tabs { display: flex; gap: 2px; padding: 4px 8px 0; }
.btab {
    background: transparent; border: none; color: #94a3b8; font-size: 11.5px;
    padding: 6px 10px; cursor: pointer; border-radius: 8px 8px 0 0; white-space: nowrap;
}
.bp-tabs { overflow-x: auto; scrollbar-width: none; padding-right: 36px; }
.btab.active { color: #38bdf8; background: rgba(56,189,248,.1); }
.bp-body { flex: 1; padding: 4px 10px 8px; min-height: 0; position: relative; }
.bp-toggle {
    position: absolute; right: 8px; top: 6px; background: transparent; border: 1px solid rgba(56,189,248,.3);
    color: #7dd3fc; border-radius: 6px; width: 22px; height: 22px; cursor: pointer; font-size: 11px;
}

/* ─── 弹窗 ─── */
.modal { position: fixed; inset: 0; background: rgba(2,6,16,.7); z-index: 3000; display: flex; align-items: center; justify-content: center; }
.modal-box {
    width: min(860px, 92vw); max-height: 82vh; overflow-y: auto;
    background: rgba(8,12,22,.97); border: 1px solid rgba(148,163,184,.22); border-radius: 16px; padding: 16px;
}
.modal-box h3 { color: #38bdf8; font-size: 15px; }
.src-body { font-size: 12px; color: #cbd5e1; }
.src-item { border-bottom: 1px solid rgba(100,180,255,.08); padding: 8px 4px; }
.src-item b { color: #e0f2fe; }
.src-item .meta { color: #64748b; font-size: 10.5px; margin-top: 2px; line-height: 1.5; }

/* ─── 状态栏 ─── */
.statusbar {
    position: fixed; left: 0; right: 0; bottom: 0; height: 26px; z-index: 2000;
    background: rgba(10,15,30,.95); border-top: 1px solid rgba(56,189,248,.15);
    display: flex; align-items: center; padding: 0 12px; font-size: 11px; color: #94a3b8; gap: 10px;
}
.statusbar .spacer { flex: 1; }
.muted { color: #64748b; }

/* ─── Leaflet 定制 ─── */
.county-tip { background: rgba(10,18,35,.92); border: 1px solid rgba(56,189,248,.3); color: #e0f2fe; font-size: 11.5px; border-radius: 8px; }
.county-tip b { color: #38bdf8; }
.leaflet-popup-content-wrapper { background: rgba(10,18,35,.95); color: #e2e8f0; border-radius: 10px; }
.fire-marker { border-radius: 50%; box-shadow: 0 0 6px #f97316; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: rgba(56,189,248,.25); border-radius: 3px; }

/* ─── 响应式 ─── */
@media (max-width: 1200px) {
    :root { --side-r: 300px; }
    .right-panel { width: 280px; }
    .module-tabs .tab { padding: 6px 8px; font-size: 11.5px; }
    .search-box { width: min(360px, 34vw); }
}
@media (max-width: 900px) {
    :root { --header-h: 88px; }
    .subtitle { display: none; }
    .layer-panel { width: min(240px, 78vw); max-height: 46vh; }
    .right-panel { width: min(260px, 86vw); max-height: 42vh; }
    .bottom-panel { display: none; }
    .kpi-grid { grid-template-columns: 1fr; }
    .search-box { width: min(92vw, 520px); top: calc(var(--header-h) + 8px); }
    .nl-fab, .nl-panel { right: 12px; }
    .basemap-sel { max-width: 96px; }
}

/* ─── 县名标注 ─── */
.county-label {
    background: rgba(10, 18, 35, 0.55);
    border: none; border-radius: 8px;
    color: #e0f2fe; font-size: 11px; font-weight: 600;
    padding: 1px 6px; white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0,0,0,.9);
    box-shadow: 0 0 0 1px rgba(56,189,248,.18);
}
.county-label span { pointer-events: none; }

/* ─── 用户徽章 ─── */
.user-badge {
    font-size: 11.5px; color: #7dd3fc; white-space: nowrap;
    border: 1px solid rgba(56,189,248,.25); border-radius: 8px; padding: 5px 10px;
    background: rgba(56,189,248,.06);
}
@media (max-width: 900px) { .user-badge { display: none; } }

/* ─── POI 查询框 ─── */
.search-box {
    position: fixed; top: calc(var(--header-h) + 12px); left: 50%; transform: translateX(-50%);
    z-index: 1600; display: flex; gap: 6px; width: min(440px, 34vw);
    transition: width .28s var(--ease);
}
.search-box:focus-within { width: min(560px, 46vw); }
.search-box input {
    flex: 1; padding: 9px 13px; font-size: 13px; color: #e0f2fe;
    background: rgba(8,12,22,.88); border: 1px solid rgba(148,163,184,.22);
    border-radius: 999px; outline: none; backdrop-filter: blur(16px);
}
.search-box input:focus { border-color: rgba(56,189,248,.65); }
.search-box select { background: rgba(10,18,35,.92); color: #cbd5e1; border: 1px solid rgba(56,189,248,.3); border-radius: 10px; padding: 0 6px; font-size: 12px; }
.search-box button { background: rgba(56,189,248,.15); border: 1px solid rgba(56,189,248,.35); border-radius: 10px; color: #7dd3fc; width: 40px; cursor: pointer; }
.search-results {
    position: absolute; top: 44px; left: 0; right: 0; display: none;
    background: rgba(10,18,35,.96); border: 1px solid rgba(56,189,248,.3);
    border-radius: 10px; max-height: 320px; overflow-y: auto; backdrop-filter: blur(12px);
}
.sr-item { padding: 8px 12px; font-size: 12.5px; color: #e2e8f0; cursor: pointer; border-bottom: 1px solid rgba(100,180,255,.08); }
.sr-item:hover { background: rgba(56,189,248,.08); }
.sr-item .src-chip { float: right; font-size: 9.5px; color: #7dd3fc; border: 1px solid rgba(125,211,252,.35); border-radius: 8px; padding: 0 6px; }
.sr-item .sr-meta { font-size: 10.5px; color: #64748b; margin-top: 2px; }

/* ─── NL 智能助手 ─── */
.nl-fab {
    position: fixed; right: 16px; bottom: 40px; z-index: 1650;
    background: rgba(8,12,22,.94); color: #e0f2fe; font-size: 12px;
    border: 1px solid rgba(148,163,184,.28); border-radius: 999px; padding: 10px 16px; cursor: pointer;
    backdrop-filter: blur(16px); box-shadow: 0 10px 28px rgba(0,0,0,.4);
}
.nl-fab:hover { background: rgba(56,189,248,.15); }
.nl-panel {
    position: fixed; right: 16px; bottom: 88px; z-index: 1650;
    width: 380px; height: 460px; min-width: 300px; min-height: 280px;
    flex-direction: column; resize: both; overflow: hidden;
    background: rgba(8,12,22,.94); border: 1px solid rgba(148,163,184,.22);
    border-radius: 16px; backdrop-filter: blur(18px); box-shadow: 0 20px 50px rgba(0,0,0,.45);
}
.nl-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid rgba(148,163,184,.16); color: #e0f2fe; font-size: 13px; cursor: grab; user-select: none; touch-action: none; }
.nl-head:active { cursor: grabbing; }
.nl-head b::after { content: " · 拖动移动"; font-weight: 400; color: #64748b; font-size: 11px; }
.nl-body { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.nl-msg { max-width: 92%; padding: 8px 11px; border-radius: 14px; font-size: 12px; line-height: 1.6; animation: ui-rise .28s var(--ease); }
@keyframes ui-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.nl-msg.bot { background: rgba(56,189,248,.08); border: 1px solid rgba(56,189,248,.18); color: #dbeafe; align-self: flex-start; }
.nl-msg.user { background: rgba(14,165,233,.25); color: #f0f9ff; align-self: flex-end; }
.nl-msg a { color: #7dd3fc; }
.nl-input { display: flex; gap: 6px; padding: 10px; border-top: 1px solid rgba(56,189,248,.2); }
.nl-input input { flex: 1; padding: 9px 11px; font-size: 12.5px; background: rgba(2,6,16,.6); border: 1px solid rgba(56,189,248,.25); border-radius: 8px; color: #e0f2fe; outline: none; }
.nl-input button { background: rgba(56,189,248,.2); border: 1px solid rgba(56,189,248,.4); color: #7dd3fc; border-radius: 8px; padding: 0 14px; cursor: pointer; }

/* ─── AOI 按钮/弹窗 ─── */
.active-btn { color: #fde68a !important; border-color: rgba(251,191,36,.6) !important; background: rgba(251,191,36,.1) !important; }
.aoi-box { width: min(560px, 92vw); }

/* ─── 图斑管理 ─── */
.parcel-label {
    background: rgba(30, 20, 60, .6); border: 1px solid rgba(167,139,250,.4); border-radius: 8px;
    color: #ede9fe; font-size: 11px; font-weight: 600; padding: 1px 6px; white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0,0,0,.9);
}
.parcel-input {
    padding: 8px 10px; font-size: 12px; color: #e0f2fe;
    background: rgba(2,6,16,.6); border: 1px solid rgba(167,139,250,.3); border-radius: 8px; outline: none;
}
.parcel-input:focus { border-color: rgba(167,139,250,.6); }
.file-btn { display: block; text-align: center; cursor: pointer; }
.parcel-list { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.parcel-item { padding: 7px 9px; font-size: 11.5px; color: #e2e8f0; cursor: pointer;
    background: rgba(139,92,246,.06); border: 1px solid rgba(167,139,250,.2); border-radius: 8px; }
.parcel-item:hover { background: rgba(139,92,246,.12); }
.parcel-item.sel { border-color: rgba(251,191,36,.6); background: rgba(251,191,36,.06); }
.mini-btn {
    background: rgba(56,189,248,.12); border: 1px solid rgba(56,189,248,.35); color: #7dd3fc;
    border-radius: 6px; font-size: 10px; padding: 2px 7px; cursor: pointer; white-space: nowrap;
}
.mini-btn:hover { background: rgba(56,189,248,.22); }
.mini-btn.danger { color: #fca5a5; border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.08); }
.rank-item, .btab, .sr-item, .parcel-item { transition: background .18s var(--ease), color .18s var(--ease); }
.leaflet-bar { border: 0 !important; box-shadow: 0 10px 28px rgba(0,0,0,.35) !important; }
.leaflet-bar a, .leaflet-bar a:hover {
    background: rgba(8,12,22,.92); color: #e0f2fe; border-bottom: 1px solid rgba(148,163,184,.16);
}
.leaflet-control-attribution { background: rgba(8,12,22,.72) !important; color: #94a3b8 !important; }
::selection { background: rgba(14,165,233,.35); color: #f8fafc; }
@view-transition { navigation: auto; }
.header { view-transition-name: app-header; }
::view-transition-old(root) { animation: ui-fade-out .2s var(--ease) both; }
::view-transition-new(root) { animation: ui-fade-in .34s var(--ease) both; }
@keyframes ui-fade-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes ui-fade-in { from { opacity: 0; transform: translateY(10px); } }
html.ui-enter body > :not(.header) { opacity: 0; transition: opacity .34s var(--ease); }
html.ui-enter.ui-entered body > :not(.header) { opacity: 1; }
html.ui-leave body > :not(.header) { opacity: 0 !important; transition: opacity .17s ease; }
html.ui-enter .page-main { translate: 0 10px; transition: translate .34s var(--ease); }
html.ui-enter.ui-entered .page-main { translate: 0 0; }
.ui-swap { animation: ui-rise .32s var(--ease); }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
