:root {
  --bg: #FFFFFF; --bg-soft: #F7F8FA; --bg-muted: #F1F3F6; --bg-hover: #F9FAFB;
  --btn-2nd: #F3F4F6; --btn-2nd-hover: #E9EBEF;
  --border: #E4E6EB; --border-ctl: #DCDFE4; --divider: #ECEEF1; --line: #F0F1F4;
  --text: #1F2329; --text-data: #374151; --text-2: #6B7280; --text-3: #9CA3AF; --text-4: #C4C8CF;
  --accent-bg: #D3EFDC; --accent: #166534; --ok-dot: #4CAF73;
  --warn: #B42318; --warn-bg: #FDECEC; --primary: #2B3038; --primary-hover: #1F2329;
  --r: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg-soft); color: var(--text);
  font: 13px/1.55 "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12px; }
.warn { color: var(--warn); }
button, input, select, textarea { font: inherit; color: inherit; }

/* 按钮 */
.btn { height: 32px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--border-ctl);
  background: var(--bg); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: var(--btn-2nd); border-color: transparent; }
.btn.ghost:hover { background: var(--btn-2nd-hover); }
.btn.danger { color: var(--warn); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.icon-btn { width: 26px; height: 26px; border: 0; background: transparent; border-radius: 6px; cursor: pointer;
  color: var(--text-2); font-size: 13px; line-height: 26px; padding: 0; }
.icon-btn:hover { background: var(--bg-muted); color: var(--text); }
.icon-btn.del:hover { background: var(--warn-bg); color: var(--warn); }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }

.input, .search, textarea.input, select.input {
  height: 32px; padding: 0 10px; border: 1px solid var(--border-ctl); border-radius: var(--r);
  background: var(--bg); outline: none; min-width: 0;
}
textarea.input { height: auto; padding: 6px 10px; resize: vertical; }
.input:focus, .search:focus { border-color: var(--text-3); }

/* 登录 */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 340px; max-width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 28px 24px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { font-size: 18px; margin: 4px 0 0; }
.login-card p { margin: 0 0 6px; }
.login-card input { height: 36px; padding: 0 12px; border: 1px solid var(--border-ctl); border-radius: var(--r); outline: none; }
.login-card .btn { height: 36px; }
.login-mark, .brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--bg-muted); position: relative; }
.login-mark::before, .brand-mark::before { content: ""; position: absolute; left: 9px; top: 9px; width: 10px; height: 10px;
  border: 2px solid var(--text-2); border-radius: 50%; }
.login-mark::after, .brand-mark::after { content: ""; position: absolute; left: 15px; top: 5px; width: 2px; height: 22px; background: var(--text-2); }

/* 顶栏 */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
  padding: 0 18px; height: 56px; background: var(--bg-soft); border-bottom: 1px solid var(--divider); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.tabs { display: flex; gap: 2px; background: var(--bg-muted); padding: 3px; border-radius: 9px; }
.tabs button { border: 0; background: transparent; padding: 0 14px; height: 28px; border-radius: 6px;
  cursor: pointer; color: var(--text-2); white-space: nowrap; }
.tabs button.on { background: var(--bg); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.top-actions { margin-left: auto; display: flex; gap: 6px; }

main { padding: 16px 18px 80px; max-width: 1280px; margin: 0 auto; }
.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r); }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--bg-muted); padding: 3px; border-radius: 8px; }
.seg button { border: 0; background: transparent; height: 26px; padding: 0 12px; border-radius: 6px; cursor: pointer; color: var(--text-2); }
.seg button.on { background: var(--bg); color: var(--text); font-weight: 600; }

/* 检索 */
.search-wrap { max-width: 860px; margin: 8px auto 16px; }
.search { width: 100%; height: 44px; font-size: 15px; padding: 0 16px; border-radius: 10px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px;
  background: var(--bg-muted); color: var(--text-2); font-size: 12px; border: 0; cursor: pointer; white-space: nowrap; }
