/* ═══════════════════════════════════════════
   瀚林整蛊 · 管理后台
   深色侧栏 + 浅色内容区 · 现代管理台风格
   ═══════════════════════════════════════════ */
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .05);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* 显式覆盖默认 [hidden] 规则，确保 CSS display:flex 不会盖掉 hidden */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
.link { font-size: 13px; }
.link:hover { text-decoration: underline; }
.hint { color: var(--muted); font-size: 12px; }

/* ── 按钮 ─────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border: 1px solid transparent; border-radius: 8px;
  font-size: 14px; font-weight: 500; cursor: pointer; transition: all .15s ease;
  white-space: nowrap; user-select: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-block { width: 100%; }

/* ── 输入控件 ─────────────────────────── */
.input, select.input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; color: var(--text); background: #fff; outline: none; transition: border .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.search { width: 220px; }
select.input { cursor: pointer; }

/* ── 登录页 ───────────────────────────── */
.login-wrap { display: flex; min-height: 100vh; background: #fff; }
.login-brand {
  flex: 1.1; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #312e81 0%, #4f46e5 55%, #7c3aed 100%);
  color: #fff; padding: 48px;
}
.login-brand::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(600px 300px at 85% 15%, rgba(255,255,255,.14), transparent 60%),
    radial-gradient(500px 350px at 10% 90%, rgba(255,255,255,.10), transparent 60%);
}
.brand-inner { position: relative; z-index: 1; max-width: 420px; }
.brand-logo {
  width: 64px; height: 64px; border-radius: 16px; background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.3); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 700; margin-bottom: 24px;
}
.brand-inner h1 { font-size: 30px; font-weight: 700; margin-bottom: 14px; letter-spacing: .5px; }
.brand-inner p { font-size: 15px; line-height: 1.9; opacity: .85; }
.brand-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.brand-tags span {
  font-size: 12.5px; padding: 5px 12px; border-radius: 999px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22);
}
.login-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 48px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 24px; margin-bottom: 6px; }
.login-sub { color: var(--muted); margin-bottom: 28px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: #334155; margin-bottom: 7px; }
.field input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14.5px; outline: none; transition: border .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.login-error {
  margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 13px;
  background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca;
}

/* ── 主布局 ───────────────────────────── */
#app-view { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--sidebar); color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.side-logo { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; }
.side-logo-badge {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 700;
}
.side-logo-text b { display: block; color: #f1f5f9; font-size: 15px; }
.side-logo-text small { color: #64748b; font-size: 11.5px; }
.side-nav { flex: 1; padding: 8px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 11px 14px; border-radius: 9px;
  color: #94a3b8; font-size: 14px; margin-bottom: 4px; transition: all .15s ease;
}
.nav-item svg { width: 19px; height: 19px; fill: currentColor; }
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 500; }
.side-foot { padding: 14px 12px 16px; border-top: 1px solid rgba(148, 163, 184, .12); }
.admin-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.admin-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #22d3ee, #6366f1); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600;
}
.admin-meta b { display: block; color: #e2e8f0; font-size: 13.5px; }
.admin-meta small { color: #64748b; font-size: 11.5px; }

.main { flex: 1; min-width: 0; padding: 0 28px 40px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 0 18px; position: sticky; top: 0; z-index: 20;
  background: linear-gradient(var(--bg) 78%, transparent);
}
.topbar h2 { font-size: 20px; font-weight: 650; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.env-pill {
  font-size: 12px; padding: 4px 12px; border-radius: 999px;
  background: var(--success-soft); color: var(--success); border: 1px solid #bbf7d0; font-weight: 500;
}
.topbar-date { color: var(--muted); font-size: 13px; }

.view { animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── KPI ──────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px;
  border-radius: 50%; background: radial-gradient(circle, rgba(79,70,229,.08), transparent 70%);
}
.kpi-label { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.kpi-value { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.kpi-sub { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

/* ── 卡片 / 表格 ──────────────────────── */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; margin-bottom: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.card-head h3 { font-size: 16px; font-weight: 600; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 760px; }
.table th {
  text-align: left; padding: 11px 14px; background: #f8fafc; color: #475569;
  font-size: 12.5px; font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.table .ta-r { text-align: right; }
.table .empty { text-align: center; color: var(--muted); padding: 36px 0; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; font-size: 12.5px; }

/* ── 徽章 ─────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-muted { background: #f1f5f9; color: var(--muted); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }

/* ── 分页 ─────────────────────────────── */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 16px; }
.pager button {
  min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 7px;
  background: #fff; cursor: pointer; font-size: 13px; color: var(--text); transition: all .12s;
}
.pager button:hover:not(:disabled):not(.current) { border-color: var(--primary); color: var(--primary); }
.pager button.current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager .page-info { font-size: 13px; color: var(--muted); margin-left: 8px; }

/* ── 模态框 ───────────────────────────── */
.modal-mask {
  position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: maskIn .18s ease; backdrop-filter: blur(2px);
}
@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%;
  max-width: 560px; max-height: 88vh; overflow: auto; animation: modalIn .22s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16.5px; }
.modal-close {
  width: 30px; height: 30px; border-radius: 8px; border: none; background: #f1f5f9;
  color: var(--muted); font-size: 16px; cursor: pointer; line-height: 1;
}
.modal-close:hover { background: #e2e8f0; color: var(--text); }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); background: #f8fafc; border-radius: 0 0 16px 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.modal .field { margin-bottom: 0; }

/* 生成码展示 */
.codes-result { margin-top: 16px; }
.codes-result h4 { font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 8px; }
.code-list {
  display: flex; flex-wrap: wrap; gap: 8px; max-height: 220px; overflow: auto;
  background: #f8fafc; border: 1px dashed var(--border); border-radius: 10px; padding: 12px;
}
.code-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: #fff; border: 1px solid var(--border); border-radius: 7px;
  font-family: Consolas, Menlo, monospace; font-size: 12.5px; letter-spacing: .5px;
}
.code-chip button {
  border: none; background: var(--primary-soft); color: var(--primary); border-radius: 5px;
  padding: 2px 7px; font-size: 11.5px; cursor: pointer;
}
.code-chip button:hover { background: var(--primary); color: #fff; }

/* ── Toast ────────────────────────────── */
#toast-root { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 380px;
  padding: 12px 16px; border-radius: 10px; background: #fff; box-shadow: var(--shadow-lg);
  font-size: 13.5px; animation: toastIn .25s ease; border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.out { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); } }

/* ── 会话抽屉 ─────────────────────────── */
.session-list { display: flex; flex-direction: column; gap: 10px; }
.session-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
}
.session-item .s-meta { font-size: 12.5px; color: var(--muted); }
.session-item .s-meta b { color: var(--text); font-weight: 600; }

/* ── 配置快照 ─────────────────────────── */
.config-snapshot { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.snap-item {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
}
.snap-item .s-key { font-size: 12px; color: var(--muted); font-family: Consolas, Menlo, monospace; margin-bottom: 4px; }
.snap-item .s-val { font-size: 15px; font-weight: 600; word-break: break-all; }
.snap-item .s-desc { font-size: 11.5px; color: #94a3b8; margin-top: 4px; }

/* ── 账号安全 ─────────────────────────── */
.sec-info {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
}
.sec-cell {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
}
.sec-cell .c-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.sec-cell .c-value { font-size: 14.5px; font-weight: 600; word-break: break-all; }
.sec-form { display: grid; grid-template-columns: 1fr; max-width: 520px; gap: 0; }
.sec-form .field { margin-bottom: 14px; }
.sec-form .field input { width: 100%; }
.sec-form > div:last-child { margin-top: 4px; }

@media (max-width: 1080px) { .sec-info { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) { .sec-info { grid-template-columns: 1fr; } }

/* ── 响应式 ───────────────────────────── */
@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .config-snapshot { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .login-wrap { flex-direction: column; }
  .login-brand { flex: none; padding: 36px 24px; }
  .brand-tags { display: none; }
  .sidebar { width: 68px; }
  .side-logo-text, .admin-meta, .side-foot .btn { display: none; }
  .nav-item { justify-content: center; padding: 13px; }
  .nav-item { font-size: 0; }
  .nav-item svg { width: 22px; height: 22px; }
  .side-foot { padding: 10px; }
  .admin-chip { justify-content: center; }
  .main { padding: 0 14px 30px; }
  .search { width: 140px; }
}
