/* ============================================================
   DrawStd 统一 Web 应用样式
   布局参照 step（顶栏 + 左侧分组菜单 + 内容区），
   登录卡片与配色参照 cad（深蓝品牌区 + 白色表单区）。
   ============================================================ */
:root {
  --primary: #0f4c81;
  --primary-2: #17629f;
  --secondary: #1f6feb;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1c2530;
  --muted: #6b7684;
  --border: #dde3ea;
  --accent: #dd7a00;
  --ok: #1a7f37;
  --err: #cf222e;
  --navy-1: #0b2344;
  --navy-2: #123f7d;
  --shadow: 0 1px 3px rgba(16, 24, 40, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", Roboto, sans-serif;
  font-size: 14px; line-height: 1.55; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--secondary); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12.5px; }
.mono { font-family: "Cascadia Mono", Consolas, Monaco, monospace; }

/* ---------------- 按钮 / 表单 / 通用件 ---------------- */
.btn, button.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 7px 13px; border-radius: 6px; cursor: pointer; font-size: 12.5px;
  font-family: inherit; text-decoration: none; display: inline-flex;
  align-items: center; gap: 6px; line-height: 1.4;
}
.btn:hover { border-color: var(--secondary); color: var(--secondary); text-decoration: none; }
.btn.primary, button.primary {
  background: var(--secondary); color: #fff; border: 1px solid var(--secondary);
  padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 13px;
  font-weight: 600; font-family: inherit;
}
.btn.primary:hover, button.primary:hover { background: #1a5fd0; color: #fff; }
.btn.danger { color: var(--err); border-color: #f0c4c7; }
.btn.danger:hover { background: #fdeaea; border-color: var(--err); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled, button:disabled { opacity: .55; cursor: wait; }
input, select, textarea {
  font-family: inherit; font-size: 13px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #cfe3fb; border-color: var(--secondary); }
textarea { resize: vertical; line-height: 1.5; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.panel h2 { font-size: 15px; margin: 0 0 14px; color: var(--primary); }
.panel h3 { font-size: 13.5px; margin: 0 0 10px; color: var(--primary); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.panel-head h2 { margin: 0; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card {
  background: linear-gradient(160deg, #fff, #f7f9fc); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px;
}
.card .k { font-size: 12px; color: var(--muted); }
.card .v { font-size: 21px; font-weight: 650; color: var(--primary); }
.card .v.ok { color: var(--ok); }
.card .v.err { color: var(--err); }
.card .s { font-size: 11.5px; color: var(--muted); }

.table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { background: #f7f9fc; color: var(--primary); font-weight: 600; white-space: nowrap; }
.table tbody tr:hover { background: #f6faff; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.op { text-align: right; white-space: nowrap; }
.table td.op .btn { margin-left: 4px; }
.table .sub { font-size: 11.5px; color: var(--muted); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 11.5px;
         background: #eef2f7; color: #46566a; border: 1px solid #e2e8f0; }
.badge.ok { background: #e8f7ee; color: var(--ok); border-color: #c3ecd2; }
.badge.warn { background: #fff4e5; color: var(--accent); border-color: #ffe0b3; }
.badge.err { background: #fdeaea; color: var(--err); border-color: #f8cccc; }
.badge.blue { background: #eaf2fb; color: var(--primary); border-color: #cddff5; }
.badge + .badge { margin-left: 4px; }

.empty { padding: 26px; text-align: center; color: var(--muted); font-size: 13px; }

/* 额度趋势 / 配额进度 */
.trend { display: flex; align-items: flex-end; gap: 4px; height: 96px; padding-top: 8px;
         border-bottom: 1px solid var(--border); }
.trend .bar { flex: 1; min-width: 6px; background: #7db0e4; border-radius: 3px 3px 0 0; }
.trend .bar:hover { background: var(--secondary); }
.trend-labels { display: flex; justify-content: space-between; margin-top: 5px;
                font-size: 11px; color: var(--muted); }
.quota-bar { height: 9px; background: #e9eef5; border-radius: 6px; overflow: hidden; }
.quota-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0; }
.err-text { color: var(--err); font-size: 12.5px; }
.ok-text { color: var(--ok); font-size: 12.5px; }

.toast {
  position: fixed; right: 22px; bottom: 22px; background: #24303f; color: #fff;
  padding: 11px 18px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 6px 18px rgba(0,0,0,.2); z-index: 200; max-width: 420px;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }

/* 通用对话框 */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 32, 56, .42);
              display: flex; align-items: center; justify-content: center; z-index: 150; padding: 20px; }
.modal { background: #fff; border-radius: 10px; width: min(560px, 100%);
         box-shadow: 0 20px 60px rgba(11,35,68,.24); max-height: 86vh; display: flex; flex-direction: column; }
.modal h3 { margin: 0; padding: 16px 20px; border-bottom: 1px solid var(--border); font-size: 15px; color: var(--primary); }
.modal .modal-body { padding: 18px 20px; overflow: auto; }
.modal .modal-actions { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------------- 登录页 ---------------- */
body.login-body { min-height: 100vh; background: var(--bg); }
.bg-layer {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(900px 520px at 12% 8%, #dfe9fa 0%, rgba(223,233,250,0) 62%),
              radial-gradient(800px 500px at 92% 100%, #e6eefb 0%, rgba(230,238,251,0) 60%),
              var(--bg);
}
.bg-layer::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(26,102,214,.055) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(26,102,214,.055) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(1100px 700px at 50% 40%, #000 25%, transparent 78%);
  -webkit-mask-image: radial-gradient(1100px 700px at 50% 40%, #000 25%, transparent 78%);
}
.login-shell { position: relative; z-index: 1; min-height: 100vh; display: flex;
               align-items: center; justify-content: center; padding: 32px 24px; }
.login-card {
  display: grid; grid-template-columns: 420px 400px; background: #fff;
  border: 1px solid rgba(20,40,80,.08); border-radius: 16px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 18px 48px rgba(11,35,68,.14);
  animation: rise .42s cubic-bezier(.2,.7,.3,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.brand-panel {
  position: relative; padding: 40px 36px 30px; color: #eaf2ff;
  background: linear-gradient(158deg, var(--navy-1) 0%, var(--navy-2) 62%, #1a5ab0 100%);
  display: flex; flex-direction: column; overflow: hidden;
}
.brand-panel::before {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.055) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.055) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(120% 80% at 20% 0%, #000 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(120% 80% at 20% 0%, #000 30%, transparent 80%);
}
.bp-art { position: absolute; right: -70px; top: -70px; width: 230px; opacity: .42; }
.bp-mark {
  position: relative; width: 44px; height: 44px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); color: #fff;
}
.bp-title { position: relative; font-size: 23px; font-weight: 650; letter-spacing: .5px; margin-top: 22px; }
.bp-sub { position: relative; margin: 8px 0 30px; font-size: 12.5px; line-height: 1.9; opacity: .82; }
.bp-feats { position: relative; list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.bp-feats li { display: flex; gap: 11px; align-items: flex-start; font-size: 12.5px; }
.bp-feats .ic { flex: 0 0 22px; height: 22px; border-radius: 6px; background: rgba(255,255,255,.16);
                display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
.bp-feats .t { font-weight: 600; }
.bp-feats .d { display: block; margin-top: 2px; font-size: 11.5px; opacity: .72; }
.bp-foot { position: relative; margin-top: auto; padding-top: 34px; font-size: 11.5px; opacity: .62; }

.form-panel { padding: 44px 38px; display: flex; align-items: center; }
.form-panel form { width: 100%; }
.fp-head h1 { margin: 0 0 6px; font-size: 21px; color: var(--primary); }
.fp-head p { margin: 0 0 26px; font-size: 12.5px; color: var(--muted); }
.banner { padding: 9px 12px; border-radius: 7px; font-size: 12.5px; margin-bottom: 14px; }
.banner.err { background: #fdeaea; color: var(--err); border: 1px solid #f8cccc; }
.banner.info { background: #eaf2fb; color: var(--primary); border: 1px solid #cddff5; }
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 12.5px; font-weight: 600; color: #414b5a; margin-bottom: 7px; }
.inp-wrap { position: relative; display: flex; align-items: center; }
.inp-wrap .lead { position: absolute; left: 11px; display: inline-flex; color: #8b95a5; pointer-events: none; }
.inp-wrap input { width: 100%; height: 42px; padding-left: 36px; font-size: 14px; background: #fbfcfe; }
.inp-wrap input:focus { background: #fff; border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(31,111,235,.12); outline: none; }
.inp-wrap .eye { position: absolute; right: 8px; border: 0; background: none; color: var(--muted);
                 font-size: 12px; cursor: pointer; padding: 4px 6px; }
.inp-wrap.has-tail input { padding-right: 54px; }
.row-between { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 18px; font-size: 12px; color: var(--muted); }
.row-between label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.submit { width: 100%; height: 44px; border: 0; border-radius: 7px; color: #fff; font-size: 14px;
          font-weight: 600; font-family: inherit; cursor: pointer;
          background: linear-gradient(90deg, var(--primary), var(--secondary)); }
.submit:hover { filter: brightness(1.06); }
.submit:disabled { opacity: .6; cursor: wait; }
.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.5);
        border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.fp-tip { margin: 24px 0 0; padding-top: 15px; border-top: 1px solid var(--border);
          font-size: 11.5px; color: var(--muted); line-height: 1.85; }
.fp-tip code { background: #f1f5fa; padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
@media (max-width: 880px) {
  .login-card { grid-template-columns: 1fr; max-width: 430px; }
  .brand-panel { padding: 26px 28px; }
  .bp-art, .bp-feats, .bp-foot { display: none; }
  .bp-title { margin-top: 14px; font-size: 20px; }
  .bp-sub { margin-bottom: 4px; }
  .form-panel { padding: 28px; }
}

/* ---------------- 应用外壳 ---------------- */
body.app-body { overflow: hidden; }
.topbar {
  height: 62px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: linear-gradient(90deg, var(--primary), var(--primary-2));
  color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .logo { font-size: 26px; line-height: 1; }
.brand h1 { font-size: 16px; margin: 0; font-weight: 600; white-space: nowrap; }
.brand .sub { margin: 2px 0 0; font-size: 11.5px; opacity: .8; white-space: nowrap; }
.nav-toggle {
  display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
  width: 34px; height: 30px; padding: 0 8px; flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.34); background: rgba(255,255,255,.12);
  border-radius: 6px; cursor: pointer; color: #fff;
}
.nav-toggle:hover { background: rgba(255,255,255,.22); }
.nav-toggle span { display: block; height: 2px; border-radius: 2px; background: currentColor; transition: .16s; }
body.nav-collapsed .nav-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body.nav-collapsed .nav-toggle span:nth-child(2) { opacity: 0; }
body.nav-collapsed .nav-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.status { font-size: 12px; background: rgba(255,255,255,.16); padding: 5px 12px; border-radius: 14px; white-space: nowrap; }
.status.ok { background: rgba(26,127,55,.85); }
.status.err { background: rgba(207,34,46,.85); }
.userbox { display: flex; align-items: center; gap: 10px; }
/* 右上角账户菜单：昵称 + 头像触发，点击展开二级菜单 */
.user-menu { position: relative; }
.user-menu-trigger {
  display: flex; align-items: center; gap: 8px; border: 1px solid rgba(255,255,255,.24);
  background: rgba(255,255,255,.14); color: #fff; border-radius: 18px;
  padding: 3px 10px 3px 3px; cursor: pointer; font-family: inherit;
  font-size: 12.5px; line-height: 1; transition: background .16s;
}
.user-menu-trigger:hover, .user-menu.open .user-menu-trigger { background: rgba(255,255,255,.26); }
.user-menu-trigger .avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.28); color: #fff; font-size: 13px; font-weight: 600;
  background-size: cover; background-position: center; overflow: hidden;
}
.user-nick { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-caret { width: 0; height: 0; flex: 0 0 auto; margin-left: 2px;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid rgba(255,255,255,.9); transition: transform .16s; }
.user-menu.open .user-menu-caret { transform: rotate(180deg); }
.user-menu-pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; display: none;
  min-width: 156px; padding: 6px; background: #fff; color: var(--text);
  border: 1px solid var(--border); border-radius: 9px; box-shadow: 0 10px 28px rgba(15,32,56,.20);
}
.user-menu.open .user-menu-pop { display: block; }
.user-menu-pop button {
  display: flex; align-items: center; width: 100%; border: 0; background: none;
  text-align: left; padding: 9px 12px; border-radius: 6px; font-family: inherit;
  font-size: 13px; color: var(--text); cursor: pointer; white-space: nowrap;
}
.user-menu-pop button:hover { background: #f2f6fb; color: var(--primary); }
.user-menu-pop button.danger { color: #cf222e; }
.user-menu-pop button.danger:hover { background: #fff1f2; }
.user-menu-pop .menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
/* 修改头像弹窗 */
.avatar-edit { display: flex; align-items: center; gap: 18px; }
.avatar-preview {
  width: 88px; height: 88px; border-radius: 50%; flex: 0 0 88px;
  border: 2px solid var(--border); background: var(--primary) center/cover no-repeat;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.layout { display: flex; height: calc(100vh - 62px); }
.sidebar {
  width: 214px; flex: 0 0 214px; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  overflow: hidden; transition: width .18s ease, flex-basis .18s ease;
}
body.nav-collapsed .sidebar { width: 0; flex-basis: 0; border-right-width: 0; }
.nav-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 10px 0 14px; }
.nav-section + .nav-section { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 4px; }
.nav-children { display: flex; flex-direction: column; }
.nav-group {
  display: flex; align-items: center; gap: 8px; width: 100%; border: 0;
  border-left: 3px solid transparent; background: none; cursor: pointer;
  padding: 9px 16px 5px; font-family: inherit; font-size: 11px; letter-spacing: 1px;
  color: var(--muted); text-align: left; user-select: none;
}
.nav-group:hover { color: var(--primary); }
.nav-group-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-group-caret { width: 0; height: 0; flex: 0 0 auto; border-left: 4px solid currentColor;
                   border-top: 4px solid transparent; border-bottom: 4px solid transparent;
                   transform: rotate(90deg); transform-origin: 40% 50%; transition: transform .16s; opacity: .65; }
.nav-section.collapsed .nav-group-caret { transform: rotate(0); }
.nav-section.collapsed .nav-children { display: none; }
.nav-section.collapsed .nav-group { padding-bottom: 9px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  border: 0; border-left: 3px solid transparent; background: none; text-align: left;
  padding: 9px 16px; font-size: 13.2px; color: var(--text); cursor: pointer;
  white-space: nowrap; font-family: inherit;
}
.nav-item:hover { background: #f2f6fb; }
.nav-item.active { background: #eaf2fb; border-left-color: var(--secondary); color: var(--primary); font-weight: 600; }
.nav-ico { width: 16px; height: 16px; flex: 0 0 16px; opacity: .7; display: inline-flex;
           align-items: center; justify-content: center; }
.nav-item.active .nav-ico { opacity: 1; }
.nav-foot { padding: 10px 16px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); white-space: nowrap; }
.nav-backdrop { display: none; }

.content { flex: 1; min-width: 0; min-height: 0; padding: 20px 24px 48px; overflow-x: hidden; overflow-y: auto; }
.content.no-pad { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.page-title { display: flex; align-items: baseline; gap: 12px; margin: 0 0 16px; }
.page-title h2 { margin: 0; font-size: 18px; color: var(--primary); }
.page-title span { font-size: 12.5px; color: var(--muted); }
.engine-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px;
              background: #fff; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.engine-bar .t { font-size: 13.5px; font-weight: 600; color: var(--primary); }
.engine-bar .sp { flex: 1; }
.engine-frame { flex: 1 1 auto; width: 100%; border: 0; min-height: 0; background: #fff; }
.svgbox { border: 1px solid var(--border); border-radius: 8px; background: #fff;
          overflow: auto; height: 440px; padding: 8px; }
.svgbox svg { max-width: 100%; height: auto; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 980px) { .split { grid-template-columns: 1fr; } }
.editor-box { width: 100%; min-height: 300px; font-family: "Cascadia Mono", Consolas, monospace;
              font-size: 12.5px; line-height: 1.55; white-space: pre; tab-size: 2; }
pre.json { background: #f7f9fc; border: 1px solid var(--border); border-radius: 8px;
           padding: 14px; font-size: 12px; overflow: auto; max-height: 420px; margin: 0; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; font-size: 12.5px; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.quick button { text-align: left; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px;
                background: #fbfcfe; cursor: pointer; font-family: inherit; }
.quick button:hover { border-color: var(--secondary); background: #eef5ff; }
.quick b { display: block; font-size: 13.5px; color: var(--primary); margin-bottom: 4px; }
.quick span { font-size: 11.5px; color: var(--muted); }
@media (max-width: 720px) {
  .status, .user-nick, .user-menu-caret { display: none; }
  .sidebar { position: absolute; z-index: 40; height: calc(100vh - 62px); }
  body:not(.nav-collapsed) .nav-backdrop { display: block; position: absolute; inset: 62px 0 0 0;
                                           background: rgba(15,32,56,.25); z-index: 30; }
  .content { padding: 14px; }
}

/* ---- 样式模板编辑器：参数配置 / YAML 双 tab ---- */
.tpl-tabs { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tpl-tab { border: 1px solid transparent; border-bottom: none; background: transparent; color: var(--muted);
  padding: 7px 16px; border-radius: 8px 8px 0 0; cursor: pointer; font: inherit; font-size: 13px; }
.tpl-tab:hover { color: var(--text); background: rgba(37,99,235,.06); }
.tpl-tab.on { background: #fff; border-color: var(--border); color: var(--blue); font-weight: 600;
  margin-bottom: -1px; border-bottom: 1px solid #fff; }
.tpl-tabs .sub { margin-left: 8px; font-size: 11.5px; color: var(--muted); }
.chk-row { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.chk-row .chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; white-space: nowrap; cursor: pointer; }
#tplLayers input, #tplLayers select { padding: 5px 7px; font-size: 12.5px; }

/* ---- 新建角色：权限分组勾选树 ---- */
.perm-tree { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: #fbfcfe; }
.perm-group { margin-bottom: 10px; }
.perm-group:last-child { margin-bottom: 0; }
.perm-g-head { display: flex; align-items: center; gap: 8px; padding: 4px 2px; cursor: pointer; user-select: none; }
.perm-g-head b { font-size: 13px; }
.perm-g-count { margin-left: auto; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 14px; padding: 4px 2px 2px 26px; }
.perm-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 3px 6px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.perm-item:hover { background: rgba(37,99,235,.07); }
.perm-item code { font-size: 11px; color: var(--muted); background: #f1f4f9; border-radius: 4px; padding: 1px 5px; }

/* ---- 权限树：分组折叠 / 展开 ---- */
.perm-g-head { display: flex; align-items: center; gap: 8px; padding: 4px 2px; }
.perm-g-toggle { display: inline-flex; align-items: center; gap: 7px; background: none; border: 0;
  cursor: pointer; font: inherit; padding: 3px 6px; border-radius: 6px; color: inherit; }
.perm-g-toggle:hover { background: rgba(37,99,235,.06); }
.perm-g-toggle .caret { width: 0; height: 0; border-left: 5px solid var(--muted);
  border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform .15s; }
.perm-group .perm-g-toggle .caret { transform: rotate(90deg); }
.perm-group.collapsed .perm-g-toggle .caret { transform: rotate(0deg); }
.perm-group.collapsed .perm-grid { display: none; }
.perm-g-count { margin-left: auto; }

/* ---- 外部服务配置：继承/自定义分段控件 ---- */
.seg { display: inline-flex; border: 1px solid var(--border, #d5dce6); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; background: #fff; color: var(--muted, #6b7785); font: inherit; font-size: 12px;
  padding: 5px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border, #d5dce6); }
.seg button.on { background: var(--secondary, #1f6feb); color: #fff; }
.svc-card { margin-bottom: 14px; }
.svc-card .panel-head { align-items: flex-start; }
.svc-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 16px; margin-top: 12px; }
.svc-fields label.field { margin-bottom: 0; }
