/* 管理台：两栏布局（左导航 + 右信息栏），TalkerABC 觀感（靛蓝 + 浅底） */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand: #4f46e5;
  --brand-deep: #4338ca;
  --brand-soft: #f1f0fe;
  --ok: #047857;
  --ok-soft: #f2fbf7;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --warn: #92400e;
  --warn-soft: #fffbeb;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #64748b;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --border: #e2e8f0;
}

html, body { height: 100%; }
body {
  font: 13px/1.5 -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* ── 登录 ── */
#login-view {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 320px; padding: 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgb(15 23 42 / 0.08);
}
.login-card h1 { font-size: 16px; margin-bottom: 4px; }
.login-card p { font-size: 12px; color: var(--ink-3); margin-bottom: 18px; }
.login-err { color: var(--danger); font-size: 12px; min-height: 18px; margin: 8px 0 4px; }

/* ── 两栏骨架 ── */
#app-view { display: none; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 216px;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 0 8px 16px; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 9px; overflow: hidden; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft); font-weight: 700; color: var(--brand); font-size: 14px;
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.brand b { font-size: 14px; }
.brand span { display: block; font-size: 11px; color: var(--ink-3); font-weight: 400; }

nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
nav a {
  display: flex; align-items: center; gap: 9px;
  height: 36px; padding: 0 10px; border-radius: 9px;
  color: var(--ink-2); text-decoration: none; font-size: 13px;
}
nav a .ico { width: 18px; text-align: center; opacity: .75; }
nav a:hover { background: var(--bg); color: var(--ink); }
nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side-foot { border-top: 1px solid var(--border); padding-top: 10px; }
.side-foot a { color: var(--ink-3); text-decoration: none; font-size: 12px; padding: 6px 10px; display: block; border-radius: 7px; }
.side-foot a:hover { background: var(--bg); color: var(--danger); }

.main { margin-left: 216px; padding: 26px 32px 60px; }
.view-head { margin-bottom: 18px; }
.view-head h2 { font-size: 18px; }
.view-head p { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }

/* ── 通用组件 ── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 16px;
}
.card h3 { font-size: 13.5px; margin-bottom: 12px; }

.btn {
  height: 34px; padding: 0 14px; border-radius: 9px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--brand-deep); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--ink-2); border-color: var(--border); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #991b1b; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 7px; }

input, select, textarea {
  height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 9px;
  font: inherit; color: var(--ink); background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { height: auto; padding: 8px 10px; font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--ink-2); }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { min-width: 140px; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: left; font-weight: 500; color: var(--ink-3); font-size: 11.5px;
  padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 9px 8px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
tr:hover td { background: #fafbfe; }
.mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: .3px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-neutral { background: #f1f5f9; color: var(--ink-2); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-danger { background: var(--danger-soft); color: var(--danger); }
.b-brand { background: var(--brand-soft); color: var(--brand); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.stat .num { font-size: 22px; font-weight: 700; }
.stat .lbl { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 12px; color: var(--ink-3); }
.gen-result { background: var(--ok-soft); border: 1px solid #b6e6d2; border-radius: 9px; padding: 10px 12px; margin-top: 12px; }
.gen-result code { display: block; font-family: ui-monospace, Consolas, monospace; font-size: 13px; color: var(--ok); padding: 2px 0; }
.hint { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; }
.ev { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid #f1f5f9; font-size: 12px; }
.ev time { color: var(--ink-3); font-family: ui-monospace, monospace; font-size: 11px; flex: none; }
.ev .t { flex: none; width: 86px; font-weight: 500; }
.toast {
  position: fixed; top: 18px; right: 18px; z-index: 99;
  background: var(--ink); color: #fff; font-size: 12.5px;
  padding: 9px 14px; border-radius: 9px; opacity: 0; transition: opacity .18s;
  pointer-events: none;
}
.toast.show { opacity: .95; }
.keybox { width: 100%; min-height: 84px; resize: vertical; }
.danger-note { background: var(--danger-soft); border: 1px solid #fecaca; border-radius: 9px; padding: 9px 12px; font-size: 12px; color: var(--danger); margin: 10px 0; }
.empty { color: var(--ink-3); font-size: 12.5px; padding: 16px 0; text-align: center; }

/* ── 确认弹窗（替代原生 confirm：内嵌/沙箱预览里原生 confirm 会被浏览器禁用而不弹）── */
.modal-mask {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgb(15 23 42 / .38);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: mask-in .16s ease;
}
.modal-mask[hidden] { display: none; }
.modal {
  width: 100%; max-width: 384px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 22px 16px;
  box-shadow: 0 24px 64px rgb(15 23 42 / .24);
  animation: modal-in .18s cubic-bezier(.16, 1, .3, 1);
}
.modal h3 { font-size: 15px; }
.modal p { font-size: 12.5px; color: var(--ink-2); line-height: 1.7; margin-top: 8px; white-space: pre-line; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
@keyframes mask-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.97) } to { opacity: 1; transform: none } }
