:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --border: #e4e8f0;
  --border-strong: #d3d9e6;
  --text: #1f2430;
  --text-2: #4b5567;
  --muted: #8a93a6;
  --primary: #07c160;
  --primary-dark: #05a850;
  --primary-soft: #e8f8ef;
  --danger: #e0483d;
  --danger-soft: #fdecea;
  --warn: #d98600;
  --warn-soft: #fff6e5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 50, 0.04), 0 8px 24px rgba(20, 30, 50, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font-family: inherit; font-size: inherit; }
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #e6f7ee 0%, var(--bg) 55%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 19px; margin: 0 0 6px; letter-spacing: -0.2px; }
.login-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.brand-dot {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, #07c160, #06a3d8);
  display: grid; place-items: center; margin-bottom: 16px;
  box-shadow: 0 6px 16px rgba(7, 193, 96, 0.28);
}
.brand-dot svg { width: 20px; height: 20px; fill: #fff; }

/* ---------- 基础控件 ---------- */
.field { margin-bottom: 14px; }
.field > label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-2); margin-bottom: 6px;
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.6; }
input[type="text"], input[type="password"], textarea, select {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: #fff; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.12);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.65; }
input[readonly] { background: #fafbfd; color: var(--text-2); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: #fff; color: var(--text); cursor: pointer; font-weight: 500;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #b9c2d4; background: #fafbfd; }
.btn:active { transform: translateY(0.5px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: #eef1f7; }
.btn.danger { color: var(--danger); border-color: #f0c9c6; background: #fff; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.block { width: 100%; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- 布局 ---------- */
.layout { height: 100%; display: flex; flex-direction: column; }
.header {
  height: 58px; flex: 0 0 auto; display: flex; align-items: center; gap: 14px;
  padding: 0 22px; background: #fff; border-bottom: 1px solid var(--border);
}
.header .logo { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -0.2px; }
.header .logo .brand-dot { width: 28px; height: 28px; border-radius: 8px; margin: 0; box-shadow: none; }
.header .logo .brand-dot svg { width: 15px; height: 15px; }
.header .spacer { flex: 1; }

.stat-strip { display: flex; gap: 8px; align-items: center; }
.stat {
  background: #f7f9fc; border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 11px; text-align: center; min-width: 68px;
}
.stat b { display: block; font-size: 14px; line-height: 1.3; }
.stat span { font-size: 11px; color: var(--muted); }

.body { flex: 1; display: flex; min-height: 0; }

/* ---------- 侧栏 ---------- */
.sidebar {
  width: 258px; flex: 0 0 auto; background: #fff;
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  min-height: 0;
}
.sidebar-head {
  padding: 14px 14px 10px; display: flex; align-items: center; justify-content: space-between;
}
.sidebar-head h2 { font-size: 12.5px; margin: 0; color: var(--muted); font-weight: 600; letter-spacing: .4px; }
.tenant-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.tenant-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px;
  border-radius: 9px; cursor: pointer; margin-bottom: 2px;
  border: 1px solid transparent; transition: background .12s;
}
.tenant-item:hover { background: #f6f8fc; }
.tenant-item.active { background: var(--primary-soft); border-color: #bfecd2; }
.tenant-avatar {
  width: 32px; height: 32px; border-radius: 8px; flex: 0 0 auto;
  background: #eef2f8; display: grid; place-items: center;
  font-size: 13px; font-weight: 650; overflow: hidden;
  color: #64748b;
}
.tenant-avatar img { width: 100%; height: 100%; object-fit: cover; }
.tenant-meta { min-width: 0; flex: 1; }
.tenant-name { font-weight: 550; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tenant-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; background: #c9d0de; }
.dot.ok { background: var(--primary); box-shadow: 0 0 0 3px rgba(7,193,96,.14); }
.dot.fail { background: var(--danger); box-shadow: 0 0 0 3px rgba(224,72,61,.14); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(217,134,0,.14); }

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; overflow-y: auto; padding: 22px 26px 60px; }
.empty-state {
  height: 100%; display: grid; place-items: center; color: var(--muted); text-align: center;
}
.empty-state .big { font-size: 15px; color: var(--text-2); margin-bottom: 8px; font-weight: 550; }

.page-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.page-head h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -0.3px; }
.page-head .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 9px 14px; cursor: pointer; font-size: 13.5px; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); font-weight: 600; }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.card h3 { font-size: 14px; margin: 0 0 4px; }
.card .card-desc { font-size: 12.5px; color: var(--muted); margin: 0 0 16px; line-height: 1.65; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1080px) { .grid-2 { grid-template-columns: 1fr; } }

.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; }

.steps { counter-reset: s; padding: 0; margin: 0; list-style: none; }
.steps li {
  position: relative; padding-left: 30px; margin-bottom: 14px;
  font-size: 13px; line-height: 1.75; color: var(--text-2);
}
.steps li::before {
  counter-increment: s; content: counter(s);
  position: absolute; left: 0; top: 1px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary-dark);
  font-size: 11.5px; font-weight: 700; display: grid; place-items: center;
}

.alert {
  padding: 11px 13px; border-radius: 8px; font-size: 12.5px; line-height: 1.7;
  margin-bottom: 14px; border: 1px solid transparent;
}
.alert.warn { background: var(--warn-soft); border-color: #ffe0b0; color: #7a5200; }
.alert.danger { background: var(--danger-soft); border-color: #f8cdc9; color: #8c2a24; }
.alert.ok { background: var(--primary-soft); border-color: #bfecd2; color: #056b35; }
.alert code { background: rgba(0,0,0,.05); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* 开关 */
.switch-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px dashed var(--border);
}
.switch-row:last-child { border-bottom: none; }
.switch-row .label { font-weight: 550; font-size: 13.5px; }
.switch-row .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.switch { margin-left: auto; position: relative; width: 40px; height: 22px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: #d5dbe6; border-radius: 999px;
  transition: background .18s; cursor: pointer;
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; transition: transform .18s;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* 素材选择 */
.media-picked {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px dashed var(--border-strong); border-radius: 8px; background: #fafbfd;
}
.media-picked .thumb {
  width: 44px; height: 44px; border-radius: 7px; background: #eaeef6;
  display: grid; place-items: center; font-size: 11px; color: var(--muted); overflow: hidden; flex: 0 0 auto;
}
.media-picked .thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-picked .info { min-width: 0; flex: 1; }
.media-picked .info .n { font-size: 13px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-picked .info .m { font-size: 11.5px; color: var(--muted); font-family: ui-monospace, monospace; margin-top: 2px; }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfd; }
tbody tr:hover { background: #fbfcfe; }
td.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--text-2); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 550; white-space: nowrap;
}
.badge.ok { background: var(--primary-soft); color: #06753c; }
.badge.failed { background: var(--danger-soft); color: #a32f26; }
.badge.pending { background: #eef2f8; color: #5b6478; }
.badge.voice { background: #eaf3ff; color: #2b62b8; }
.badge.image { background: #f3ecff; color: #6b40b8; }
.badge.text { background: #f0f2f5; color: #4d5666; }

.pager { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 12.5px; color: var(--muted); }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(18, 24, 38, .38);
  backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 50; padding: 24px;
}
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 620px;
  max-height: 78vh; display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(10,20,40,.22);
}
.modal-head {
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.modal-head h3 { margin: 0; font-size: 15px; flex: 1; }
.modal-body { padding: 8px 10px 14px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.pick-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: 8px; cursor: pointer; border: 1px solid transparent;
}
.pick-item:hover { background: #f7f9fc; }
.pick-item.sel { background: var(--primary-soft); border-color: #bfecd2; }
.pick-item .thumb {
  width: 46px; height: 46px; border-radius: 7px; background: #eef2f8; overflow: hidden;
  display: grid; place-items: center; flex: 0 0 auto; font-size: 10.5px; color: var(--muted);
}
.pick-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.pick-item .info { min-width: 0; flex: 1; }
.pick-item .info .n { font-size: 13px; font-weight: 550; }
.pick-item .info .m { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.pick-item .play {
  border: 1px solid var(--border-strong); background: #fff; border-radius: 6px;
  padding: 3px 9px; font-size: 11.5px; cursor: pointer; color: var(--text-2);
}
.pick-item .play:hover { border-color: var(--primary); color: var(--primary-dark); }

/* toast */
.toast-wrap {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: #1f2430; color: #fff; padding: 9px 16px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.2); animation: tin .18s ease-out;
}
.toast.err { background: #c0392b; }
.toast.ok { background: #0f8a4a; }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.loading-line {
  height: 2px; background: linear-gradient(90deg, transparent, var(--primary), transparent);
  background-size: 40% 100%; animation: slide 1s linear infinite; border-radius: 2px;
}
@keyframes slide { from { background-position: -40% 0; } to { background-position: 140% 0; } }

.section-title { font-size: 12.5px; font-weight: 650; color: var(--muted); letter-spacing: .5px; margin: 26px 0 12px; }
.kv { display: flex; gap: 10px; font-size: 13px; padding: 6px 0; }
.kv .k { color: var(--muted); width: 96px; flex: 0 0 auto; }
.kv .v { color: var(--text); word-break: break-all; }

/* ============ 菜单编辑器 ============ */
.menu-preview {
  background: #f6f7f9; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 12px 0; margin: 14px 0 16px; overflow: hidden;
}
.mp-sub {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 2px 0; max-width: 240px; margin: 0 auto 10px;
}
.mp-sub-item {
  padding: 9px 14px; font-size: 13px; color: var(--text); text-align: center;
  border-bottom: 1px solid #f2f3f6;
}
.mp-sub-item:last-child { border-bottom: none; }
.mp-bar { display: flex; border-top: 1px solid #e9ebf0; }
.mp-cell {
  flex: 1; min-width: 0; text-align: center; padding: 11px 6px; font-size: 13px;
  color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-right: 1px solid #e9ebf0;
}
.mp-cell:last-child { border-right: none; }
.mp-empty { color: #c8cdd8; }
.mp-caret { font-size: 10px; color: var(--muted); margin-left: 3px; }

.menu-node {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px 14px 8px;
  margin-top: 12px; background: #fcfdfe;
}
.menu-node-head, .sub-node-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.menu-node-title { font-size: 13px; font-weight: 650; color: var(--text-2); }
.menu-node-head .btn, .sub-node-head .btn { margin-left: auto; }
.sub-node-head span { font-size: 12.5px; color: var(--text-2); font-weight: 550; }

.sub-list {
  margin-top: 6px; padding: 12px; background: #fff;
  border: 1px dashed var(--border-strong); border-radius: 8px;
}
.sub-list-head { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.sub-node { border-top: 1px solid #f1f2f6; padding-top: 12px; margin-top: 12px; }
.sub-list-head + .sub-node { border-top: none; padding-top: 0; margin-top: 0; }
.sub-list > .btn.sm { margin-top: 4px; }
