/* home_viewer — 聚合工作台首页（设计 token 对齐 frontend/weight；浏览器下限 Chromium 80，
   兜底行在前、新特性行在后；不用 :has/dvh 独占/inset 单独出现）。 */

:root {
  --page: #f9f9f7;            /* 页面底 */
  --surface: #fcfcfb;         /* 卡片面 */
  --ink: #0b0b0b;             /* 主文字 */
  --ink-2: #52514e;           /* 次文字 */
  --muted: #898781;           /* 弱文字 */
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;          /* 主交互色 */
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.05);
  --shadow-pop: 0 4px 12px rgba(11, 11, 11, 0.08), 0 16px 40px rgba(11, 11, 11, 0.14);
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ── 登录页（与四应用同款：渐变底 + pop-in + 顶部饰条） ── */

body.login-body {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top))
           max(20px, env(safe-area-inset-right))
           max(20px, env(safe-area-inset-bottom))
           max(20px, env(safe-area-inset-left));
  overflow-y: auto;
}
.login-body {
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 420px at 50% -15%, rgba(233, 211, 75, 0.20), transparent 60%),
    radial-gradient(1000px 480px at 85% -10%, rgba(42, 120, 214, 0.14), transparent 60%),
    radial-gradient(800px 420px at 0% 110%, rgba(27, 175, 122, 0.10), transparent 60%),
    var(--page);
}
.login-card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 38px;
  width: min(440px, 100%); text-align: left;
  box-shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 24px 65px rgba(31, 41, 55, 0.12);
  animation: pop-in 0.22s ease;
}
.login-card::before {
  content: ""; position: absolute;
  top: 0; right: 0; left: 0; bottom: auto; inset: 0 0 auto; /* inset 兜底四边 */
  height: 4px;
  background: linear-gradient(90deg, #e8d24a, #f3c93e, #e8d24a);
}
.login-brand { display: flex; align-items: center; gap: 14px; }
/* 品牌 logo（乐享瘦，黄底深字方形头像）：圆角 + 细描边 + 柔和投影 */
.brand-logo {
  flex: none; display: block; object-fit: cover;
  border: 1px solid rgba(11, 11, 11, 0.08);
  box-shadow: 0 6px 16px rgba(176, 148, 32, 0.28);
}
.login-brand .brand-logo { width: 48px; height: 48px; border-radius: 14px; }
.login-kicker {
  color: #1d66c0; font-size: 11px; font-weight: 700; letter-spacing: .12em;
  margin-bottom: 3px;
}
.login-card h1 { font-size: 23px; line-height: 1.25; color: #17211b; }
.login-sub {
  color: #646c68; font-size: 14px; margin: 22px 0 20px; line-height: 1.75;
  overflow-wrap: anywhere;
}
.login-actions { display: grid; gap: 10px; }
.login-actions + .login-actions { margin-top: 10px; }
.login-card .btn-primary, .login-card .btn-ghost {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px;
  margin: 0; padding: 11px 20px; border-radius: 9px; font-size: 14px; font-weight: 600;
  line-height: 1.35; text-align: center; text-decoration: none; transition: .15s ease;
}
.login-card .btn-primary {
  /* 品牌黄 CTA（与 logo 同源 #e9d34b；黄底白字对比不足，用深字） */
  background: #e9d34b; border: 1px solid #dfc435; color: #26251f;
}
.login-card .btn-primary:hover { background: #f0dc63; border-color: #d4be35; }
.login-card .btn-primary:active { transform: translateY(1px); background: #ddc23c; }
.login-card .btn-ghost { background: #fff; border: 1px solid #d9dedb; color: #3d4942; }
.login-card .btn-ghost:hover { background: #faf6e3; border-color: #d9cd8f; }
.login-card .btn-ghost:active { background: #f5efd7; }
.login-card a:focus-visible {
  outline: 3px solid rgba(176, 148, 32, .38); outline-offset: 2px;
}
.login-note, .login-fallback {
  color: #77817b; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere;
}
.login-note { margin: -2px 2px 2px; }
.login-fallback { margin: 14px 2px 0; text-align: center; }
.login-dev {
  display: grid; gap: 8px; margin-top: 24px; padding-top: 18px; border-top: 1px solid #edf0ee;
}
.login-dev > span { color: #929a95; font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.login-dev .btn-ghost { min-height: 42px; color: #68736c; font-size: 13px; font-weight: 500; }

@keyframes pop-in { from { opacity: 0; transform: scale(1.015); } to { opacity: 1; transform: none; } }

/* ── 首页：顶栏 + 欢迎语 + 模块卡片网格 ── */

.home-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center;
  padding: 26px max(26px, env(safe-area-inset-right)) 48px max(26px, env(safe-area-inset-left));
  padding-top: max(26px, env(safe-area-inset-top));
  padding-bottom: max(48px, env(safe-area-inset-bottom));
  background:
    radial-gradient(900px 420px at 50% -15%, rgba(233, 211, 75, 0.20), transparent 60%),
    radial-gradient(1000px 480px at 85% -10%, rgba(42, 120, 214, 0.14), transparent 60%),
    radial-gradient(800px 420px at 0% 110%, rgba(27, 175, 122, 0.10), transparent 60%),
    var(--page);
}

.topbar {
  width: 100%; max-width: 1080px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  animation: card-in 0.3s ease backwards;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .brand-logo { width: 42px; height: 42px; border-radius: 12px; }
.brand-kicker {
  color: #1d66c0; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; margin: 0 0 2px;
}
.brand-title { font-size: 17px; margin: 0; color: #17211b; }
.topbar-user { display: flex; align-items: center; gap: 12px; flex: none; }
.user-name { color: var(--ink-2); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.btn-out {
  border: 1px solid #d9dedb; background: #fff; border-radius: 9px;
  padding: 8px 14px; font-size: 13px; font-weight: 500; color: #3d4942;
  text-decoration: none; transition: .15s ease;
}
.btn-out:hover { background: #f2f6fb; border-color: #a8c0dd; }
.btn-out:active { background: #edf2fa; }
.btn-out:focus-visible, .module-card:focus-visible {
  outline: 3px solid rgba(42, 120, 214, .28); outline-offset: 2px;
}

.hero { width: 100%; max-width: 1080px; margin: 38px 0 22px; animation: card-in 0.3s .06s ease backwards; }
.hero-kicker {
  color: #1d66c0; font-size: 11px; font-weight: 700; letter-spacing: .12em; margin: 0 0 6px;
}
.hero h1 { font-size: 26px; line-height: 1.3; margin: 0; color: #17211b; }
.hero p { color: var(--ink-2); margin: 10px 0 0; font-size: 14px; }

.cards {
  width: 100%; max-width: 1080px;
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
/* 四组分块（2026-10-13）：每组左侧竖排组标签，右侧卡片网格；组间距隔开 */
.group-row {
  width: 100%; max-width: 1080px;
  display: flex; align-items: stretch; gap: 16px;
}
.group-row + .group-row { margin-top: 44px; }
.group-label {
  flex: 0 0 auto;
  display: flex; justify-content: center;
  padding: 4px 0 4px 4px;
  font-size: 13px; font-weight: 700; letter-spacing: 4px;
  color: var(--muted);
  writing-mode: vertical-rl;                 /* CJK 竖排，/ 顺转 90° 充当分隔 */
  user-select: none;
}
.group-row .cards {
  flex: 1; min-width: 0;
  max-width: none;                            /* 宽度交给 .group-row 约束 */
}

.module-card {
  display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 20px 18px; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  animation: card-in 0.34s ease backwards;
}
.module-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-pop);
  border-color: rgba(201, 174, 41, 0.55);
}
.module-card:active { transform: translateY(-1px); }
.module-icon {
  /* 品牌黄底 + 深色线条图标（呼应 logo 黄底深字） */
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #f0d95e, #e3c634);
  color: #2f2e28; box-shadow: 0 8px 20px rgba(227, 198, 52, 0.38);
}
.module-name {
  font-size: 16px; font-weight: 700; color: #17211b;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.module-arrow { color: var(--accent); font-weight: 400; transition: transform 0.18s ease; }
.module-card:hover .module-arrow { transform: translate(2px, -2px); }
.module-desc { color: var(--ink-2); font-size: 13px; line-height: 1.6; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
/* 卡片 stagger 入场：依次 60ms 延迟浮现（纯 CSS，无 JS 依赖） */
.module-card:nth-child(1) { animation-delay: 0.10s; }
.module-card:nth-child(2) { animation-delay: 0.16s; }
.module-card:nth-child(3) { animation-delay: 0.22s; }
.module-card:nth-child(4) { animation-delay: 0.28s; }

/* ── 响应式与动效偏好 ── */

@media (max-width: 620px) {
  .home-shell { padding: 18px 16px 32px; }
  .hero { margin: 26px 0 18px; }
  .hero h1 { font-size: 21px; }
  .brand-title { font-size: 15px; }
  .cards { gap: 12px; }
  /* 窄屏：组标签改横排置于组顶，不再占左侧竖排 */
  .group-row { flex-direction: column; gap: 10px; }
  .group-row + .group-row { margin-top: 32px; }
  .group-label {
    writing-mode: horizontal-tb; padding: 0; justify-content: flex-start;
    letter-spacing: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-card, .topbar, .hero, .module-card { animation: none; }
  .module-card, .module-arrow, .btn-out { transition: none; }
}

/* ── 权限管理页（/admin，2026-09-15：仅完全管理员；保存走 AJAX 不刷新，表单提交兜底） ── */

.admin-shell { justify-content: flex-start; }
.admin-shell .hero { margin: 30px 0 18px; }
.admin-shell .hero h1 { font-size: 22px; }
.admin-shell .hero p { font-size: 13px; }

.admin-msg {
  width: 100%; max-width: 1080px; margin: 0 0 14px;
  font-size: 13px; color: #166534; background: rgba(27, 175, 122, 0.10);
  border: 1px solid rgba(27, 175, 122, 0.25); border-radius: 9px; padding: 10px 14px;
}
.admin-msg-warn { color: #92400e; background: rgba(234, 179, 8, 0.10); border-color: rgba(234, 179, 8, 0.35); }

/* 筛选栏：卡片化（与授权行卡片呼应），搜索框带放大镜、下拉带自绘箭头、切换即筛 */
.admin-filter {
  width: 100%; max-width: 1080px; margin-bottom: 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; box-shadow: var(--shadow);
}
.admin-search-input {
  flex: 1; min-width: 170px; font: inherit; font-size: 13.5px; color: var(--ink);
  border: 1px solid #d9dedb; border-radius: 9px; padding: 9px 13px 9px 36px; outline: none;
  background: var(--page) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%23898781' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 12px center;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.admin-search-input:focus { border-color: #b7a92f; box-shadow: 0 0 0 3px rgba(176, 148, 32, .16); }
.admin-filter-select { flex: none; display: inline-flex; align-items: center; gap: 8px; }
.admin-filter-select > span { font-size: 12px; color: var(--muted); }
.admin-search-select {
  font: inherit; font-size: 13.5px; color: var(--ink); cursor: pointer;
  border: 1px solid #d9dedb; border-radius: 9px; padding: 9px 32px 9px 13px; outline: none;
  appearance: none; -webkit-appearance: none;
  background: var(--page) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23898781' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.admin-search-select:focus { border-color: #b7a92f; box-shadow: 0 0 0 3px rgba(176, 148, 32, .16); }
.admin-search-btn {
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  background: #e9d34b; border: 1px solid #dfc435; color: #26251f; border-radius: 9px; padding: 9px 20px;
  transition: background .15s ease;
}
.admin-search-btn:hover { background: #f0dc63; }
.admin-search-clear {
  font-size: 12.5px; color: var(--ink-2); text-decoration: none; align-self: center;
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px;
  background: transparent; transition: border-color .15s ease, color .15s ease;
}
.admin-search-clear:hover { border-color: #b7a92f; color: var(--ink); }

/* ── 筛选原地更新 + 搜索候选下拉（2026-10-14）── */
.admin-list { transition: opacity .15s ease; }
.admin-list.is-patching { opacity: .45; pointer-events: none; }
.admin-list.is-faded-in { animation: admin-list-in .28s ease; }
@keyframes admin-list-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.admin-search-wrap { position: relative; flex: 1; min-width: 170px; }
.admin-search-wrap .admin-search-input { width: 100%; flex: none; min-width: 0; }
.admin-cands {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 28px rgba(20, 24, 22, 0.16); padding: 6px;
  max-height: 324px; overflow: auto;
}
.admin-cand {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.admin-cand b { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.admin-cand i { font-style: normal; font-size: 12px; color: var(--muted); white-space: nowrap; }
.admin-cand.is-active, .admin-cand:hover { background: rgba(233, 211, 75, 0.20); }
.admin-cands-empty { padding: 8px 10px; font-size: 12.5px; color: var(--muted); }

/* 保存回执 toast（AJAX，底部居中堆叠；成功墨绿、失败红） */
.admin-toasts {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 90; pointer-events: none;
}
.admin-toast {
  max-width: 86vw; padding: 10px 22px; border-radius: 999px;
  background: #1f2a22; color: #fff; font-size: 13.5px; font-weight: 550; text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .24);
  animation: admin-toast-in .18s ease; transition: opacity .35s ease;
}
.admin-toast-err { background: #8c2f2f; }
.admin-toast.is-out { opacity: 0; }
@keyframes admin-toast-in { from { opacity: 0; transform: translateY(6px); } }

.admin-list { width: 100%; max-width: 1080px; display: flex; flex-direction: column; gap: 8px; }
.admin-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 11px;
  padding: 12px 16px; box-shadow: var(--shadow);
}
.admin-who { display: flex; flex-direction: column; gap: 1px; min-width: 168px; flex: none; }
.admin-who b { font-size: 14px; color: #17211b; }
.admin-who i { font-style: normal; font-size: 11.5px; color: var(--muted); }
.admin-badge {
  flex: none; font-size: 12px; font-weight: 600; color: #1d66c0;
  background: rgba(42, 120, 214, 0.09); border: 1px solid rgba(42, 120, 214, 0.25);
  border-radius: 999px; padding: 3px 11px;
}
.admin-badge-static { color: #6b7280; background: #f3f4f6; border-color: #e5e7eb; }
.admin-mods { flex: 1; min-width: 300px; display: flex; flex-wrap: wrap; gap: 6px; }
.admin-mod {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer; user-select: none;
  font-size: 12.5px; color: var(--ink-2); background: var(--page);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 11px;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.admin-mod:hover { border-color: #b7a92f; color: var(--ink); }
.admin-mod input { margin: 0; accent-color: #b7a92f; cursor: pointer; }
.admin-mod.is-on { background: #faf6e3; border-color: #d9cd8f; color: #26251f; font-weight: 600; }
.admin-save {
  flex: none; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  color: #26251f; background: #e9d34b; border: 1px solid #dfc435; border-radius: 9px; padding: 6px 16px;
  transition: background .15s ease;
}
.admin-save:hover { background: #f0dc63; }
.admin-save:disabled { opacity: .5; cursor: default; }
.admin-empty { width: 100%; max-width: 1080px; padding: 30px 0; text-align: center; color: var(--muted); font-size: 13px; }

.admin-log { width: 100%; max-width: 1080px; margin-top: 26px; }
.admin-log h2 { font-size: 14px; color: var(--ink-2); margin: 0 0 8px; }
.admin-log p {
  margin: 0; padding: 7px 12px; font-size: 12.5px; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.admin-log p + p { margin-top: 6px; }
.admin-log .admin-log-empty { color: var(--muted); background: transparent; border-style: dashed; }
.admin-log p + p { margin-top: 4px; }

@media (max-width: 620px) {
  .admin-who { min-width: 0; flex: 1 1 100%; }
  .admin-mods { min-width: 0; }
}

/* ── 两档分权（2026-09-22）：首页「普通」角标 + 授权页档位标签/普通档药丸 ── */

.admin-tier-label {
  flex: 0 0 auto; align-self: center;
  font-size: 11px; font-weight: 700; color: var(--muted, #8a8f98);
  margin: 0 4px 0 10px; white-space: nowrap;
}
.admin-tier-label:first-child { margin-left: 0; }
.admin-mod-basic.is-on {
  border-color: rgba(124, 92, 191, 0.55);
  background: rgba(124, 92, 191, 0.10);
  color: #5b3fa0;
}

/* ── 授权页分档 tab（2026-09-23）：管理员/普通权限 两页互切 ── */
.admin-tabs {
  display: flex; gap: 8px; margin-top: 14px;
}
.admin-tab {
  padding: 6px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--muted, #8a8f98); background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(0, 0, 0, 0.08); text-decoration: none;
  transition: all .15s ease;
}
.admin-tab:hover { color: var(--ink, #26251f); }
.admin-tab.is-on {
  color: #26251f; background: #faf6e3; border-color: #d9cd8f;
}

/* ── 软导航过渡（2026-09-23）：新视图淡入+轻上移，与整页跳变的区别即「自然切换」；
   只做入场不做退出——退出动画会人为增加点击到新内容的感知延迟 ── */
}

/* 滚动条槽位固定（2026-09-23）：home(短页)↔admin(长页)切换时滚动条出现/消失
   会令视口宽度突变 17px——旧页面整体横向压缩=「先跳一下本页面再跳转」的根源。
   stable 永久预留槽位，宽度恒定，切换零横向位移。 */
html { scrollbar-gutter: stable; }

/* ── 软导航轻量方向入场（2026-09-23 重构）：放弃两层并存整页推入（每次切换
   解析+插入 91KB×2+删除，顿挫/掉帧为架构下限）——照 profile 认可的动效模式：
   单层瞬间替换 + 小幅方向位移淡入（前进从右 46px、返回从左），合成器友好、
   成本一次性付清，无动画中段收尾二次顿挫 ── */
/* 插入期屏外内容跳过布局/绘制/图片解码——91KB 长列表页（admin↔basic）掉帧主因；
   动画结束后 JS 移除该类，恢复完整渲染（渐进、无感） */
.home-shell.nav-cv { content-visibility: auto; contain-intrinsic-size: auto 100vh; }
.home-shell.nav-in-fwd { animation: nav-in-fwd .32s cubic-bezier(.2, .7, .3, 1); }
.home-shell.nav-in-back { animation: nav-in-back .32s cubic-bezier(.2, .7, .3, 1); }
@keyframes nav-in-fwd  { from { opacity: 0; transform: translateX(46px); } }
@keyframes nav-in-back { from { opacity: 0; transform: translateX(-46px); } }
@media (prefers-reduced-motion: reduce) {
  .home-shell.nav-in-fwd, .home-shell.nav-in-back { animation: none; }
}
