/* ---------- 基础 / 清爽主题 ---------- */
:root {
  --bg: #f3f5f8;
  --panel-bg: #fff;
  --border: #d9dee5;
  --header-bg: #f7f9fb;
  --header-fg: #2c3440;
  --toolbar-bg: #fbfcfd;
  --btn-bg: #fff;
  --btn-border: #cfd6df;
  --btn-hover: #eef3fa;
  --btn-active: #dde7f5;
  --accent: #3b7ddd;
  --text: #222;
  --muted: #7a8494;
  --splitter: #e9edf2;
  --splitter-hover: #c9d7ec;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 13px/1.4 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }

/* ---------- 三栏布局 ---------- */
#app { display: flex; height: 100%; width: 100%; padding: 4px; gap: 0; }
.panel {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--panel-bg); border: 1px solid var(--border); border-radius: 4px; overflow: hidden;
}
#leftPanel { flex: 0 0 440px; width: 440px; }
#gridPanel { flex: 0 0 300px; width: 300px; }
.panel.center { flex: 1 1 auto; }
.splitter { flex: 0 0 5px; cursor: col-resize; background: var(--splitter); border-radius: 2px; margin: 0 1px; }
.splitter:hover, .splitter.active { background: var(--splitter-hover); }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe, body.resizing textarea { pointer-events: none; }

.panel-header {
  flex: none; height: 30px; line-height: 30px; padding: 0 10px;
  background: var(--header-bg); border-bottom: 1px solid var(--border);
  font-weight: 600; color: var(--header-fg); user-select: none;
  display: flex; align-items: center; justify-content: space-between;
}
.toolbar {
  flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  min-height: 32px; padding: 3px 6px; background: var(--toolbar-bg); border-bottom: 1px solid var(--border);
}
.toolbar .label { color: var(--muted); margin-right: 2px; }
.toolbar .sep { width: 1px; height: 16px; background: var(--border); margin: 0 3px; }
.toolbar .fill { flex: 1; }
.toolbar button {
  height: 24px; padding: 0 9px; border: 1px solid var(--btn-border); border-radius: 3px;
  background: var(--btn-bg); cursor: pointer; white-space: nowrap; line-height: 22px;
}
.toolbar button:hover { background: var(--btn-hover); border-color: #b9c6d8; }
.toolbar button:active { background: var(--btn-active); }
.toolbar button:disabled, .toolbar button:disabled:hover, .toolbar button:disabled:active {
  background: var(--btn-bg); border-color: var(--btn-border); color: #b3bac4; cursor: default;
}
.toolbar button.icon-btn img { width: 16px; height: 16px; vertical-align: -3px; margin-right: 2px; }
.toolbar input[type=text] {
  height: 24px; width: 110px; padding: 0 6px; border: 1px solid var(--btn-border); border-radius: 3px; outline: none;
}
.toolbar input[type=text]:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,125,221,.15); }
.search-result { padding: 0 6px; font-weight: bold; color: #c0392b; white-space: nowrap; }
.search-result.ok { color: var(--accent); }

.panel-body { flex: 1 1 auto; min-height: 0; position: relative; overflow: auto; }

/* ---------- 左栏标题行的格式下拉 ---------- */
.fmt-pick { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; font-weight: normal; font-size: 12px; color: var(--muted); }
.fmt-pick select {
  height: 22px; padding: 0 4px; border: 1px solid var(--btn-border); border-radius: 3px;
  background: var(--btn-bg); color: var(--text); font: inherit; cursor: pointer; outline: none;
}
.fmt-pick select:hover { border-color: #b9c6d8; }
.fmt-pick select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,125,221,.15); }
.dialog-body p.hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

