/* ============================================================
   管理后台
   ============================================================ */

.login-title { margin: 0 0 6px; font-size: 20px; text-align: center; }
.login-sub { margin: 0 0 24px; font-size: 12.5px; color: var(--text-faint); text-align: center; }
.login-error {
  margin-bottom: 12px; padding: 10px 13px; font-size: 12.5px;
  color: var(--danger); background: var(--danger-soft); border-radius: var(--radius); line-height: 1.6;
}
.login-foot { margin: 18px 0 0; font-size: 11.5px; color: var(--text-faint); text-align: center; }

.admin { display: grid; grid-template-columns: 224px 1fr; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------------- 侧栏（浅色品牌风格） ---------------- */
.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-elevated); border-right: 1px solid var(--border);
  padding: 16px 12px; padding-top: calc(16px + var(--safe-top));
  z-index: 200;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 8px 18px; font-size: 15px; font-weight: 800; color: var(--accent);
}
.sidebar-brand .mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), #FFE066);
  font-size: 15px; box-shadow: var(--shadow-sm);
}
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  font-size: 13.5px; font-weight: 600; color: var(--text-soft);
  border-radius: var(--radius); cursor: pointer; user-select: none;
  transition: var(--transition);
}
.nav-item:hover { background: var(--bg-sunken); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-sm); }
.nav-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-foot {
  padding-top: 14px; border-top: 1px solid var(--border);
  margin-top: 12px;
}
.sidebar-scrim {
  display: none; position: fixed; inset: 0; z-index: 190;
  background: rgba(25, 22, 15, 0.45); backdrop-filter: blur(2px);
}

/* ---------------- 内容区 ---------------- */
.content { overflow-y: auto; padding: 20px 24px 40px; min-height: 0; -webkit-overflow-scrolling: touch; }
.content-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.content-head h1 { margin: 0; font-size: 20px; font-weight: 800; }
.tab-panel { animation: fade-in 0.18s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 14px; flex-wrap: wrap;
}
.panel-desc { margin: 0; font-size: 12.5px; color: var(--text-soft); line-height: 1.75; max-width: 720px; }
.panel-desc code {
  padding: 1px 6px; background: var(--bg-sunken); border-radius: 4px;
  font-size: 11.5px; color: var(--accent);
}

/* 移动端顶栏（汉堡菜单） */
.mobile-topbar {
  display: none; align-items: center; gap: 12px;
  height: 52px; padding: 0 14px; padding-top: var(--safe-top);
  background: var(--bg-elevated); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.hamburger {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; font-size: 18px;
  background: var(--bg-sunken); border: none; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text);
}
.mobile-topbar .title { font-size: 15px; font-weight: 700; }

/* ---------------- 统计卡 ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(166px, 1fr)); gap: 14px; }
.stat-card {
  padding: 16px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-soft); margin-bottom: 8px; }
.stat-value { font-size: 27px; font-weight: 800; line-height: 1.15; color: var(--accent); }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--text-faint); }
.stat-foot { margin-top: 7px; font-size: 11.5px; color: var(--text-faint); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }

.trend-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.trend-row:last-child { margin-bottom: 0; }
.trend-bar-wrap { flex: 1; height: 8px; background: var(--bg-sunken); border-radius: var(--radius-pill); overflow: hidden; }
.trend-bar { height: 100%; background: var(--brand); border-radius: var(--radius-pill); transition: width 0.4s; min-width: 3px; }

/* ---------------- 渠道 ---------------- */
.channel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.channel-card {
  display: flex; flex-direction: column; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.channel-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.channel-icon {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius); font-size: 18px; flex-shrink: 0;
}
.channel-card-body { flex: 1; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.channel-card-foot { display: flex; gap: 6px; padding: 11px 16px; border-top: 1px solid var(--border); background: var(--bg-sunken); flex-wrap: wrap; }

.webhook-box { margin-top: 4px; padding: 10px 12px; background: var(--bg-sunken); border-radius: var(--radius); }
.webhook-url { margin: 4px 0 8px; word-break: break-all; white-space: normal; font-size: 11px; line-height: 1.55; }

/* ---------------- 团队 ---------------- */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.team-card { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }

/* ---------------- 知识库 ---------------- */
.kb-layout { display: flex; gap: 14px; align-items: flex-start; }
.kb-cat {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 11px; font-size: 13px; font-weight: 500; color: var(--text-soft);
  border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition);
}
.kb-cat:hover { background: var(--bg-sunken); }
.kb-cat.active { background: var(--brand-soft); color: var(--on-brand); font-weight: 700; }
.kb-cat b { cursor: pointer; color: var(--text-faint); font-weight: 400; }
.kb-cat b:hover { color: var(--danger); }

.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }

/* ---------------- 飞书绑定码 ---------------- */
.bind-code-box {
  margin: 4px 0 16px; padding: 18px; text-align: center;
  background: linear-gradient(135deg, var(--brand-tint), var(--accent-soft));
  border: 1px dashed var(--brand); border-radius: var(--radius-lg);
}
.bind-code {
  margin: 8px 0 6px; font-size: 27px; font-weight: 800; letter-spacing: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--accent); word-break: break-all;
}
.bind-steps { padding: 14px; background: var(--bg-sunken); border-radius: var(--radius); font-size: 13px; }
.bind-steps code {
  padding: 2px 7px; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 4px; font-size: 12.5px; color: var(--accent); font-weight: 600;
}

/* ---------------- 通用补充 ---------------- */
.ticket-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-row .checkbox-label { font-size: 13px; color: var(--text); }
.table-wrap-admin { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: auto; }
.hide-mobile { }

/* ============================================================
   平板
   ============================================================ */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ============================================================
   移动端：侧栏变抽屉
   ============================================================ */
@media (max-width: 900px) {
  .admin { grid-template-columns: 1fr; }

  .mobile-topbar { display: flex; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: min(82vw, 280px);
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
    border-right: none;
  }
  .sidebar.open { transform: none; }
  .sidebar-scrim { display: block; animation: mask-in 0.2s ease; }

  /* 顶部间距改由 mobile-topbar 承担，让汉堡栏能贴住顶部 */
  .content { padding: 0 14px calc(32px + var(--safe-bottom)); }
  .mobile-topbar { position: sticky; top: 0; margin: 0 -14px 14px; }
  .content-head { margin-bottom: 14px; }
  .content-head h1 { font-size: 17px; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 13px; }
  .stat-value { font-size: 23px; }

  .channel-grid { grid-template-columns: 1fr; }
  .team-grid { grid-template-columns: 1fr; }
  .ticket-grid { grid-template-columns: 1fr; }

  .kb-layout { flex-direction: column; }
  .kb-layout > .card:first-child { width: 100% !important; }

  .panel-head { flex-direction: column; align-items: stretch; }
  .panel-head .btn { align-self: flex-start; }

  .hide-mobile { display: none !important; }

  /* 表格：横向可滚动，首列固定 */
  .table-wrap-admin { border-radius: var(--radius); }
  .table th, .table td { padding: 10px; font-size: 12.5px; white-space: nowrap; }
  .table th:first-child, .table td:first-child { position: sticky; left: 0; background: var(--bg-elevated); z-index: 1; }
  .table th:first-child { background: var(--bg-sunken); z-index: 3; }

  .webhook-url { font-size: 10.5px; }
}
