/* 指挥调度平台 - 全局样式（简洁明亮） */
:root {
    --primary: #1677ff;
    --primary-dark: #0958d9;
    --primary-soft: #e8f2ff;
    --danger: #d7263d;
    --danger-soft: #fdecee;
    --success: #1d9a41;
    --success-soft: #e9f7ee;
    --warn: #b8860b;
    --warn-soft: #fff7e6;
    --text: #1f2937;
    --text-sub: #6b7280;
    --border: #e5e7eb;
    --bg: #f4f6f9;
    --panel: #ffffff;
    --radius: 10px;
    --shadow: 0 2px 10px rgba(16, 24, 40, .06);
    --shadow-lg: 0 8px 28px rgba(16, 24, 40, .12);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    color: var(--text);
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
                 "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
h1, h2, h3, h4 { margin: 0 0 12px; font-weight: 600; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
code { background: #f1f3f5; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------- 卡片 / 按钮 / 表单 ---------- */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}
.card > h2:first-child { margin-top: 0; }

.btn {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .88; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 13px; }
input[type=text], input[type=password], input[type=number], input[type=tel], select, textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,119,255,.1); }
textarea { min-height: 88px; resize: vertical; }
.field { margin-bottom: 14px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.alert-error   { background: var(--danger-soft); color: #a3123a; border: 1px solid #f3bcc7; }
.alert-success { background: var(--success-soft); color: #1d6b32; border: 1px solid #b7e2c4; }
.alert-warn    { background: var(--warn-soft); color: var(--warn); border: 1px solid #ffe1a1; }
.alert-info    { background: var(--primary-soft); color: var(--primary-dark); border: 1px solid #bcdcff; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    color: #fff;
    font-size: 12px;
    line-height: 18px;
    white-space: nowrap;
}
.badge-gray { background: #9ca3af; }
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--text-sub); }

.table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { background: #f8fafc; font-weight: 600; color: var(--text-sub); white-space: nowrap; }
.table tbody tr:hover { background: #fafcff; }
.table .nowrap { white-space: nowrap; }
.table-responsive { overflow-x: auto; }

.empty { padding: 30px; text-align: center; color: var(--text-sub); }
.muted { color: var(--text-sub); }
.small { font-size: 12px; }
.tip { font-size: 12px; color: var(--text-sub); }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }
.row-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- 登录 / 注册 ---------- */
.auth-page {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 15px;
    background: linear-gradient(135deg, #eaf2ff 0%, #f6f8fb 55%, #e9f6f1 100%);
}
.auth-box {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 30px;
}
.auth-box h1 { font-size: 22px; text-align: center; margin-bottom: 4px; }
.auth-box .sub { text-align: center; color: var(--text-sub); margin-bottom: 20px; font-size: 13px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 13px; }

.avatar-upload { display: flex; align-items: center; gap: 14px; }
.avatar-upload img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); background: #f1f3f5; }
.avatar-upload input[type=file] { font-size: 12px; }

/* ---------- 地图主页 ---------- */
.dash { display: flex; flex-direction: column; height: 100%; }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(16,24,40,.04);
    z-index: 30;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.topbar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 4px rgba(215,38,61,.15); }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.topbar .user-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 20px; }
.topbar .user-chip:hover { background: #f3f5f8; }
.topbar .user-chip img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }

.map-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    /* 强制建立层叠上下文：内部所有子元素的 z-index 都只在 .map-stage 内部比较，
       彻底杜绝第三方地图 SDK 的高 z-index 元素盖住悬浮面板 */
    isolation: isolate;
}

/* 地图包裹层：定位元素 + 非 auto 的 z-index 会创建层叠上下文，
   天地图内部 z-index 高达数百的窗格元素因此被限制在本层内 */
.map-canvas {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;   /* 不用 inset，兼容老浏览器 */
    z-index: 0;
    background: #eaeef3;
}
#mapContainer {
    width: 100%; height: 100%;
    /* 兜底：即使天地图用行内样式改了 position/z-index，!important 也能压过去，
       保证地图容器自身形成层叠上下文，其子元素不会跑到面板之上 */
    position: absolute !important;
    top: 0 !important; right: 0 !important; bottom: 0 !important; left: 0 !important;
    z-index: 0 !important;
}

.panel-layer {
    position: absolute;
    top: 12px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100% - 24px);
    overflow-y: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
}
/* 底部预留约 96px，避免长面板盖住左下角的图例/状态条与右下的天地图控件 */
.panel-layer.left { left: 12px; max-height: calc(100% - 96px); }
.panel-layer.right { right: 12px; max-height: calc(100% - 96px); }
.panel-layer::-webkit-scrollbar { width: 6px; }
.panel-layer::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 3px; }

