/* ============================================================================
   云打印平台 · 商户后台样式（纯手写，无框架、无 CDN、无外链字体/图标）
   主色 #2563eb，卡片圆角 8px，轻阴影，<=768px 侧边栏收成抽屉
   ========================================================================== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --text: #1f2937;
  --text-soft: #6b7280;
  --text-mute: #9ca3af;
  --line: #e5e7eb;
  --line-soft: #f1f3f7;
  --bg: #f5f7fb;
  --card: #ffffff;
  --green: #16a34a;
  --green-bg: #e8f7ee;
  --gray: #6b7280;
  --gray-bg: #f1f2f4;
  --red: #dc2626;
  --red-bg: #fdecec;
  --blue: #2563eb;
  --blue-bg: #e8f0fe;
  --orange: #d97706;
  --orange-bg: #fdf1e0;
  --cyan: #0891b2;
  --cyan-bg: #e2f6fa;
  --indigo: #4f46e5;
  --indigo-bg: #eceafd;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .14);
  --sidebar-w: 224px;
  --topbar-h: 58px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; }
hr.sep { border: 0; border-top: 1px solid var(--line-soft); margin: 16px 0; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace; }
.muted { color: var(--text-soft); font-weight: 400; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ic { flex: none; vertical-align: -2px; }

/* ---------------------------------------------------------------- 侧边栏 */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 30;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line-soft); min-height: var(--topbar-h);
}
.brand-logo {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-size: 14px; }
.brand-text small { color: var(--text-mute); font-size: 11px; }
.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: var(--radius); color: var(--text); font-weight: 500;
}
.nav-item:hover { background: var(--line-soft); text-decoration: none; }
.nav-item.is-active { background: var(--primary-light); color: var(--primary-dark); }
.nav-item.is-active .ic { color: var(--primary); }
.sidebar-foot { border-top: 1px solid var(--line-soft); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.who { display: flex; align-items: center; gap: 8px; }
.who-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--line-soft);
  color: var(--text-soft); display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.who-text { display: flex; flex-direction: column; line-height: 1.3; overflow: hidden; }