.chip:hover { background: var(--btn-2nd-hover); color: var(--text); }
.chip.acc { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.sec-title { display: flex; align-items: baseline; gap: 8px; margin: 18px 0 8px; font-weight: 700; font-size: 14px; }
.sec-title .muted { font-weight: 400; font-size: 12px; }
.empty { padding: 36px 16px; text-align: center; color: var(--text-3); }

table.list { width: 100%; border-collapse: collapse; }
table.list th { background: var(--bg-soft); color: var(--text-2); font-weight: 400; font-size: 12px; text-align: left;
  padding: 0 12px; height: 34px; border-bottom: 1px solid var(--divider); white-space: nowrap; }
table.list td { padding: 7px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover td { background: var(--bg-hover); }
table.list tr.clickable { cursor: pointer; }
.devname { font-weight: 600; }
.mono { font-family: Consolas, "Microsoft YaHei UI", monospace; color: var(--text-data); }
.seqpill { display: inline-block; min-width: 22px; height: 20px; line-height: 20px; text-align: center; padding: 0 6px;
  border-radius: 999px; background: var(--bg-muted); color: var(--text-data); font-size: 12px; font-weight: 600; }
mark { background: var(--accent-bg); color: var(--accent); border-radius: 3px; padding: 0 1px; }
.fn-group { margin-bottom: 14px; }
.fn-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--divider); }
.fn-head b { font-size: 14px; }
.fn-head .count { color: var(--text-2); font-size: 12px; }

/* 设备卡 */
.dev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(560px, 1fr)); gap: 12px; }
.dev-card { padding: 14px 16px; }
.dev-card.hit { border-color: var(--text-3); }
.dev-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.dev-head h3 { margin: 0; font-size: 15px; }
.dev-head .meta { color: var(--text-2); font-size: 12px; }
.dev-head .acts { margin-left: auto; display: flex; gap: 4px; }
.dev-members { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 10px; }
.dev-members .chip { cursor: default; }
.dev-members .chip.acc { cursor: default; }
.dev-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.diagram { width: 100%; overflow-x: auto; border-radius: 6px; background: var(--bg); }
.diagram svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.fn-summary { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.fn-summary .lbl { color: var(--text-3); font-size: 12px; margin-right: 4px; }
.warnlist { margin: 6px 0 0; padding: 0; list-style: none; }
.warnlist li { color: var(--warn); font-size: 12px; }
.warnlist li::before { content: "! "; font-weight: 700; }
.ctname { color: var(--text-2); font-size: 12px; }

/* 矩阵 */
.matrix-wrap { overflow: auto; max-height: calc(100vh - 150px); }
table.matrix { border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.matrix th, table.matrix td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  padding: 6px 10px; white-space: nowrap; text-align: center; }
table.matrix thead th { position: sticky; top: 0; background: var(--bg-soft); color: var(--text-2); font-weight: 400; z-index: 2; }
table.matrix tbody th { position: sticky; left: 0; background: var(--bg); text-align: left; font-weight: 600; z-index: 1; }
table.matrix thead th:first-child { left: 0; z-index: 3; }
table.matrix td.has { color: var(--text); font-weight: 600; }
table.matrix td.dup { color: var(--warn); }
table.matrix tbody tr:hover td, table.matrix tbody tr:hover th { background: var(--bg-hover); }

/* 录入 */
.edit-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 12px; align-items: start; }
.edit-side { position: sticky; top: 72px; display: flex; flex-direction: column; max-height: calc(100vh - 150px); }
.side-head { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--divider); }
.side-head .input { flex: 1; }
.edit-list { overflow: auto; flex: 1; padding: 4px 0; }
.edit-item { padding: 7px 12px 7px 13px; cursor: pointer; border-left: 3px solid transparent; }
.edit-item:hover { background: var(--bg-hover); }
.edit-item.on { background: var(--bg-muted); border-left-color: var(--primary); }
.edit-item .t { font-weight: 600; }
.edit-item .s { color: var(--text-3); font-size: 12px; }
.edit-sec { padding: 4px 12px; color: var(--text-3); font-size: 12px; background: var(--bg-soft); }
.side-foot { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--divider); }
.form { padding: 16px; }
.form h2 { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.form h2 .acts { margin-left: auto; display: flex; gap: 6px; }
.frow { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 8px 12px; align-items: center; margin-bottom: 10px; }
.frow label { color: var(--text-2); font-size: 12px; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.fgrid label { display: block; color: var(--text-2); font-size: 12px; margin-bottom: 3px; }
.fgrid .input { width: 100%; }
.hint { color: var(--text-3); font-size: 12px; }
.ct-block { border: 1px solid var(--border); border-radius: var(--r); margin-top: 12px; }
.ct-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bg-soft);
  border-bottom: 1px solid var(--divider); border-radius: var(--r) var(--r) 0 0; }
