/* FleetView 2.0 · 深色主题 · 方案二（字段选择导出）· 交互重排版 */
:root {
  --bg: #0a0b0d;
  --bg-side: #0f1114;
  --bg-input: #0c0d10;
  --panel: #14161a;
  --panel-2: #1b1e23;
  --panel-3: #22262d;
  --border: #252930;
  --border-2: #323841;
  --text: #f2f3f5;
  --text-2: #9ca3af;
  --text-3: #646c78;
  --brand: #ee8e25;
  --brand-2: #f6a64e;
  --brand-soft: rgba(238, 142, 37, .14);
  --ok: #10b981;
  --ok-soft: rgba(16, 185, 129, .14);
  --danger: #f53f3f;
  --danger-soft: rgba(245, 63, 63, .14);
  --info: #0792fb;
  --radius: 8px;
  --font: "Microsoft YaHei", "PingFang SC", -apple-system, "Segoe UI", sans-serif;
  --mono: Consolas, "JetBrains Mono", "Courier New", monospace;
  --side-w: 84px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 13px; -webkit-font-smoothing: antialiased; }
button, input, select { font-family: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg.ico { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------- 框架 ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: var(--side-w); background: var(--bg-side); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.logo { height: 56px; display: grid; place-items: center; border-bottom: 1px solid var(--border); }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #140d04; font-weight: 800; display: grid; place-items: center; font-size: 14px; }
.menu { padding: 8px 6px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.menu-item { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 2px 8px; border-radius: 8px; color: var(--text-2); font-size: 10.5px; text-align: center; line-height: 1.2; position: relative; }
.menu-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.menu-item:hover { color: var(--text); background: var(--panel); }
.menu-item.active { color: var(--brand); background: var(--brand-soft); }
.menu-item.sub { font-size: 11px; padding: 7px 4px 7px 22px; margin: -2px 0 2px; justify-content: flex-start; text-align: left; }
.menu-item.sub::before { content: "└"; position: absolute; left: 8px; color: var(--text-3); }
.menu-item.sub.active { color: var(--brand); }

.shell { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tabs { height: 40px; display: flex; align-items: stretch; background: var(--bg-side); border-bottom: 1px solid var(--border); padding-left: 4px; flex-shrink: 0; }
.tabs .tab { display: flex; align-items: center; padding: 0 16px; color: var(--text-2); font-size: 12px; position: relative; }
.tabs .tab + .tab { border-left: 1px solid var(--border); }
.tabs .tab:first-child { color: var(--text); }
.tabs .tab:first-child::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--brand); }
.tab-right { margin-left: auto; display: flex; align-items: center; gap: 10px; padding-right: 14px; }
.role-tag { font-size: 11px; color: var(--brand); background: var(--brand-soft); padding: 3px 9px; border-radius: 20px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--panel-3); display: grid; place-items: center; font-size: 10px; color: var(--text-2); font-weight: 600; }

.demo-bar { display: flex; align-items: center; gap: 14px; padding: 7px 20px; background: #0d0e11; border-bottom: 1px dashed var(--border); color: var(--text-2); font-size: 12px; flex-shrink: 0; }
.demo-label { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.demo-note { color: var(--text-3); }
.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); }
.switch input { display: none; }
.switch-track { width: 30px; height: 17px; border-radius: 10px; background: var(--border-2); position: relative; transition: background .15s; }
.switch-track::after { content: ""; position: absolute; width: 13px; height: 13px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::after { transform: translateX(13px); }

.main { flex: 1; overflow: auto; padding: 20px 24px 28px; position: relative; }
.main.has-preview { padding-bottom: 38vh; }
.page { min-height: 100%; }

/* ---------- 页头 ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 14px; gap: 16px; }
.crumb { font-size: 11.5px; color: var(--text-3); margin-bottom: 6px; }
.crumb span { margin: 0 6px; }
.page-head h1 { font-size: 22px; font-weight: 700; }
.sub { color: var(--text-2); margin-top: 6px; font-size: 12.5px; }

/* ---------- 操作栏（粘性） ---------- */
.actionbar { position: sticky; top: -20px; z-index: 6; display: flex; align-items: center; gap: 10px; background: rgba(10, 11, 13, .92); backdrop-filter: blur(6px); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px 10px 16px; margin: 0 0 16px; }
.ab-status { display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.ab-status b { color: var(--text); font-weight: 600; }
.ab-blocker { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #ffb4b4; background: var(--danger-soft); border: 1px solid rgba(245, 63, 63, .35); padding: 4px 10px; border-radius: 6px; }
.ab-blocker::before { content: "!"; width: 16px; height: 16px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.spacer { flex: 1; }

/* ---------- 卡片与分区 ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; min-height: 26px; }
.card-title { font-size: 14px; font-weight: 600; }
.hint { color: var(--text-3); font-size: 11.5px; }
.count { background: var(--panel-3); color: var(--text-2); font-size: 11px; padding: 1px 8px; border-radius: 10px; }
.stat { color: var(--text-2); font-size: 12px; }
.muted { color: var(--text-2); }
.small { font-size: 11.5px; }
.badge { min-width: 18px; height: 18px; border-radius: 9px; background: var(--brand); color: #140d04; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; padding: 0 5px; margin-left: 6px; }

.workspace { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.catalog { position: sticky; top: 76px; max-height: calc(100vh - 150px); display: flex; flex-direction: column; }
.build { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.section { min-width: 0; }
.section + .section { border-top: 1px solid var(--border); padding-top: 16px; }

/* ---------- 按钮 / 输入 ---------- */
.btn { height: 32px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text); font-size: 12.5px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover:not(:disabled) { border-color: #434a55; background: var(--panel-3); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #140d04; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--brand-2); border-color: var(--brand-2); }
.btn-ghost { background: transparent; }
.btn-sm { height: 28px; padding: 0 11px; font-size: 12px; }
.icon-btn { width: 30px; height: 30px; border-radius: 6px; border: none; background: transparent; color: var(--text-2); display: grid; place-items: center; }
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.search-box { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; color: var(--text-3); margin-bottom: 10px; }
.search-box:focus-within { border-color: var(--brand); }
.search-box input { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font-size: 12.5px; }
.search-box input::placeholder { color: var(--text-3); }
.pill { font-size: 11px; padding: 3px 9px; border-radius: 20px; font-weight: 500; }
.pill-warn { background: var(--brand-soft); color: var(--brand-2); }
.pill-ok { background: var(--ok-soft); color: #4ade80; }
.pill-err { background: var(--danger-soft); color: #ff8a8a; }

/* ---------- 字段清单 ---------- */
.field-groups { overflow-y: auto; min-height: 0; padding-right: 4px; flex: 1; }
.group-title { font-size: 11px; color: var(--text-3); letter-spacing: .04em; margin: 12px 2px 6px; text-transform: uppercase; }
.group-title:first-child { margin-top: 2px; }
.field { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 6px; cursor: pointer; position: relative; user-select: none; }
.field:hover:not(.disabled) { background: var(--panel-2); }
.field.on { background: var(--brand-soft); }
.field.disabled { opacity: .42; cursor: not-allowed; }
.field input[type="checkbox"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.box { width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--border-2); background: var(--bg-input); display: grid; place-items: center; flex-shrink: 0; }
.field.on .box { background: var(--brand); border-color: var(--brand); }
.field.on .box::after { content: ""; width: 5px; height: 9px; border-right: 2px solid #140d04; border-bottom: 2px solid #140d04; transform: rotate(45deg) translate(-1px, -1px); }
.field input:focus-visible + .box { outline: 2px solid var(--brand); outline-offset: 2px; }
.f-label { flex: 1; min-width: 0; color: var(--text); }
.f-unit { font-size: 11px; color: var(--text-3); font-family: var(--mono); }
.f-add { width: 24px; height: 24px; border-radius: 5px; border: none; background: transparent; color: var(--text-3); display: grid; place-items: center; opacity: 0; }
.field:hover .f-add, .f-add:focus-visible { opacity: 1; }
.f-add:hover { color: var(--brand); background: var(--panel-3); }
.f-add svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.f-lock { font-size: 10.5px; color: var(--text-3); max-width: 120px; text-align: right; line-height: 1.3; }
.empty-mini { color: var(--text-3); font-size: 12px; text-align: center; padding: 22px 8px; line-height: 1.6; }

/* ---------- 导出列 ---------- */
.col-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.col { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 6px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; position: relative; }
.col:hover { border-color: var(--border-2); }
.col.dragging { opacity: .4; }
.col.drop-before::before, .col.drop-after::after { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: var(--brand); border-radius: 2px; }
.col.drop-before::before { top: -4px; }
.col.drop-after::after { bottom: -4px; }
.grip { width: 18px; height: 22px; display: grid; place-items: center; color: var(--text-3); cursor: grab; font-size: 14px; letter-spacing: -2px; user-select: none; }
.grip:active { cursor: grabbing; }
.col-no { width: 18px; color: var(--text-3); font-family: var(--mono); font-size: 11px; text-align: center; }
.col-label { flex: 1; min-width: 0; font-size: 12.5px; }
.col-unit { color: var(--text-3); font-size: 11.5px; margin-left: 4px; }
.col-btn { width: 24px; height: 24px; border-radius: 4px; border: 1px solid transparent; background: transparent; color: var(--text-3); display: grid; place-items: center; font-size: 12px; }
.col-btn:hover:not(:disabled) { color: var(--text); background: var(--panel-3); }
.col-btn:disabled { opacity: .25; cursor: not-allowed; }
.col-btn.rm:hover:not(:disabled) { color: #ff8a8a; }
.cols-empty { border: 1px dashed var(--border-2); border-radius: 6px; padding: 22px; text-align: center; color: var(--text-3); font-size: 12px; line-height: 1.7; }

/* ---------- 筛选条件 ---------- */
.flt { display: grid; grid-template-columns: minmax(120px, 1.1fr) minmax(90px, .8fr) minmax(160px, 2fr) 28px; gap: 8px; align-items: start; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin-bottom: 8px; }
.flt.bad { border-color: rgba(245, 63, 63, .5); }
.flt select, .flt .input { height: 30px; min-width: 0; width: 100%; background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 5px; color: var(--text); padding: 0 8px; font-size: 12px; outline: none; color-scheme: dark; }
.flt select:focus, .flt .input:focus { border-color: var(--brand); }
.flt .del { width: 28px; height: 30px; border-radius: 5px; border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text-2); }
.flt .del:hover { color: #ff8a8a; border-color: rgba(245, 63, 63, .5); }
.val-pair { display: grid; grid-template-columns: 1fr 14px 1fr; gap: 4px; align-items: center; }
.val-pair i { color: var(--text-3); font-style: normal; text-align: center; font-size: 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 1px; }
.chip-opt { height: 26px; padding: 0 10px; border-radius: 13px; border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text-2); font-size: 12px; }
.chip-opt:hover { color: var(--text); }
.chip-opt[aria-pressed="true"] { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.flt-err { grid-column: 1 / -1; font-size: 11.5px; color: #ff9b9b; margin-top: -2px; }
.flt-tip { grid-column: 1 / -1; font-size: 11px; color: var(--text-3); }
.flt-empty { border: 1px dashed var(--border-2); border-radius: 6px; padding: 16px; text-align: center; color: var(--text-3); font-size: 12px; line-height: 1.7; }

/* ---------- 预览（底部停靠） ---------- */
.preview { position: fixed; left: var(--side-w); right: 0; bottom: 0; height: 36vh; background: var(--panel); border-top: 1px solid var(--border-2); box-shadow: 0 -18px 40px rgba(0,0,0,.45); z-index: 12; display: flex; flex-direction: column; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.preview-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.preview-body { flex: 1; overflow: auto; padding: 0 14px 12px; min-height: 0; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 6px; margin-top: 10px; }
table.result { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.result th { position: sticky; top: 0; background: #1a1d22; color: var(--text-2); font-weight: 500; text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border-2); white-space: nowrap; z-index: 1; }
table.result th.num { text-align: right; }
table.result td { padding: 6px 12px; border-bottom: 1px solid #1d2026; white-space: nowrap; color: var(--text); }
table.result tbody tr:nth-child(even) td { background: rgba(255,255,255,.012); }
table.result td.num { text-align: right; font-variant-numeric: tabular-nums; color: #a7f3d0; }
.empty-block { padding: 26px; text-align: center; color: var(--text-2); font-size: 12.5px; line-height: 1.7; }

/* ---------- 导出记录抽屉 ---------- */
.drawer { position: fixed; inset: 0; z-index: 20; }
.mask { position: absolute; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); }
.drawer-panel { position: absolute; right: 0; top: 0; bottom: 0; width: 420px; background: var(--panel); border-left: 1px solid var(--border); display: flex; flex-direction: column; box-shadow: -20px 0 40px rgba(0,0,0,.35); animation: slideIn .18s ease-out; }
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 18px 18px 12px; }
.drawer-head .card-title { margin-bottom: 3px; font-size: 15px; }
.drawer-tools { padding: 0 18px 12px; border-bottom: 1px solid var(--border); }
.seg { display: inline-flex; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; padding: 2px; width: fit-content; }
.seg-item { border: none; background: transparent; color: var(--text-2); font-size: 12px; padding: 5px 12px; border-radius: 4px; }
.seg-item:hover { color: var(--text); }
.seg-item.active { background: var(--panel-3); color: var(--text); }
.history { flex: 1; overflow-y: auto; padding: 8px 14px 14px; }
.h-group { font-size: 11px; color: var(--text-3); letter-spacing: .04em; padding: 12px 4px 8px; text-transform: uppercase; }
.h-item { background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 8px; position: relative; }
.h-item::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 0 2px 2px 0; background: var(--ok); }
.h-item.err::before { background: var(--danger); }
.h-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.h-fields { font-size: 12px; color: var(--text-2); margin-top: 6px; line-height: 1.6; }
.h-cond { font-size: 11.5px; color: var(--text-3); margin-top: 4px; line-height: 1.5; }
.h-err { font-size: 11.5px; color: #ff9b9b; margin-top: 6px; line-height: 1.5; }
.h-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--text-3); font-size: 11px; }
.h-foot .spacer { flex: 1; }
.h-act { border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text-2); font-size: 11px; padding: 3px 9px; border-radius: 4px; }
.h-act:hover { color: var(--text); border-color: var(--brand); }
.h-empty { text-align: center; color: var(--text-3); padding: 60px 20px; font-size: 12px; line-height: 1.7; }
.drawer-foot { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--border); }

/* ---------- 无权限 / 占位 / Toast ---------- */
.state-block { height: 62vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; color: var(--text-2); }
.state-block h2 { color: var(--text); font-size: 18px; }
.state-block p { max-width: 380px; line-height: 1.6; }
.state-icon { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.state-icon.danger { border: 2px solid var(--danger); color: var(--danger); background: var(--danger-soft); }
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: #1d2026; border: 1px solid var(--border-2); padding: 10px 16px; border-radius: 8px; font-size: 12.5px; z-index: 40; box-shadow: 0 12px 30px rgba(0,0,0,.45); display: flex; align-items: center; gap: 8px; }
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.toast.ok::before { background: var(--ok); }
.toast.err::before { background: var(--danger); }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 1fr; }
  .catalog { position: static; max-height: none; }
  .field-groups { max-height: 340px; }
}
