/* Zephyrian 门户 — GitHub 设计语言,与 nempoi / robovan 视觉一致 */

:root {
  --gh-bg-canvas: #f6f8fa;
  --gh-bg: #ffffff;
  --gh-fg: #1f2328;
  --gh-fg-muted: #656d76;
  --gh-fg-subtle: #9ba1a8;
  --gh-border: #d0d7de;
  --gh-border-muted: #d8dee4;
  --gh-accent: #0969da;
  --gh-success: #1f883d;
  --gh-danger: #cf222e;
  --gh-radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.5;
  background: var(--gh-bg-canvas); color: var(--gh-fg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh; min-height: 100dvh;
}

.page {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
}

/* ── 登录页 ────────────────────────────────── */
#login-view {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--gh-bg);
  border: 1px solid var(--gh-border);
  border-radius: var(--gh-radius);
  box-shadow: 0 1px 0 rgba(31,35,40,.04);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px 24px;
}

.brand { text-align: center; margin-bottom: 22px; }
.brand-logo {
  width: 64px; height: 64px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: #ddf4ff;
  color: var(--gh-accent);
  display: flex; align-items: center; justify-content: center;
}
.brand h1 {
  margin: 0 0 4px;
  font-size: 24px; font-weight: 600;
  letter-spacing: -0.3px;
}
.brand-sub {
  margin: 0;
  font-size: 13px;
  color: var(--gh-fg-muted);
}

#login-form label {
  display: block;
  margin-bottom: 14px;
}
.label {
  display: block;
  font-size: 13px;
  color: var(--gh-fg-muted);
  margin-bottom: 6px;
  font-weight: 500;
}
#login-form input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--gh-border);
  border-radius: var(--gh-radius);
  font-size: 14px;
  color: var(--gh-fg);
  background: var(--gh-bg);
  transition: border-color .15s, box-shadow .15s;
}
#login-form input:focus {
  outline: none;
  border-color: var(--gh-accent);
  box-shadow: 0 0 0 3px rgba(9,105,218,.2);
}

.btn {
  display: block;
  width: 100%;
  height: 40px;
  border: 1px solid var(--gh-border);
  border-radius: var(--gh-radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  background: var(--gh-bg);
  color: var(--gh-fg);
}
.btn:hover { background: #f3f4f6; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary {
  background: var(--gh-success);
  border-color: rgba(31,136,61,.4);
  color: #ffffff;
}
.btn-primary:hover { background: #1a7f37; }

.err {
  margin-top: 12px;
  padding: 8px 10px;
  background: #ffebe9;
  border: 1px solid rgba(207,34,46,.4);
  border-radius: var(--gh-radius);
  color: var(--gh-danger);
  font-size: 12px;
  text-align: center;
}

.divider {
  margin: 16px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--gh-border-muted);
}
.divider span {
  font-size: 12px;
  color: var(--gh-fg-subtle);
}

.btn-feishu {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--gh-fg);
  background: var(--gh-bg);
}
.btn-feishu svg { color: var(--gh-fg-muted); }
.btn-feishu:hover { background: #f3f4f6; border-color: var(--gh-accent); }
.btn-feishu:hover svg { color: var(--gh-accent); }

.hint {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--gh-border-muted);
  text-align: center;
  font-size: 12px;
  color: var(--gh-fg-muted);
}
.hint a { color: var(--gh-accent); text-decoration: none; }
.hint a:hover { text-decoration: underline; }

/* ── 应用选择页 ──────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--gh-bg);
  border-bottom: 1px solid var(--gh-border);
}
.topbar-brand {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--gh-fg-muted);
}
.role-tag {
  padding: 2px 8px;
  border-radius: 12px;
  background: #ddf4ff;
  color: var(--gh-accent);
  font-size: 11px;
  font-weight: 600;
}
.link-btn {
  border: none;
  background: transparent;
  color: var(--gh-accent);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background .15s;
}
.link-btn:hover { background: #ddf4ff; }

.apps-main {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 24px 24px;
  flex: 1;
}

/* 双栏:统一卡片尺寸后左右等宽,左主区 / 右副区视觉权重靠分组标题区分 */
.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}
.side-col {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.section-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
  color: var(--gh-fg);
}
.section-sub {
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--gh-fg-muted);
}