.who-text b { font-size: 13px; }
.who-text small { color: var(--text-mute); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- 主区域 */
.main { margin-left: var(--sidebar-w); min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 0 18px;
}
.topbar-title { font-size: 16px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-meta { color: var(--text-soft); font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.content { padding: 18px; display: flex; flex-direction: column; gap: 16px; flex: 1; }

.icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius); border: 1px solid var(--line);
  background: #fff; color: var(--text-soft); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.icon-btn:hover { color: var(--primary); border-color: #c7d7fb; background: var(--primary-light); }
.nav-toggle { display: none; }

/* ---------------------------------------------------------------- 卡片 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 13px 16px; border-bottom: 1px solid var(--line-soft);
}
.card-head h2 { font-size: 15px; }
.card-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 16px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }

.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.page-h2 { font-size: 17px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.back-link { font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.section-title { font-size: 14px; display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; }
.section-title:first-child { margin-top: 0; }

/* ---------------------------------------------------------------- 统计卡 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.stat { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.stat-head { display: flex; align-items: center; }
.stat-label { color: var(--text-soft); font-size: 13px; }
.stat-ico {
  margin-left: auto; width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary-light); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
}
.stat-value { font-size: 26px; font-weight: 650; line-height: 1.2; letter-spacing: -.5px; }
.stat-unit { font-size: 12px; color: var(--text-mute); font-weight: 400; margin-left: 6px; }
.stat-foot { font-size: 12px; color: var(--text-soft); }

/* ---------------------------------------------------------------- 表格 */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table thead th {
  background: #fafbfd; color: var(--text-soft); font-weight: 600; font-size: 12px;
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
.table tbody tr:hover { background: #fbfcfe; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .empty { text-align: center; color: var(--text-mute); padding: 28px 12px; }
.table .ops { width: 1%; white-space: nowrap; }
.table-kv th { width: 150px; color: var(--text-soft); font-weight: 500; background: #fafbfd; }
.row-active { background: var(--primary-light); }
.row-actions { display: flex; gap: 6px; flex-wrap: nowrap; }
.detail-row > td { background: #fafbfd; }
.job-detail { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.json-block {
  margin: 0; padding: 10px 12px; background: #0f172a; color: #e2e8f0; border-radius: var(--radius);
  font-size: 12px; line-height: 1.5; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}
.payload-cell { max-width: 380px; }
.payload-cell .json { font-size: 11.5px; color: var(--text-soft); word-break: break-all; }

/* ---------------------------------------------------------------- 徽章 */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1.6; white-space: nowrap;
}
.badge-ok { color: var(--green); background: var(--green-bg); }
.badge-muted { color: var(--gray); background: var(--gray-bg); }
.badge-danger { color: var(--red); background: var(--red-bg); }
.badge-info { color: var(--blue); background: var(--blue-bg); }
.badge-warn { color: var(--orange); background: var(--orange-bg); }
.badge-cyan { color: var(--cyan); background: var(--cyan-bg); }
.badge-queued { color: var(--indigo); background: var(--indigo-bg); }
.tag {
  display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 6px;
  background: var(--line-soft); color: var(--text-soft); font-size: 12px;
}

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 7px 13px; border-radius: var(--radius); border: 1px solid var(--line);
  background: #fff; color: var(--text); font-size: 13px; font-weight: 500;
  cursor: pointer; text-decoration: none; line-height: 1.4; white-space: nowrap;
}
.btn:hover { border-color: #c7d7fb; color: var(--primary-dark); text-decoration: none; background: #fbfcff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger { background: #fff; border-color: #f3c9c9; color: var(--red); }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--line-soft); color: var(--text); border-color: transparent; }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- 表单 */
.form { display: flex; flex-direction: column; gap: 14px; padding: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.form-inline-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 12px; color: var(--text-soft); }
.input {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--text); font-size: 13px; font-family: inherit;
}
.input:focus { outline: 0; border-color: #93b4fb; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #9ca3af 50%), linear-gradient(135deg, #9ca3af 50%, transparent 50%); background-position: calc(100% - 14px) 14px, calc(100% - 9px) 14px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
textarea.input { resize: vertical; line-height: 1.5; }
.input-sm { padding: 4px 8px; font-size: 12px; }
.code-editor { font-size: 12.5px; line-height: 1.55; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; }
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  padding: 13px 16px; border-bottom: 1px solid var(--line-soft); background: #fcfdff;
}
.field-inline { flex: 0 1 190px; }
.filter-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.fieldset { border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 12px 14px; margin: 0; }
.fieldset legend { padding: 0 6px; font-size: 12px; color: var(--text-soft); }
.radio-row { display: flex; gap: 16px; margin-bottom: 12px; }
.radio { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.mode-pane { display: flex; flex-direction: column; gap: 8px; }

/* ---------------------------------------------------------------- 提示条 */
.alert { border-radius: var(--radius); padding: 11px 14px; font-size: 13px; border: 1px solid transparent; }
.alert-head { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.alert-list { margin: 6px 0 0; padding-left: 20px; }
.alert-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background: var(--primary-light); border-color: #c7d7fb; color: #1e40af; }
.alert-danger { background: var(--red-bg); border-color: #f5c2c2; color: #991b1b; display: flex; align-items: center; gap: 8px; }
.flash-stack { display: flex; flex-direction: column; gap: 8px; }
.flash { border-radius: var(--radius); padding: 10px 14px; font-size: 13px; border: 1px solid transparent; }
.flash-success { background: var(--green-bg); border-color: #bfe6cd; color: #166534; }
.flash-error { background: var(--red-bg); border-color: #f5c2c2; color: #991b1b; }
.flash-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* ---------------------------------------------------------------- 详情 */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px 18px; }
.detail-item { display: flex; flex-direction: column; gap: 2px; font-size: 13px; min-width: 0; }
.detail-wide { grid-column: 1 / -1; }
.detail-label { color: var(--text-mute); font-size: 12px; }

/* ---------------------------------------------------------------- 分页 */
.pager {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-top: 1px solid var(--line-soft);
}
.pager-info { font-size: 12px; color: var(--text-soft); }
.pager-links { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.pg {
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12.5px; color: var(--text);
}
.pg:hover { border-color: #c7d7fb; background: var(--primary-light); text-decoration: none; }
.pg-active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pg-active:hover { background: var(--primary-dark); color: #fff; }
.pg-disabled { color: var(--text-mute); background: var(--line-soft); border-color: transparent; }
.pg-gap { border-color: transparent; color: var(--text-mute); }

/* ---------------------------------------------------------------- 抽屉 / 遮罩 / 吐司 */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 94vw); background: #fff;
  border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); z-index: 50;
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .22s ease;
}
.drawer.is-open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line-soft); }
.drawer-head h2 { font-size: 15px; flex: 1; }
.drawer-body { padding: 16px; overflow-y: auto; }
.scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .38); z-index: 40; }
.scrim[hidden] { display: none; }
.toast-stack { position: fixed; top: 16px; right: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, 92vw); }
.toast {
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--primary);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 10px 13px; font-size: 13px;
  animation: toast-in .18s ease-out;
}
.toast-success { border-left-color: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-warn { border-left-color: var(--orange); }
.toast-info { border-left-color: var(--primary); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- 空状态 */
.empty-state { padding: 40px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-icon {
  width: 54px; height: 54px; border-radius: 14px; background: var(--primary-light); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------------------------------------------------------------- 登录页 */
.auth-body { background: linear-gradient(160deg, #f5f7fb 0%, #e8efff 100%); display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-wrap { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 24px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-brand div { display: flex; flex-direction: column; line-height: 1.3; }
.auth-brand small { color: var(--text-mute); font-size: 11px; }
.auth-title { font-size: 18px; margin-bottom: 14px; }
.auth-card .form { padding: 0; }
.auth-foot { margin: 16px 0 0; font-size: 12px; color: var(--text-mute); }
.auth-foot code { background: var(--line-soft); padding: 1px 4px; border-radius: 4px; }
.auth-copy { text-align: center; font-size: 12px; color: var(--text-mute); margin: 0; }

/* ---------------------------------------------------------------- 自适应 */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: translateX(0); }
  .main { margin-left: 0; }
  .nav-toggle { display: inline-flex; }
  .content { padding: 12px; gap: 12px; }
  .topbar { padding: 0 12px; }
  .topbar-meta { display: none; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .stat-value { font-size: 22px; }
  .table th, .table td { padding: 9px 10px; }
  .field-inline { flex: 1 1 100%; }
  .filter-actions { margin-left: 0; width: 100%; }
  .table-kv th { width: 110px; }
  .drawer { width: 100vw; }
  .toast-stack { left: 12px; right: 12px; top: 12px; max-width: none; }
}

/* ----------------------------------------------------------------------------
   管理动作补充（设备/门店/密钥/MQTT 页）
   ---------------------------------------------------------------------------- */
.disclosure > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure[open] > summary { margin-bottom: 14px; }
.field-hint { display: block; font-size: 12px; color: var(--text-soft); margin-top: 4px; line-height: 1.5; }
.secret-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.secret-val { font-family: var(--mono, ui-monospace, Consolas, monospace); font-size: 13px; word-break: break-all;
  background: var(--gray-bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; flex: 1 1 260px; }
.code-block { font-family: var(--mono, ui-monospace, Consolas, monospace); font-size: 12.5px; line-height: 1.7;
  background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 12px 14px; overflow-x: auto; white-space: pre; margin: 0; }
.metric-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.metric-k { font-size: 12px; color: var(--text-soft); }
.metric-v { font-size: 20px; font-weight: 600; margin-top: 4px; word-break: break-all; }

/* 表单必填标记 + 警示按钮（api-credentials 页用） */
.req { color: var(--red); font-weight: 600; }
.btn-warn { background: #fff; color: var(--orange); border-color: #f3d5a7; }
.btn-warn:hover { background: var(--orange-bg); }

/* ----------------------------------------------------------------------------
   模板可视化编辑器
   ---------------------------------------------------------------------------- */
.tpl-editor { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr); gap: 16px; margin-top: 14px; }
@media (max-width: 1100px) { .tpl-editor { grid-template-columns: 1fr; } }

.tpl-toolbar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.tpl-toolbar .field { margin: 0; min-width: 260px; }

.tpl-blocks { display: flex; flex-direction: column; gap: 10px; }

.tpl-block { border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; }
.tpl-block-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--line-soft); flex-wrap: wrap; }
.tpl-block-badge { font-weight: 600; font-size: 13px; color: var(--primary-dark); }
.tpl-block-idx { font-size: 11px; color: var(--text-mute); font-family: ui-monospace, Consolas, monospace; }
.tpl-block-desc { font-size: 12px; flex: 1 1 160px; min-width: 0; }
.tpl-block-ops { display: flex; gap: 4px; margin-left: auto; }
.tpl-block-ops .btn { padding: 3px 8px; font-size: 12px; line-height: 1.4; }
.tpl-block-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; padding: 12px 10px; }
.tpl-field { min-width: 0; }
.tpl-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.tpl-rep { display: flex; flex-direction: column; gap: 6px; }
.tpl-rep-row { display: flex; gap: 6px; align-items: center; }
.tpl-rep-row .input { min-width: 0; }
.tpl-rep-col .input:nth-child(1) { max-width: 70px; }
.tpl-lint-item { font-size: 12.5px; padding: 6px 8px; border-radius: 8px; margin-top: 6px; line-height: 1.5; }
.tpl-lint-err { background: var(--red-bg); color: #991b1b; }
.tpl-lint-warn { background: #fffbeb; color: #92400e; }
.tpl-lint-ok { font-size: 12.5px; color: var(--green); padding: 6px 0; }

.tpl-col-side { min-width: 0; }
.tpl-preview-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.tpl-paper-wrap { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 8px; overflow-x: auto; }
.tpl-paper { margin: 0; font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 12px;
  line-height: 1.45; white-space: pre; color: #111827; background: #fff; border-radius: 6px; padding: 10px; }
.tpl-lint { margin-top: 8px; max-height: 260px; overflow-y: auto; }

/* ----------------------------------------------------------------------------
   变量选择器（模板编辑器）
   ---------------------------------------------------------------------------- */
.tpl-var { margin-top: 5px; }
.tpl-var-btn {
  font-size: 11.5px; padding: 2px 9px; border: 1px solid var(--line);
  background: #fff; border-radius: 6px; cursor: pointer;
  color: var(--primary-dark); font-family: inherit;
}
.tpl-var-btn:hover { background: var(--primary-bg); border-color: var(--primary); }
.tpl-var-panel {
  margin-top: 6px; padding: 8px 9px; border: 1px solid var(--line);
  border-radius: 8px; background: #fbfcfe; max-height: 220px; overflow-y: auto;
}
.tpl-var-group {
  font-size: 11px; color: var(--text-mute); margin: 7px 0 4px;
  font-weight: 700; letter-spacing: .04em;
}
.tpl-var-group:first-child { margin-top: 0; }
.tpl-var-row { display: flex; flex-wrap: wrap; gap: 4px; }
.tpl-var-item {
  font-family: ui-monospace, Consolas, monospace; font-size: 11.5px;
  padding: 2px 7px; border: 1px solid var(--line); background: #fff;
  border-radius: 5px; cursor: pointer; color: #0f172a; line-height: 1.5;
}
.tpl-var-item:hover { background: var(--primary-bg); border-color: var(--primary); color: var(--primary-dark); }
.tpl-var-empty { font-size: 12px; color: var(--text-mute); }
