/* 绿蔬农事管理系统 全局样式 */
html, body, #app { height: 100%; margin: 0; }
body { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; background: #f0f2f5; }
* { box-sizing: border-box; }

.layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 220px; background: #1d2b36; color: #cfd8dc; display: flex; flex-direction: column; flex-shrink: 0; }
.logo { height: 56px; display: flex; align-items: center; gap: 8px; padding: 0 16px; color: #fff; font-weight: 700; font-size: 15px; background: #16212b; letter-spacing: 1px; }
.logo .el-icon { color: #67c23a; font-size: 20px; }
.menu { flex: 1; overflow-y: auto; padding-bottom: 12px; }
.menu::-webkit-scrollbar { width: 4px; } .menu::-webkit-scrollbar-thumb { background: #37474f; }
.menu-group-title { padding: 12px 16px 4px; font-size: 12px; color: #607d8b; }
.menu-item { display: flex; align-items: center; gap: 8px; padding: 10px 16px; cursor: pointer; font-size: 13.5px; transition: background .15s; border-left: 3px solid transparent; }
.menu-item:hover { background: #263442; }
.menu-item.active { background: #2e7d3222; color: #8bc34a; border-left-color: #8bc34a; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.header { height: 56px; background: #fff; display: flex; align-items: center; padding: 0 16px; gap: 12px; box-shadow: 0 1px 4px rgba(0,21,41,.08); z-index: 5; }
.header .crumb { font-size: 15px; font-weight: 600; color: #263238; }
.header .spacer { flex: 1; }
.header .link-btn { cursor: pointer; color: #2e7d32; font-size: 13px; }
.content { flex: 1; overflow-y: auto; padding: 14px; }

.page-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.card { background: #fff; border-radius: 8px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 14px; }
.card-title { font-weight: 600; margin-bottom: 12px; color: #263238; display: flex; align-items: center; gap: 8px; }
.card-title::before { content: ''; width: 4px; height: 16px; background: #4caf50; border-radius: 2px; display: inline-block; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat-card { background: #fff; border-radius: 8px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); display: flex; flex-direction: column; gap: 6px; cursor: default; }
.stat-card .num { font-size: 26px; font-weight: 700; }
.stat-card .label { font-size: 13px; color: #78909c; }
.stat-card.warn .num { color: #e53935; } .stat-card.ok .num { color: #2e7d32; } .stat-card.blue .num { color: #1e88e5; } .stat-card.orange .num { color: #fb8c00; }

.kanban { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.kanban-col { background: #eceff1; border-radius: 8px; padding: 10px; max-height: calc(100vh - 240px); display: flex; flex-direction: column; }
.kanban-col .col-title { font-weight: 600; margin-bottom: 8px; display: flex; justify-content: space-between; font-size: 14px; }
.kanban-cards { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.kcard { background: #fff; border-radius: 6px; padding: 10px; font-size: 13px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.kcard.overdue { border-left: 3px solid #e53935; }
.kcard .k-title { font-weight: 600; margin-bottom: 4px; }
.kcard .k-meta { color: #90a4ae; font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

.flex { display: flex; gap: 12px; } .flex-1 { flex: 1; min-width: 0; }
.mt { margin-top: 12px; } .mb0 { margin-bottom: 0; }
.map-wrap { height: calc(100vh - 220px); min-height: 420px; border-radius: 8px; overflow: hidden; position: relative; }
.map-toolbar { position: absolute; top: 10px; left: 60px; z-index: 1000; display: flex; gap: 6px; background: #ffffffe6; padding: 6px 8px; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.map-legend { position: absolute; bottom: 18px; right: 10px; z-index: 1000; background: #ffffffe6; padding: 8px 10px; border-radius: 6px; font-size: 12px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }
.leaflet-container { font: inherit; }

.chart-box { width: 100%; }
.table-footer { display: flex; justify-content: flex-end; margin-top: 10px; }
.ai-chat { display: flex; flex-direction: column; height: calc(100vh - 220px); }
.ai-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: #fafafa; border-radius: 8px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 10px; font-size: 13.5px; line-height: 1.75; }
.msg.user { align-self: flex-end; background: #2e7d32; color: #fff; border-bottom-right-radius: 2px; white-space: pre-wrap; }
.msg.ai { align-self: flex-start; background: #fff; border: 1px solid #e0e0e0; border-bottom-left-radius: 2px; white-space: normal; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
/* AI 回复 Markdown 排版 */
.md-body { line-height: 1.75; }
.md-body p { margin: 0 0 8px; }
.md-body p:last-child { margin-bottom: 0; }
.md-body .md-h { font-weight: 700; color: #1b5e20; margin: 12px 0 6px; padding-left: 9px; border-left: 3px solid #4caf50; line-height: 1.45; }
.md-body > .md-h:first-child, .md-body > p:first-child { margin-top: 0; }
.md-body ul { margin: 0 0 8px; padding-left: 20px; }
.md-body li { margin: 3px 0; }
.md-body li::marker { color: #4caf50; }
.md-body strong { color: #1b5e20; font-weight: 700; }
.md-body code { background: #eef3ee; padding: 1px 6px; border-radius: 4px; font-size: 12px; color: #2e7d32; }
.md-body .md-foot { margin-top: 10px; padding-top: 6px; border-top: 1px dashed #e0e0e0; color: #90a4ae; font-size: 12px; }
.ai-input { display: flex; gap: 8px; margin-top: 10px; }

.chain { display: flex; flex-direction: column; gap: 0; }
.chain-step { display: flex; gap: 12px; }
.chain-rail { display: flex; flex-direction: column; align-items: center; }
.chain-dot { width: 14px; height: 14px; border-radius: 50%; background: #4caf50; margin-top: 4px; flex-shrink: 0; }
.chain-dot.missing { background: #ff9800; }
.chain-line { width: 2px; flex: 1; background: #c8e6c9; min-height: 18px; }
.chain-body { padding-bottom: 14px; }
.chain-body .t { font-weight: 600; }

.trace-hero { background: linear-gradient(135deg, #2e7d32, #66bb6a); color: #fff; border-radius: 12px; padding: 24px; margin-bottom: 16px; }
.tl { position: relative; padding-left: 20px; }
.tl::before { content: ''; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: #c8e6c9; }
.tl-item { position: relative; padding-bottom: 14px; }
.tl-item::before { content: ''; position: absolute; left: -19px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #2e7d32; }

.pkt { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.pkt-card { border: 1px solid #e0e0e0; border-radius: 8px; padding: 10px; font-size: 13px; background: #fff; }
.pkt-card .v { font-size: 18px; font-weight: 700; }
.pkt-card .u { color: #90a4ae; font-size: 12px; }

.screen { background: #0a1622; color: #cfe8ff; height: 100vh; overflow: hidden; display: flex; flex-direction: column; padding: 10px; gap: 10px; }
.screen-header { text-align: center; font-size: 24px; font-weight: 700; letter-spacing: 4px; color: #fff; background: linear-gradient(90deg, transparent, #0d3b4f88, transparent); padding: 8px 0; border: 1px solid #1e4a5f; border-radius: 6px; position: relative; }
.screen-header .time { position: absolute; right: 16px; top: 12px; font-size: 13px; letter-spacing: 0; color: #8ac6d1; }
.screen-grid { flex: 1; display: grid; grid-template-columns: 1fr 1.4fr 1fr; grid-template-rows: 1fr 1fr; gap: 10px; min-height: 0; }
.panel { background: #0d2136cc; border: 1px solid #1e4a5f; border-radius: 8px; padding: 10px; display: flex; flex-direction: column; min-height: 0; }
.panel .p-title { font-size: 14px; font-weight: 600; color: #4dd0e1; margin-bottom: 6px; letter-spacing: 2px; }
.panel .p-body { flex: 1; min-height: 0; }
.screen-map { grid-column: 2; grid-row: 1 / span 2; }

.el-table .overdue-row { color: #e53935; font-weight: 600; }
.el-dialog { border-radius: 10px !important; }
th.gutter, .el-table__header th { background: #f5f7f6 !important; }
.search-bar .el-input, .search-bar .el-select { width: 170px; }

/* ===== 新增/编辑基地：左表单 + 右地图（绘制边界/搜索定位/拐点编辑） ===== */
.base-form-grid { display: flex; gap: 14px; align-items: stretch; }
.base-form { width: 335px; flex-shrink: 0; }
.base-form .el-form-item { margin-bottom: 12px; }
.base-map-wrap { flex: 1; min-width: 0; height: 470px; position: relative; border-radius: 8px; overflow: hidden; border: 1px solid #e0e0e0; background: #e8ece9; }
.base-map-toolbar { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 1000; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.base-search-row, .base-tools-row { display: flex; gap: 6px; align-items: center; background: #ffffffe6; padding: 6px 8px; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.15); width: fit-content; max-width: 100%; flex-wrap: wrap; }
.base-search-row .el-input { width: 265px; }
.base-search-panel { position: absolute; top: 92px; left: 10px; z-index: 1001; width: 330px; max-height: 250px; overflow: auto; background: #fff; border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.22); }
.base-search-item { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; cursor: pointer; border-bottom: 1px dashed #eee; }
.base-search-item:hover { background: #f0fdf4; }
.base-search-kind { flex-shrink: 0; font-size: 11px; padding: 1px 6px; border-radius: 4px; color: #fff; background: #1e88e5; margin-top: 2px; }
.base-search-kind.k-base { background: #2e7d32; }
.base-search-kind.k-plot { background: #f9a825; }
.base-search-name { font-size: 13px; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 250px; }
.base-search-sub { font-size: 11.5px; color: #999; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 250px; }
.base-search-close { text-align: center; font-size: 12px; color: #999; padding: 5px; cursor: pointer; }
.base-map-hint { position: absolute; bottom: 10px; left: 10px; z-index: 1000; background: #ffffffe6; padding: 5px 10px; border-radius: 6px; font-size: 12px; color: #555; max-width: calc(100% - 130px); }
.base-map-area { position: absolute; bottom: 10px; right: 10px; z-index: 1000; background: #2e7d32e6; color: #fff; padding: 5px 10px; border-radius: 6px; font-size: 12px; white-space: nowrap; }
.base-area-tip { font-size: 11.5px; color: #2e7d32; line-height: 1.5; }

/* ===== 地图编辑器（map-editor.js）原生工具条样式 ===== */
.me-layer-switch { display: flex; gap: 0; border-radius: 4px; overflow: hidden; border: 1px solid #cfd8dc; }
.me-layer-switch .me-btn { border: none; border-radius: 0; }
.me-layer-switch .me-btn + .me-btn { border-left: 1px solid #cfd8dc; }
.me-btn { padding: 5px 12px; font-size: 12.5px; line-height: 1.4; border: 1px solid #dcdfe6; background: #fff; color: #444; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.me-btn:hover { color: #2e7d32; border-color: #2e7d32; }
.me-btn.active { background: #2e7d32; color: #fff; border-color: #2e7d32; }
.me-btn.me-primary { background: #2e7d32; color: #fff; border-color: #2e7d32; }
.me-btn.me-primary:hover { background: #256a29; }
.me-btn.me-danger { color: #e53935; border-color: #ef9a9a; }
.me-btn.me-danger:hover { background: #fef0f0; }
.me-btn:disabled { color: #bbb; border-color: #e5e5e5; background: #f5f7f6; cursor: not-allowed; }
.me-input { width: 250px; padding: 5px 10px; font-size: 12.5px; border: 1px solid #dcdfe6; border-radius: 4px; outline: none; }
.me-input:focus { border-color: #2e7d32; }

/* ===== 基地平面图（base-view）：左大地图 + 右侧图例/地块速览 ===== */
.plan-flex { display: flex; gap: 14px; align-items: stretch; }
.plan-map-wrap { flex: 2; min-width: 0; height: clamp(480px, calc(100vh - 400px), 760px); border-radius: 8px; overflow: hidden; position: relative; border: 1px solid #e0e0e0; }
.plan-switch { position: absolute; top: 10px; right: 10px; z-index: 1000; display: flex; gap: 6px; background: #ffffffe6; padding: 6px 8px; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.plan-side { flex: 1; min-width: 270px; max-width: 380px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.plan-side .side-title { font-weight: 600; font-size: 13px; color: #333; margin-bottom: 2px; flex-shrink: 0; }
.plan-legend-card { background: #f7f9fb; border: 1px solid #e8edf2; border-radius: 8px; padding: 10px 12px; flex-shrink: 0; }
.plan-legend-grid { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: #555; }
.plan-lg-item { display: flex; align-items: center; gap: 5px; }
.plan-lg-item span { width: 13px; height: 13px; border-radius: 3px; display: inline-block; border: 1px solid #fff; box-shadow: 0 0 2px rgba(0,0,0,.25); }
.plot-quick-list { flex: 1; min-height: 0; overflow: auto; border: 1px solid #e8edf2; border-radius: 8px; background: #fff; }
.plot-quick-row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px dashed #eee; font-size: 12.5px; cursor: pointer; }
.plot-quick-row:hover { background: #f2f9f4; }
.plot-quick-row .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.plot-quick-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #333; }
.plot-quick-row .ar { color: #888; flex-shrink: 0; }
/* 地块详情/编辑工作台（base-view 右栏选中态） */
.plot-detail { flex: 1; min-height: 0; overflow: auto; background: #fff; border: 1px solid #e8edf2; border-radius: 8px; padding: 12px 14px; }
.pd-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pd-name { font-size: 16px; font-weight: 700; color: #1b5e20; }
.pd-sub { font-size: 12px; color: #888; margin-top: 2px; }
.pd-sec { font-weight: 600; font-size: 13px; color: #2e7d32; margin: 12px 0 6px; border-bottom: 1px dashed #e0e0e0; padding-bottom: 4px; }
.pd-grid { display: flex; gap: 8px; }
.pd-cell { flex: 1; background: #f7f9fb; border: 1px solid #e8edf2; border-radius: 8px; text-align: center; padding: 8px 4px; }
.pd-cell b { display: block; font-size: 16px; color: #333; font-family: Consolas, monospace; }
.pd-cell span { font-size: 11px; color: #999; }
.pd-edges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.pd-edge { background: #eef5ef; border: 1px solid #c8e6c9; color: #2e7d32; font-size: 11.5px; border-radius: 10px; padding: 1px 8px; font-family: Consolas, monospace; white-space: nowrap; }
.pd-kv { font-size: 12.5px; color: #555; line-height: 1.9; }
.pd-empty { font-size: 12.5px; color: #aaa; padding: 4px 0; }
.pd-tl-sub { color: #999; font-size: 12px; margin-left: 6px; }
.pd-rec { display: flex; align-items: center; gap: 8px; padding: 6px 2px; border-bottom: 1px dashed #eee; font-size: 12.5px; }
.pd-rec .t { color: #999; flex-shrink: 0; font-size: 12px; }
.pd-rec .ti { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #333; }
.pd-rec .who { color: #888; flex-shrink: 0; font-size: 12px; }
.pd-readonly { font-size: 12.5px; color: #999; padding: 4px 0; }
/* ===== 地块管理编辑器（plot-mgmt：左地图 + 右信息表单，实时预览） ===== */
.pe-page { display: flex; flex-direction: column; gap: 10px; height: 100%; min-height: 640px; } /* 填满内容区，不再底部留白 */
.pe-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; flex-shrink: 0; }
.pe-tip { color: #999; font-size: 12.5px; }
.pe-layout { display: flex; gap: 12px; align-items: stretch; flex: 1; min-height: 0; }
.pe-map { flex: 1; min-width: 0; min-height: 0; height: 100%; border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden; position: relative; background: #e8ece9; }
.pe-form { flex: 0 0 400px; max-width: 420px; min-height: 0; overflow-y: auto; background: #fff; border: 1px solid #e8edf2; border-radius: 8px; padding: 12px 16px; }
.pf-sec { font-weight: 600; font-size: 13px; color: #2e7d32; margin: 4px 0 10px; border-bottom: 1px dashed #e0e0e0; padding-bottom: 4px; }
.pf-new { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; font-size: 12.5px; border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; line-height: 1.7; }
.pf-color-row { display: flex; align-items: center; width: 100%; }
.pf-color-row input[type=color] { width: 44px; height: 28px; padding: 0; border: 1px solid #dcdfe6; border-radius: 4px; cursor: pointer; background: none; flex-shrink: 0; }
.pf-stats { display: flex; gap: 8px; }
.pf-stat { flex: 1; background: #f7f9fb; border: 1px solid #e8edf2; border-radius: 8px; text-align: center; padding: 8px 4px; }
.pf-stat b { display: block; font-size: 16px; color: #333; font-family: Consolas, monospace; }
.pf-stat span { font-size: 11px; color: #999; }
.pf-edges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.pf-edge { background: #eef5ef; border: 1px solid #c8e6c9; color: #2e7d32; font-size: 11.5px; border-radius: 10px; padding: 1px 8px; font-family: Consolas, monospace; white-space: nowrap; }
/* 边长可编辑（改数值回车生效，地图即时调整） */
.pf-edge-edit { display: flex; align-items: center; gap: 4px; background: #eef5ef; border: 1px solid #c8e6c9; border-radius: 10px; padding: 1px 4px 1px 8px; font-size: 11.5px; color: #2e7d32; }
.pf-edge-edit .lbl { font-family: Consolas, monospace; }
.pf-edge-edit input { width: 58px; border: 1px solid #c8e6c9; border-radius: 8px; font-size: 12px; font-family: Consolas, monospace; color: #1b5e20; padding: 1px 5px; outline: none; text-align: right; background: #fff; }
.pf-edge-edit input:focus { border-color: #2e7d32; box-shadow: 0 0 0 2px #2e7d3222; }
.pf-edge-edit input:disabled { background: #f4f8f4; color: #999; }
.pf-edge-edit .unit { color: #7cb342; margin-right: 4px; }
.pf-hint { font-size: 12px; color: #999; line-height: 1.8; margin-top: 8px; }
.pf-btns { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.pf-links { margin-top: 10px; }
/* 查看模式只读信息 */
.pf-kvs { margin-top: 12px; border: 1px solid #e8edf2; border-radius: 8px; overflow: hidden; }
.pf-kvs .kv { display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; border-bottom: 1px dashed #eef2f6; font-size: 12.5px; }
.pf-kvs .kv:last-child { border-bottom: none; }
.pf-kvs .kv span { color: #999; }
.pf-kvs .kv b { color: #333; font-weight: 600; }
.pf-empty-hint { text-align: center; color: #90a4ae; font-size: 13.5px; line-height: 2.2; padding: 60px 10px; }
/* 基地管理：企业信息卡 */
.ent-grid { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.ent-kv { flex: 1 1 220px; min-width: 220px; background: #f7f9fb; border: 1px solid #eef2f6; border-radius: 8px; padding: 8px 12px; }
.ent-kv span { display: block; font-size: 11.5px; color: #90a4ae; margin-bottom: 2px; }
.ent-kv b { font-size: 13.5px; color: #333; }
/* ===== 设备管理：概览统计条 ===== */
.iot-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.iot-stat { flex: 1; min-width: 130px; background: #fff; border: 1px solid #e8edf2; border-radius: 10px; padding: 12px 16px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: default; transition: box-shadow .2s; }
.iot-stat:hover { box-shadow: 0 3px 12px rgba(46,125,50,.12); }
.iot-stat b { font-size: 24px; font-weight: 800; font-family: Consolas, monospace; color: #37474f; line-height: 1.1; }
.iot-stat span { font-size: 12px; color: #90a4ae; }
.iot-stat.is-green b { color: #2e7d32; }
.iot-stat.is-ok b { color: #43a047; }
.iot-stat.is-gray b { color: #78909c; }
.iot-stat.is-warn b { color: #f9a825; }
.iot-stat.is-blue b { color: #1e88e5; }
.iot-stat.is-blink { border-color: #1e88e5; box-shadow: 0 0 0 2px #1e88e522; cursor: pointer; }
/* 全屏 API 被内嵌环境拒绝时的伪全屏：地图（或弹窗）固定铺满视口 */
.me-fs-fallback { position: fixed !important; inset: 0 !important; z-index: 3000 !important; width: 100vw !important; height: 100vh !important; max-width: none !important; max-height: none !important; border-radius: 0 !important; border: none !important; }

/* ===== 可视化大屏（内嵌 /screen） ===== */
.screen-view-wrap { margin: -14px; }
.screen-iframe { display: block; width: 100%; height: calc(100vh - 57px); border: none; }

/* ===== 地图绘制弹窗全屏模式 ===== */
.el-dialog:fullscreen { width: 100vw !important; height: 100vh !important; max-height: none !important; border-radius: 0 !important; margin: 0 !important; }
.el-dialog:fullscreen .el-dialog__body { max-height: none; overflow: hidden; }
.el-dialog:fullscreen .base-map-wrap { height: calc(100vh - 235px) !important; }
.el-dialog:fullscreen .base-search-row, .el-dialog:fullscreen .base-tools-row { z-index: 1002; }
.base-map-wrap:fullscreen { height: 100vh; border-radius: 0; border: none; }