.fpanel {
    background: rgba(255,255,255,.96);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(2px);
    overflow: hidden;
}
.fpanel .fp-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-bottom: 1px solid var(--border);
    font-weight: 600; font-size: 14px; background: #fbfcfe;
    cursor: pointer; user-select: none;
}
.fpanel .fp-head .fp-toggle { color: var(--text-sub); font-size: 12px; }
.fpanel .fp-body { padding: 12px; font-size: 13px; max-height: 46vh; overflow-y: auto; }
.fpanel.collapsed .fp-body { display: none; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-item { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 10px; text-align: center; }
.stat-item .num { font-size: 20px; font-weight: 700; color: var(--primary); line-height: 1.3; }
.stat-item .lbl { font-size: 12px; color: var(--text-sub); }

.plist { list-style: none; margin: 0; padding: 0; }
.plist li { padding: 8px 0; border-bottom: 1px dashed var(--border); display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.plist li:last-child { border-bottom: 0; }
.plist .pname { font-weight: 500; cursor: pointer; color: var(--text); }
.plist .pname:hover { color: var(--primary); }
.plist .pmeta { font-size: 12px; color: var(--text-sub); }

.ulist { list-style: none; margin: 0; padding: 0; }
.ulist li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.ulist li:last-child { border-bottom: 0; }
.ulist img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.ulist .uname { font-weight: 500; }
.ulist .umeta { font-size: 12px; color: var(--text-sub); }
.role-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }

/* 左下角容器：图例 + 定位状态（避开右上/右下的天地图控件） */
.map-corner {
    position: absolute; left: 12px; bottom: 12px; z-index: 1001;
    display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
    max-width: 46%;
}
.map-status {
    background: rgba(255,255,255,.95); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 12px; font-size: 12px; color: var(--text-sub);
    box-shadow: var(--shadow);
}
.map-legend {
    background: rgba(255,255,255,.95); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 12px; font-size: 12px; box-shadow: var(--shadow);
}
.map-legend .lg-item { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.map-legend .lg-dot { width: 10px; height: 10px; border-radius: 50%; }

/* 顶部工具条居中，避免与左右两侧面板重叠 */
.map-tools {
    position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1002;
    display: flex; gap: 6px;
}
.map-tools .btn { background: rgba(255,255,255,.96); box-shadow: var(--shadow); }

/* 天地图自带控件（缩放/图层/比例尺）默认在左上，会压住左侧面板，统一移出可视干扰区 */
.map-canvas .tdt-control-container { z-index: 10 !important; }

/* 信息窗口 */
.iw { min-width: 220px; max-width: 320px; font-size: 13px; }
.iw h4 { margin: 0 0 8px; font-size: 15px; }
.iw .iw-row { margin: 3px 0; color: #4b5563; }
.iw .iw-actions { margin-top: 10px; display: flex; gap: 8px; }

/* ---------- 后台布局 ---------- */
.admin { display: flex; min-height: 100vh; }
.sidebar {
    width: 210px; flex: 0 0 210px;
    background: #fff; border-right: 1px solid var(--border);
    padding: 14px 10px;
}
.sidebar .sb-title { font-weight: 700; font-size: 15px; padding: 6px 10px 14px; display: flex; align-items: center; gap: 8px; }
.sidebar a {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 12px; border-radius: 8px; color: var(--text); margin-bottom: 2px; font-size: 14px;
}
.sidebar a:hover { background: #f3f5f8; color: var(--text); }
.sidebar a.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.sidebar .sb-group { font-size: 12px; color: var(--text-sub); padding: 12px 12px 6px; }
.admin-main { flex: 1; min-width: 0; padding: 18px 22px; background: var(--bg); }
.admin-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.admin-head h2 { margin: 0; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; height: 56px; padding: 0 22px; background: #fff; border-bottom: 1px solid var(--border); }

/* ---------- 项目选择 / 复选 ---------- */
.project-picker { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: #fbfcfe; }
.project-picker label { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0 0 6px; cursor: pointer; }

/* ---------- 天地图选点 ---------- */
.pick-map { height: 320px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; }
.search-result { border: 1px solid var(--border); border-radius: 8px; max-height: 220px; overflow-y: auto; margin-top: 8px; display: none; }
.search-result .item { padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.search-result .item:hover { background: var(--primary-soft); }
.search-result .item:last-child { border-bottom: 0; }
.search-result .item .name { font-weight: 500; }
.search-result .item .addr { font-size: 12px; color: var(--text-sub); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    .admin { flex-direction: column; }
    .sidebar { width: 100%; flex: none; display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
    .sidebar .sb-title, .sidebar .sb-group { display: none; }
    .sidebar a { white-space: nowrap; }
    .admin-main { padding: 14px; }
}

/* 窄屏（手机）才隐藏地图悬浮面板；平板/小笔记本仍然显示，只是变窄 */
@media (max-width: 640px) {
    .panel-layer { display: none; }
    .map-corner { max-width: 70%; }
}