.ct-head .input { width: 160px; height: 28px; font-weight: 600; }
.ct-head .acts { margin-left: auto; display: flex; gap: 2px; align-items: center; }
table.wtab { width: 100%; border-collapse: collapse; }
table.wtab th { color: var(--text-3); font-weight: 400; font-size: 12px; text-align: left; padding: 6px 6px 2px; }
table.wtab td { padding: 3px 6px; }
table.wtab .input { width: 100%; height: 30px; }
table.wtab td.seq { width: 44px; text-align: center; }
table.wtab td.ops { width: 90px; white-space: nowrap; text-align: right; }
.w-ratio { width: 130px; } .w-acc { width: 90px; } .w-va { width: 80px; }
.ct-foot { padding: 6px 10px 10px; display: flex; gap: 8px; align-items: center; }
.unknown { color: var(--text-3); font-size: 11px; }
.savebar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px 8px 16px; box-shadow: 0 6px 24px rgba(0,0,0,.10); white-space: nowrap; }
.dict-table .input { width: 100%; height: 30px; }

/* 历史 */
.hist-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.hist-row:last-child { border-bottom: 0; }
.hist-row .v { width: 56px; color: var(--text-2); }
.hist-row .t { width: 150px; color: var(--text-data); }
.hist-row .s { flex: 1; min-width: 0; }
.badge-new { display: inline-block; padding: 0 8px; height: 20px; line-height: 20px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent); font-size: 11px; font-weight: 700; }

/* 弹窗 / 提示 */
.modal { position: fixed; inset: 0; background: rgba(31,35,41,.28); z-index: 50; display: flex;
  align-items: center; justify-content: center; padding: 16px; }
.modal-card { background: var(--bg); border-radius: 10px; width: 760px; max-width: 100%; max-height: 90vh;
  overflow: auto; box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.modal-head { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--divider); font-weight: 700; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--divider); }
.toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--primary);
  color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.toast.err { background: var(--warn); }

/* 手机 */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 8px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .tabs button { flex: 1; padding: 0 8px; }
  .brand-sub { display: none; }
  main { padding: 12px 16px 90px; }
  .dev-grid { grid-template-columns: minmax(0, 1fr); }
  .edit-layout { grid-template-columns: minmax(0, 1fr); }
  .edit-side { position: static; max-height: 260px; }
  .fgrid { grid-template-columns: 1fr; }
  .frow { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .wtab thead { display: none; }
  table.wtab, table.wtab tbody, table.wtab tr, table.wtab td { display: block; width: 100%; }
  table.wtab tr { display: grid; grid-template-columns: 34px 1fr 1fr 1fr; gap: 4px; padding: 6px 4px;
    border-bottom: 1px solid var(--line); }
  table.wtab td { padding: 0; }
  table.wtab td.seq { width: auto; align-self: center; }
  table.wtab td.fn { grid-column: 2 / 5; }
  table.wtab td.ops { grid-column: 2 / 5; width: auto; text-align: left; }
  .ct-head { flex-wrap: wrap; }
  .hist-row { flex-wrap: wrap; gap: 4px 12px; }
  .hist-row .t { width: auto; }
  .hist-row .s { flex-basis: 100%; }
  table.list.resp thead { display: none; }
  table.list.resp tr { display: block; padding: 8px 12px; border-bottom: 1px solid var(--line); }
  table.list.resp td { display: inline; padding: 0 8px 0 0; border: 0; }
  table.list.resp td.blk { display: block; }
  .savebar { left: 16px; right: 16px; transform: none; justify-content: flex-end; }
  .savebar #saveMsg { margin-right: auto; overflow: hidden; text-overflow: ellipsis; }
}

/* 备案页脚 */
.icp { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 16px; padding: 14px 16px 18px;
  font-size: 11px; color: var(--text-3); }
.icp a { color: inherit; text-decoration: none; }
.icp a:hover { color: var(--text); }
.login { min-height: calc(100vh - 60px); }
main { padding-bottom: 24px; }
#page-edit { padding-bottom: 60px; }