/* ---------- 左侧编辑区与转换结果（CodeMirror 6） ---------- */
#edit, #convEdit { height: 100%; }
#edit .cm-editor, #convEdit .cm-editor { height: 100%; font-size: 12px; background: #fff; }
#edit .cm-editor.cm-focused, #convEdit .cm-editor.cm-focused { outline: none; }
#edit .cm-scroller, #convEdit .cm-scroller { overflow: auto; font-family: Menlo, Consolas, "Courier New", monospace; line-height: 1.5; }
#edit .cm-content, #convEdit .cm-content { padding: 4px 0; }
#edit .cm-line, #convEdit .cm-line { padding: 0 8px 0 4px; }
#edit .cm-gutters, #convEdit .cm-gutters { background: #f7f9fb; border-right: 1px solid var(--border); color: #9aa3b0; }
#edit .cm-activeLineGutter, #convEdit .cm-activeLineGutter { background: #e9f0fa; }
#edit .cm-activeLine, #convEdit .cm-activeLine { background: rgba(59,125,221,.06); }
#edit .cm-placeholder { color: #9aa3b0; font-style: normal; }
#edit .cm-selectionBackground, #edit .cm-editor ::selection,
#convEdit .cm-selectionBackground, #convEdit .cm-editor ::selection { background: #cfe0f7 !important; }
#edit .cm-cursor, #convEdit .cm-cursor { border-left-color: #222; }
#edit .cm-panels, #convEdit .cm-panels { background: #f7f9fb; border-color: var(--border); font-size: 12px; }
#edit .cm-panels input, #edit .cm-panels button, #convEdit .cm-panels input, #convEdit .cm-panels button { font-size: 12px; }