/* 所有 grid(app / tool)用同一节奏,卡片自身尺寸由 .app-tile 决定 */
.apps-grid,
.tools-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tools-section { /* 容器,样式空,定位由 .side-col gap 决定 */ }

/* 工具卡:复用 .app-tile 主体尺寸,只是右侧把 arrow 替换成「安装 / 详情」双 CTA。
   .tool-card 自己只负责"非整体可点"的语义(div 而非 a),padding/图标/字号继承 .app-tile */
.tool-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.tool-card-btn {
  display: inline-block;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--gh-border);
  border-radius: 4px;
  color: var(--gh-fg);
  background: var(--gh-bg);
  transition: all .12s;
  white-space: nowrap;
}
.tool-card-btn:hover { background: #f3f4f6; border-color: var(--gh-accent); color: var(--gh-accent); }
.tool-card-btn-primary {
  background: var(--gh-success);
  border-color: rgba(31,136,61,.4);
  color: #fff;
}
.tool-card-btn-primary:hover { background: #1a7f37; color: #fff; border-color: rgba(31,136,61,.6); }

/* deprecated 工具卡片:整体灰度减弱,旁边一个橙色徽章提示。功能保留(老用户脚本仍能正常工作),
   推动新装的用户改装替代品。徽章与主标题同行 */
.tool-card-deprecated {
  opacity: 0.7;
}
.tool-card-deprecated .app-tile-icon {
  background: #f3f4f6;
  color: var(--gh-fg-muted);
}
.tool-card-badge-prereq {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(31, 111, 235, 0.12);
  color: #0969da;
  border: 1px solid rgba(31, 111, 235, 0.3);
  vertical-align: 1px;
}
.tool-card-badge-deprecated {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(210, 153, 34, 0.15);
  color: #8a6d00;
  border: 1px solid rgba(210, 153, 34, 0.3);
  font-size: 11px;
  font-weight: 500;
  vertical-align: 1px;
}

/* 超管入口:topbar 右侧文本链接,仅 superadmin / root_owner 可见 */
.topbar-admin-link {
  font-weight: 600;
}
.topbar-admin-link:hover {
  background: #ddf4ff;
}

.app-tile {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--gh-bg);
  border: 1px solid var(--gh-border);
  border-radius: var(--gh-radius);
  text-decoration: none;
  color: var(--gh-fg);
  transition: all .15s;
  box-shadow: 0 1px 0 rgba(31,35,40,.04);
}
.app-tile:hover {
  border-color: var(--gh-accent);
  background: #f6f8fa;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(31,35,40,.08);
}
.app-tile-icon {
  flex-shrink: 0;
  width: 56px; height: 56px;
  border-radius: var(--gh-radius);
  background: #ddf4ff;
  color: var(--gh-accent);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.app-tile:hover .app-tile-icon {
  background: var(--gh-accent);
  color: #ffffff;
}
.app-tile-body { flex: 1; min-width: 0; }
.app-tile-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}
.app-tile-desc {
  font-size: 13px;
  color: var(--gh-fg-muted);
  line-height: 1.4;
}
.app-tile-arrow {
  font-size: 22px;
  color: var(--gh-fg-muted);
  font-weight: 300;
  transition: transform .15s, color .15s;
}
.app-tile:hover .app-tile-arrow {
  color: var(--gh-accent);
  transform: translateX(4px);
}

/* 版本徽章:tile 标题旁边的小灰色版本号 */
.app-tile-version {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 10px;
  background: #f6f8fa;
  border: 1px solid var(--gh-border-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--gh-fg-muted);
  vertical-align: 1px;
  white-space: nowrap;
}

/* hover 出 tooltip 显示最近 3 次更新 */
.app-tile { position: relative; }
.app-tile-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 50;
  background: #1f2328;
  color: #f0f3f6;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 8px 24px rgba(31,35,40,.25);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.app-tile.has-tooltip:hover .app-tile-tooltip {
  opacity: 1;
  transform: translateY(0);
}
.app-tile-tooltip::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 24px;
  width: 10px; height: 10px;
  background: #1f2328;
  transform: rotate(45deg);
}
.tooltip-version {
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,.12);
  color: #ffffff;
}
.tooltip-version:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.tooltip-date {
  margin-left: 6px;
  color: #9ba1a8;
  font-weight: 400;
  font-size: 11px;
}
.tooltip-note {
  margin-top: 4px;
  padding-left: 10px;
  position: relative;
  color: #d6dadf;
}
.tooltip-note::before {
  content: "·";
  position: absolute;
  left: 2px;
  color: #6e7781;
}
.tooltip-empty { color: #9ba1a8; padding-left: 0; }
.tooltip-empty::before { content: ""; }

/* 工具卡是 div 不是 a,但视觉跟 .app-tile 完全一致;hover 时不变背景(里面有按钮自己 hover) */
.tool-card.app-tile { cursor: default; }
.tool-card.app-tile:hover {
  border-color: var(--gh-border);
  background: var(--gh-bg);
  transform: none;
  box-shadow: 0 1px 0 rgba(31,35,40,.04);
}
.tool-card.app-tile:hover .app-tile-icon {
  background: #ddf4ff;
  color: var(--gh-accent);
}

.empty {
  padding: 32px 20px;
  text-align: center;
  background: #fff8e1;
  border: 1px solid #f0b429;
  border-radius: var(--gh-radius);
  color: #5a4200;
  font-size: 13px;
}

/* 跳 return URL 拦下「权限不足」时显示的横幅(tryRedirectToReturn 触发) */
.access-denied-banner {
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #fff8e1;
  border: 1px solid #f0b429;
  border-radius: var(--gh-radius);
  color: #5a4200;
  font-size: 13px;
}

/* 飞书首登 pending 待审批专门面板(替代笼统的"无应用") */
.pending-card {
  background: linear-gradient(180deg, #fffbeb 0%, #fff8e1 100%);
  border: 1px solid #f0b429;
  border-radius: 10px;
  padding: 32px 28px;
  text-align: center;
  max-width: 520px;
  margin: 12px auto 0;
}
.pending-card-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 12px;
}
.pending-card-title {
  font-size: 17px;
  font-weight: 600;
  color: #5a4200;
  margin: 0 0 18px;
}
.pending-card-meta {
  background: rgba(255, 255, 255, .5);
  border: 1px solid rgba(240, 180, 41, .35);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 0 auto 16px;
  text-align: left;
  display: inline-block;
  min-width: 280px;
}
.pending-card-meta > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
  color: #5a4200;
  gap: 16px;
}
.pending-card-meta > div + div { border-top: 1px dashed rgba(240, 180, 41, .3); }
.pending-card-label { color: #8a6d00; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.pending-card-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  background: #fff;
  border: 1px solid rgba(240, 180, 41, .3);
  padding: 1px 6px;
  border-radius: 3px;
  color: #5a4200;
}
.pending-card-tip {
  font-size: 12px;
  color: #8a6d00;
  line-height: 1.7;
  margin: 0;
}
.pending-card-tip strong { color: #5a4200; }

/* ── 底部 ──────────────────────────────── */
.foot {
  padding: 16px 0;
  text-align: center;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.foot a {
  color: var(--gh-fg-subtle);
  text-decoration: none;
}
.foot a:hover { color: var(--gh-fg-muted); }

/* ── 双栏断点:窄屏崩单栏 ──────────── */
@media (max-width: 880px) {
  .main-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
}

/* ── 移动端 ────────────────────────────── */
@media (max-width: 600px) {
  .login-card { padding: 24px 20px 18px; }
  .brand h1 { font-size: 22px; }
  .topbar { padding: 10px 16px; }
  .topbar-user { gap: 8px; font-size: 12px; }
  .role-tag { font-size: 10px; padding: 2px 6px; }
  .apps-main { padding: 32px 16px 16px; }
  .section-title { font-size: 16px; margin-bottom: 14px; }
  .app-tile { padding: 14px 16px; gap: 12px; }
  .app-tile-icon { width: 44px; height: 44px; }
  .app-tile-icon svg { width: 28px; height: 28px; }
  .app-tile-name { font-size: 15px; }
  .app-tile-desc { font-size: 12px; }
}