/* ---------- 中栏标签页：树视图 | 转换 ---------- */
.view-tabs { display: inline-flex; margin: 0 auto 0 12px; font-weight: normal; }
.view-tab {
  height: 22px; padding: 0 12px; border: 1px solid var(--btn-border); background: var(--btn-bg);
  font-size: 12px; line-height: 20px; cursor: pointer; color: var(--text);
}
.view-tab + .view-tab { margin-left: -1px; }
.view-tab:first-child { border-radius: 3px 0 0 3px; }
.view-tab:last-child { border-radius: 0 3px 3px 0; }
.view-tab:hover { background: var(--btn-hover); }
.view-tab.on, .view-tab.on:hover { position: relative; z-index: 1; background: var(--btn-active); border-color: var(--accent); color: var(--accent); }
.tab-pane { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
#treePanel { position: relative; }
.busy-tip {
  position: absolute; left: 50%; top: 50%; z-index: 20; transform: translate(-50%, -50%);
  padding: 8px 18px; background: #fff; border: 1px solid #c8d0da; border-radius: 4px;
  box-shadow: 0 4px 14px rgba(0,0,0,.15); color: var(--muted); font-size: 12px; white-space: nowrap;
}

/* ---------- 转换面板 ---------- */
.conv-toolbar { flex-wrap: nowrap; overflow: hidden; }
.seg { display: inline-flex; }
.toolbar .seg button, .conv-opts .seg button { border-radius: 0; padding: 0 9px; }
.toolbar .seg button + button, .conv-opts .seg button + button { margin-left: -1px; }
.toolbar .seg button:first-child, .conv-opts .seg button:first-child { border-radius: 3px 0 0 3px; }
.toolbar .seg button:last-child, .conv-opts .seg button:last-child { border-radius: 0 3px 3px 0; }
.toolbar .seg button.on, .toolbar .seg button.on:hover, .conv-opts .seg button.on, .conv-opts .seg button.on:hover {
  position: relative; z-index: 1; background: var(--btn-active); border-color: var(--accent); color: var(--accent);
}
#convOptBtn { display: inline-flex; align-items: center; gap: 5px; }
.caret { display: inline-block; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 4px solid var(--muted); }
.conv-bar {
  flex: none; display: flex; align-items: center; gap: 8px; min-height: 26px; padding: 3px 8px;
  background: #f7f9fb; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted);
}
.conv-bar.warn { background: #fff8e8; border-bottom-color: #f0dcae; }
.conv-bar-text { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-bar .warn-mark {
  display: inline-block; width: 14px; height: 14px; margin-right: 5px; border-radius: 50%; background: #d97706; color: #fff;
  font-weight: bold; font-size: 11px; line-height: 14px; text-align: center; vertical-align: -2px;
}
.conv-bar .actual { color: #a35200; }
.conv-bar .paths { color: #8a6d3b; font-family: Menlo, Consolas, monospace; font-size: 11px; }
.conv-bar .inherent { color: var(--muted); }
button.link { flex: none; padding: 0; border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 12px; }
button.link:hover { text-decoration: underline; }
.conv-body { overflow: hidden; }
.conv-msg { padding: 14px 12px; color: var(--muted); font-size: 12px; }
.conv-msg p { margin: 0 0 8px; }
.conv-msg pre { margin: 8px 0 0; padding: 8px; background: #f6f8fa; border-radius: 4px; font-size: 12px; white-space: pre-wrap; word-break: break-all; color: #b03a2e; }
.conv-msg button {
  height: 24px; padding: 0 9px; border: 1px solid var(--btn-border); border-radius: 3px; background: var(--btn-bg); cursor: pointer; font-size: 12px;
}
.conv-msg button:hover { background: var(--btn-hover); border-color: #b9c6d8; }
.conv-opts {
  position: fixed; z-index: 1000; min-width: 230px; padding: 8px 12px; display: flex; flex-direction: column; gap: 8px;
  background: #fff; border: 1px solid #c8d0da; border-radius: 4px; box-shadow: 0 4px 14px rgba(0,0,0,.15); font-size: 12px;
}
.conv-opts .opt-row { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.conv-opts .opt-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.conv-opts .opt-label { color: var(--header-fg); min-width: 28px; }
.conv-opts .opt-note { color: var(--muted); }
.conv-opts .seg button { height: 22px; border: 1px solid var(--btn-border); background: var(--btn-bg); cursor: pointer; font-size: 12px; line-height: 20px; }
.conv-opts .seg button:hover { background: var(--btn-hover); }
.conv-opts .seg button:disabled { color: #b3bac4; cursor: default; background: var(--btn-bg); }
.conv-opts input[type=text] { width: 110px; height: 22px; padding: 0 6px; border: 1px solid var(--btn-border); border-radius: 3px; outline: none; font: inherit; }
.conv-opts input[type=text]:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,125,221,.15); }
.dialog.wide { width: 640px; }
.loss-list { margin: 0; padding-left: 18px; }
.loss-list li { margin-bottom: 6px; }
.loss-list .paths { display: block; color: var(--muted); font-family: Menlo, Consolas, monospace; font-size: 11px; word-break: break-all; }
.loss-list.inherent li { color: var(--muted); }
.dialog-body h4 { margin: 0 0 6px; font-size: 13px; }
.dialog-body h4 + .loss-list { margin-bottom: 12px; }

/* ---------- 中间树视图：保持 ExtJS 原样 ---------- */
.x-tree { background: #fff; }
#treeSpacer { position: relative; min-height: 100%; }
#treeLayer { position: absolute; left: 0; top: 0; min-width: 100%; }
.tn {
  display: flex; align-items: center; height: 18px; white-space: nowrap; cursor: pointer;
  color: #000; font: 12px/18px Menlo, Consolas, "DejaVu Sans Mono", "Courier New", monospace;
}
.tn:hover { background-color: #eee; }
.tn.sel, .tn.sel:hover { background-color: #d9e8fb; }
.tn > span { flex: none; display: block; width: 16px; height: 18px; background-repeat: no-repeat; }
.tn .tb { background: none; }                                         /* 空白缩进 */
.tn .tl { background-image: url(../assets/ico/elbow-line.gif); }      /* 竖线缩进 */
.tn .ec { cursor: pointer; }
.tn .ec.e   { background-image: url(../assets/ico/elbow.gif); }
.tn .ec.ee  { background-image: url(../assets/ico/elbow-end.gif); }
.tn .ec.ep  { background-image: url(../assets/ico/elbow-plus.gif); }
.tn .ec.em  { background-image: url(../assets/ico/elbow-minus.gif); }
.tn .ec.eep { background-image: url(../assets/ico/elbow-end-plus.gif); }
.tn .ec.eem { background-image: url(../assets/ico/elbow-end-minus.gif); }
.tn .ni { background-position: center; }
.tn .ni.object  { background-image: url(../assets/ico/object.gif); }
.tn .ni.array   { background-image: url(../assets/ico/array.gif); }
.tn .ni.string  { background-image: url(../assets/ico/blue.gif); }
.tn .ni.number  { background-image: url(../assets/ico/green.gif); }
.tn .ni.boolean { background-image: url(../assets/ico/yellow.gif); }
.tn .ni.null    { background-image: url(../assets/ico/red.gif); }
.tn .ni.date    { background-image: url(../assets/ico/purple.gif); }
.tn a { display: block; line-height: 18px; text-decoration: none; color: #000; user-select: none; }
.tn a span { padding: 0 3px 0 2px; }
.tree-empty { padding: 12px; color: var(--muted); font-size: 12px; }

/* ---------- 右侧属性表 ---------- */
.grid-body { background: #fff; }
.prop-grid { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: fixed; font-size: 12px; }
.prop-grid th {
  position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 600; color: #444;
  background: #f4f6f9; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 4px 6px;
}
.prop-grid th:last-child { border-right: 0; }
.prop-grid .col-name { width: 40%; }
.prop-grid td {
  padding: 3px 6px; border-bottom: 1px solid #eef1f4; border-right: 1px solid #eef1f4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: top;
}
.prop-grid td:last-child { border-right: 0; }
.prop-grid td.name { background: #fafbfc; color: #333; }
.prop-grid tr:hover td { background: #f0f5fc; }
.prop-grid td.more { color: var(--muted); font-style: italic; text-align: center; }

/* ---------- 右键菜单 ---------- */
.ctx-menu {
  position: fixed; z-index: 1000; min-width: 140px; padding: 4px 0;
  background: #fff; border: 1px solid #c8d0da; border-radius: 4px; box-shadow: 0 4px 14px rgba(0,0,0,.15);
  font-size: 12px; user-select: none;
}
.ctx-item { padding: 5px 14px; cursor: pointer; white-space: nowrap; }
.ctx-item:hover { background: var(--btn-hover); color: var(--accent); }
.ctx-sep { height: 1px; margin: 4px 0; background: var(--border); }

/* ---------- 对话框 / 提示 ---------- */
.dialog-mask { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center; }
.dialog { width: 420px; max-width: 90vw; background: #fff; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.25); overflow: hidden; }
.dialog-title { padding: 10px 14px; font-weight: 600; background: var(--header-bg); border-bottom: 1px solid var(--border); }
.dialog-body { padding: 14px; max-height: 60vh; overflow: auto; font-size: 13px; line-height: 1.6; }
.dialog-body pre { margin: 8px 0 0; padding: 8px; background: #f6f8fa; border-radius: 4px; font-size: 12px; white-space: pre-wrap; word-break: break-all; color: #b03a2e; }
.dialog-body code { padding: 0 3px; background: #f2f4f7; border-radius: 3px; font-family: Menlo, Consolas, monospace; font-size: 12px; }
.dialog-body kbd { padding: 1px 5px; border: 1px solid #ccc; border-bottom-width: 2px; border-radius: 3px; background: #f7f7f7; font-size: 11px; }
.dialog-footer { padding: 8px 14px; text-align: right; border-top: 1px solid var(--border); background: #fafbfc; }
.dialog-footer button { height: 26px; padding: 0 16px; border: 1px solid var(--accent); border-radius: 3px; background: var(--accent); color: #fff; cursor: pointer; }
.dialog-footer button:hover { filter: brightness(1.08); }
.dialog-footer button + button { margin-left: 8px; }
.dialog-footer button.secondary { border-color: var(--btn-border); background: var(--btn-bg); color: var(--text); }
.dialog-footer button.secondary:hover { filter: none; background: var(--btn-hover); border-color: #b9c6d8; }
.dialog-footer button:disabled { opacity: .6; cursor: default; filter: none; }

/* 修改密码弹窗 */
.dialog.pwd-dialog { width: 360px; margin: 0; }
.form-fields { display: flex; flex-direction: column; gap: 10px; font-size: 12px; line-height: 1.4; }
.form-error { min-height: 17px; color: #c0392b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.toast {
  position: fixed; z-index: 3000; top: 50%; left: 50%; transform: translate(-50%, -50%);
  padding: 10px 24px; background: rgba(0,0,0,.6); color: #fff; border-radius: 4px; font-size: 13px; pointer-events: none;
}
[hidden] { display: none !important; }

/* ---------- 登录 / 设置 / 账户 / 用户管理页 ---------- */
body.auth-page { overflow: auto; height: auto; min-height: 100%; }
.auth-wrap { width: 360px; max-width: calc(100vw - 24px); margin: 12vh auto 40px; }
.auth-wrap.wide { width: 720px; margin-top: 6vh; }
.auth-top {
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px; padding: 0 2px;
  font-size: 12px; color: var(--muted);
}
.auth-top b { color: var(--text); }
.auth-top .fill { flex: 1; }
.auth-top a, .auth-page button.link { color: var(--accent); text-decoration: none; }
.auth-top a:hover, .auth-page button.link:hover { text-decoration: underline; }
.auth-page button.link { padding: 0; border: 0; background: none; cursor: pointer; font-size: 12px; }
.auth-page form.inline { display: inline; margin: 0; }
.auth-card { background: var(--panel-bg); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.auth-title {
  height: 34px; line-height: 34px; padding: 0 14px;
  background: var(--header-bg); border-bottom: 1px solid var(--border);
  font-weight: 600; color: var(--header-fg);
}
.auth-body { padding: 16px; }
.auth-hint { margin: 0 0 12px; color: var(--muted); }
.auth-msg { margin-bottom: 12px; padding: 7px 10px; border-radius: 3px; border: 1px solid; }
.auth-msg.error { color: #c0392b; background: #fdf1f0; border-color: #f2c4bf; }
.auth-msg.ok { color: #2e7d32; background: #f0f8f0; border-color: #bfe0c1; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form.narrow { max-width: 320px; }
.auth-form label, .form-fields label { display: flex; flex-direction: column; gap: 4px; color: var(--header-fg); }
/* 表单输入框：认证页与查看器内弹窗（.form-fields）共用 */
.auth-page input[type=text], .auth-page input[type=password], .form-fields input[type=password] {
  height: 28px; padding: 0 8px; border: 1px solid var(--btn-border); border-radius: 3px; outline: none; background: #fff;
}
.auth-page input[type=text]:focus, .auth-page input[type=password]:focus, .form-fields input[type=password]:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,125,221,.15); }
.auth-page button:not(.link) {
  height: 26px; padding: 0 12px; border: 1px solid var(--btn-border); border-radius: 3px;
  background: var(--btn-bg); cursor: pointer; white-space: nowrap;
}
.auth-page button:not(.link):hover { background: var(--btn-hover); border-color: #b9c6d8; }
.auth-page button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.auth-page button.primary:hover { background: var(--accent); filter: brightness(1.08); }
.auth-form button.primary { height: 30px; margin-top: 4px; }
.auth-page button.danger { color: #c0392b; }
.auth-page button.danger:hover { background: #fdf1f0; border-color: #e6a39b; }
.auth-inline-form { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.auth-inline-form input[type=text], .auth-inline-form input[type=password] { width: 170px; }
.auth-inline-form .check { display: inline-flex; align-items: center; gap: 4px; color: var(--header-fg); }
.auth-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; border: 1px solid var(--border); border-radius: 3px; }
.auth-table th {
  text-align: left; font-weight: 600; color: #444; background: #f4f6f9;
  border-bottom: 1px solid var(--border); padding: 5px 8px;
}
.auth-table td { padding: 5px 8px; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
.auth-table tr:last-child td { border-bottom: 0; }
.auth-table tr:hover td { background: #f0f5fc; }
.auth-table .c-name { width: 20%; }
.auth-table .c-admin { width: 8%; }
.auth-table .c-time { width: 21%; }
.auth-table td.ops { white-space: nowrap; }
.auth-table td.ops form.inline { margin-right: 4px; }
.auth-table td.ops input[type=password] { width: 96px; height: 24px; }
.auth-table td.ops button { height: 24px; padding: 0 8px; }
.auth-page .muted { color: var(--muted); }

/* ---------- 用户菜单（启用登录验证时显示在“视图”标题栏右侧） ---------- */
.user-menu { display: inline-flex; margin-left: auto; font-weight: normal; }
.user-menu #userBtn {
  display: inline-flex; align-items: center; gap: 5px; max-width: 180px; height: 22px; padding: 0 8px;
  border: 1px solid var(--btn-border); border-radius: 3px; background: var(--btn-bg); cursor: pointer; font-size: 12px; line-height: 20px;
}
.user-menu #userBtn:hover { background: var(--btn-hover); border-color: #b9c6d8; }
.user-menu #userName { overflow: hidden; text-overflow: ellipsis; }
.user-drop {
  position: fixed; z-index: 1000; display: block; min-width: 120px; padding: 4px 0;   /* 位置由 JS 按按钮计算，避免被面板裁剪 */
  background: #fff; border: 1px solid #c8d0da; border-radius: 4px; box-shadow: 0 4px 14px rgba(0,0,0,.15);
  font-size: 12px; line-height: 1.5; font-weight: normal; user-select: none;
}
.user-drop .ctx-sep { display: block; }
.user-drop a, .user-drop button {
  display: block; width: 100%; padding: 5px 14px; color: var(--text); text-decoration: none; white-space: nowrap; text-align: left;
}
.user-drop form { margin: 0; }
.user-drop button { height: auto; line-height: inherit; border: 0; border-radius: 0; background: none; font-size: 12px; cursor: pointer; }
.user-drop a:hover, .user-drop button:hover { background: var(--btn-hover); color: var(--accent); }
