/* ============================================================
   应用工作台 · 统一入口门户
   视觉令牌全部来自 /shared/theme.css（全站唯一视觉源）
   本文件只保留门户专属布局与组件，不得再写死色值
   ============================================================ */

/* 令牌别名：把门户历史变量名映射到共享设计系统，双主题自动跟随 */
:root {
  --muted: var(--text-2);
  --faint: var(--text-3);
  --online: var(--ok);
  --offline: var(--danger);
  --radius-card: var(--r-lg);
  --shadow-card: var(--sh-inset), var(--sh-md);

  /* 应用主色：卡片图标块与悬浮辉光 */
  --c-amber: #f6b545;  --c-amber-soft: rgba(246, 181, 69, .12);   --c-amber-line: rgba(246, 181, 69, .30);
  --c-teal: #34d8ad;   --c-teal-soft: rgba(52, 216, 173, .12);    --c-teal-line: rgba(52, 216, 173, .30);
  --c-azure: #6fa8ff;  --c-azure-soft: rgba(111, 168, 255, .12);  --c-azure-line: rgba(111, 168, 255, .30);
  --c-violet: #b18cff; --c-violet-soft: rgba(177, 140, 255, .12); --c-violet-line: rgba(177, 140, 255, .30);
}

/* 亮色下应用主色需加深，保证白底对比度 */
[data-theme="light"] {
  --c-amber: #b45309;  --c-amber-soft: rgba(180, 83, 9, .10);    --c-amber-line: rgba(180, 83, 9, .32);
  --c-teal: #0e9f6e;   --c-teal-soft: rgba(14, 159, 110, .10);   --c-teal-line: rgba(14, 159, 110, .32);
  --c-azure: #2563eb;  --c-azure-soft: rgba(37, 99, 235, .10);   --c-azure-line: rgba(37, 99, 235, .32);
  --c-violet: #7c3aed; --c-violet-soft: rgba(124, 58, 237, .10); --c-violet-line: rgba(124, 58, 237, .32);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

/* 背景光晕与文字色由共享设计系统提供，这里只补充门户的纵向布局 */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.mono, .clock, .sysline-item b { font-family: var(--font-mono); }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px clamp(20px, 5vw, 56px) 14px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  color: var(--c-azure);
  background: var(--c-azure-soft);
  border: 1px solid var(--c-azure-line);
  box-shadow: 0 0 24px -6px var(--c-azure-line);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-text h1 { font-size: 20px; font-weight: 700; letter-spacing: 0.02em; line-height: 1.3; }
.brand-sub {
  font-family: var(--font-mono);
  font-size: 10.5px; letter-spacing: 0.32em;
  color: var(--faint);
}
.topbar-right { display: flex; align-items: center; gap: 12px; flex: none; }

.status-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px; color: var(--muted);
  white-space: nowrap;
}
.pill-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--faint);
  transition: background 0.4s;
}
.status-pill.all-on .pill-dot { background: var(--online); box-shadow: 0 0 8px var(--online); }
.status-pill.part-on .pill-dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.status-pill.all-off .pill-dot { background: var(--offline); box-shadow: 0 0 8px var(--offline); }

.clock {
  font-size: 13px; color: var(--muted);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 6px 12px; border-radius: 8px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 系统信息线 ---------- */
.sysline {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 0 clamp(20px, 5vw, 56px) 26px;
  font-size: 11.5px; color: var(--faint);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}
.sysline-item b { color: var(--muted); font-weight: 600; }
.sysline-sep { color: var(--border-strong); }

/* ---------- 应用卡片网格 ---------- */
.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 18px;
  padding: 0 clamp(20px, 5vw, 56px) 40px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  text-decoration: none;
  color: inherit;
  transition: transform 0.22s ease, border-color 0.22s ease, background 0.22s ease, box-shadow 0.22s ease;
  animation: card-in 0.5s ease backwards;
}
.card:hover, .card:focus-visible {
  transform: translateY(-3px);
  background: var(--surface-hover);
  outline: none;
}
/* 各应用专属色 */
.card.c-amber:hover, .card.c-amber:focus-visible { border-color: var(--c-amber-line); box-shadow: 0 14px 36px -10px var(--c-amber-soft), var(--shadow-card); }
.card.c-teal:hover,  .card.c-teal:focus-visible  { border-color: var(--c-teal-line);  box-shadow: 0 14px 36px -10px var(--c-teal-soft),  var(--shadow-card); }
.card.c-azure:hover, .card.c-azure:focus-visible { border-color: var(--c-azure-line); box-shadow: 0 14px 36px -10px var(--c-azure-soft), var(--shadow-card); }
.card.c-violet:hover, .card.c-violet:focus-visible { border-color: var(--c-violet-line); box-shadow: 0 14px 36px -10px var(--c-violet-soft), var(--shadow-card); }

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .card { animation: none; transition: none; }
}

.card-head { display: flex; align-items: flex-start; gap: 14px; }
.icon-tile {
  position: relative;
  width: 48px; height: 48px; flex: none;
  display: grid; place-items: center;
  border-radius: 13px;
  transition: transform 0.22s ease;
}
.card:hover .icon-tile { transform: scale(1.06); }
.c-amber .icon-tile { color: var(--c-amber); background: var(--c-amber-soft); border: 1px solid var(--c-amber-line); }
.c-teal  .icon-tile { color: var(--c-teal);  background: var(--c-teal-soft);  border: 1px solid var(--c-teal-line); }
.c-azure .icon-tile { color: var(--c-azure); background: var(--c-azure-soft); border: 1px solid var(--c-azure-line); }
.c-violet .icon-tile { color: var(--c-violet); background: var(--c-violet-soft); border: 1px solid var(--c-violet-line); }
.icon-tile svg { width: 24px; height: 24px; }

.card-name { font-size: 17px; font-weight: 700; letter-spacing: 0.01em; margin-top: 2px; }
.card-desc { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* 状态点：悬浮在图标右上角 */
.state-dot {
  position: absolute; top: -4px; right: -4px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--faint);
  border: 2px solid var(--bg);
  transition: background 0.4s;
}
.state-dot.on { background: var(--online); animation: pulse 2.2s ease-out infinite; }
.state-dot.off { background: var(--offline); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(61, 220, 151, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0); }
}
@media (prefers-reduced-motion: reduce) { .state-dot.on { animation: none; } }

/* 元信息 chips */
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  letter-spacing: 0.03em;
}

.card-foot {
  margin-top: auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.app-status { font-family: var(--font-mono); font-size: 11.5px; color: var(--faint); letter-spacing: 0.05em; display: flex; align-items: center; gap: 7px; }
.app-status .st-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.app-status.st-on { color: var(--online); }
.app-status.st-on .st-dot { background: var(--online); }
.app-status.st-off { color: var(--offline); }
.app-status.st-off .st-dot { background: var(--offline); }
.app-status.st-wait { color: var(--muted); }

.enter-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600;
  color: var(--text);
  padding: 8px 16px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  transition: all 0.22s ease;
  white-space: nowrap;
}
.enter-btn .arrow { transition: transform 0.22s ease; font-family: var(--font-mono); }
.c-amber .enter-btn:hover { border-color: var(--c-amber-line); color: var(--c-amber); background: var(--c-amber-soft); }
.c-teal  .enter-btn:hover { border-color: var(--c-teal-line);  color: var(--c-teal);  background: var(--c-teal-soft); }
.c-azure .enter-btn:hover { border-color: var(--c-azure-line); color: var(--c-azure); background: var(--c-azure-soft); }
.c-violet .enter-btn:hover { border-color: var(--c-violet-line); color: var(--c-violet); background: var(--c-violet-soft); }
.card:hover .enter-btn .arrow { transform: translateX(3px); }

/* ---------- 加载骨架 ---------- */
.card-skeleton { pointer-events: none; }
.sk { border-radius: 7px; background: var(--surface-hover); position: relative; overflow: hidden; }
.sk::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--surface-hover), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.card-skeleton .icon-tile { background: var(--surface-hover); border: 1px solid var(--border); }
.sk-name { width: 130px; height: 16px; }
.sk-desc { width: 92%; height: 12px; margin-top: 9px; }
.sk-meta { width: 180px; height: 22px; }
.sk-status { width: 110px; height: 14px; }
.sk-btn { width: 92px; height: 36px; border-radius: 9px; }
.sk-lines { flex: 1; padding-top: 4px; }

/* ---------- 加载失败 ---------- */
.hidden { display: none !important; }
.load-error { flex: 1; display: grid; place-items: center; padding: 40px clamp(20px, 5vw, 56px); }
.load-error-box {
  max-width: 460px; text-align: center;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 36px 30px;
}
.load-error-box .mono { color: var(--offline); font-size: 13px; letter-spacing: 0.14em; margin-bottom: 10px; }
.load-error-box p:not(.mono) { color: var(--muted); font-size: 13px; }
.retry-btn {
  margin-top: 18px;
  font-family: var(--font-sans); font-size: 13px; font-weight: 600;
  color: var(--text); background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  padding: 9px 22px; border-radius: 9px; cursor: pointer;
  transition: background 0.2s;
}
.retry-btn:hover { background: var(--accent-line); }

/* ---------- 页脚 ---------- */
.footer {
  padding: 18px clamp(20px, 5vw, 56px) 26px;
  text-align: center;
  font-size: 11px; color: var(--faint);
  letter-spacing: 0.06em;
}

/* ============================================================
   通用组件：顶栏用户区 / 弹层 / 按钮 / toast
   ============================================================ */

/* ---------- 顶栏用户区 ---------- */
.user-area { display: flex; align-items: center; gap: 8px; }
.btn-login-top {
  font-family: var(--font-sans); font-size: 13px; font-weight: 600;
  color: var(--text);
  padding: 7px 18px; border-radius: 9px;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  cursor: pointer; white-space: nowrap;
  transition: background 0.2s;
}
.btn-login-top:hover { background: var(--accent-line); }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px; color: var(--text);
  max-width: 180px;
}
.user-chip .u-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .u-role { color: var(--azure); font-family: var(--font-mono); font-size: 10.5px; }
.btn-topbar {
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 500;
  color: var(--muted);
  padding: 7px 13px; border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer; white-space: nowrap;
  transition: all 0.2s;
}
.btn-topbar:hover { color: var(--text); border-color: var(--border-strong); }
.btn-topbar.accent { color: var(--c-azure); border-color: var(--c-azure-line); }
.btn-topbar.accent:hover { background: var(--c-azure-soft); }

/* ---------- 弹层通用 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 900;
  display: flex; align-items: center; justify-content: center;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
  animation: fade-in 0.18s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  box-shadow: var(--sh-lg);
  max-height: 88vh;
  display: flex; flex-direction: column;
  animation: modal-in 0.22s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.985); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .modal-mask, .modal-card { animation: none; }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 12px;
}
.modal-head h3 { font-size: 16px; font-weight: 700; letter-spacing: 0.02em; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--faint); font-size: 22px; line-height: 1;
  padding: 4px 8px; border-radius: 8px;
  transition: all 0.15s;
}
.modal-close:hover { color: var(--text); background: var(--surface-hover); }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px 20px;
}

/* ---------- 登录弹层 ---------- */
.login-modal-card { width: 400px; max-width: 94vw; padding-bottom: 22px; }

/* 2026-10-10 晚：原「登录品牌区」（卡片顶部渐变 + 粒子画布）已按用户要求移除 ——
   粒子改为整页背景（见 /shared/theme-motion.js 的 mountBg()），登录卡片回归干净样式。 */
.login-tip { padding: 0 22px 14px; font-size: 12px; color: var(--muted); }
.login-fields { padding: 0 22px; }
.login-fields label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 6px; }
.login-fields input {
  width: 100%; box-sizing: border-box;
  padding: 10px 13px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text); font-size: 14px;
  outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.login-fields input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-results { padding: 14px 22px 4px; display: flex; flex-direction: column; gap: 6px; }
.login-row {
  display: flex; align-items: center; gap: 9px;
  font-size: 12.5px; color: var(--muted);
  padding: 7px 11px; border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.login-row .lr-icon { font-family: var(--font-mono); width: 14px; text-align: center; flex: none; }
.login-row.ok { color: var(--ok); }
.login-row.ok .lr-icon { color: var(--online); }
.login-row.fail { color: var(--danger); }
.login-row.fail .lr-icon { color: var(--offline); }
.login-row.skip { color: var(--faint); }
.login-row .lr-msg { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#btn-do-login { margin: 16px 22px 0; }
#btn-do-pwd, #btn-fg-request, #btn-fg-reset { margin: 16px 22px 0; }
.login-foot-link { text-align: center; margin: 8px 0 2px; }
.link-btn {
  background: none; border: none; padding: 6px 8px; cursor: pointer;
  color: var(--azure); font-family: var(--font-sans); font-size: 12.5px;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- 通用按钮 ---------- */
.btn-primary {
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 600;
  color: var(--accent-contrast);
  padding: 10px 20px; border-radius: 9px;
  border: 1px solid var(--accent);
  background: var(--accent);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary.sm { padding: 7px 14px; font-size: 12.5px; }
.btn-ghost {
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 500;
  color: var(--muted);
  padding: 10px 18px; border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer; transition: all 0.2s;
  white-space: nowrap;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-hover); }
.btn-ghost.sm { padding: 7px 13px; font-size: 12.5px; }
.btn-danger {
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 500;
  color: var(--danger);
  padding: 7px 13px; border-radius: 8px;
  border: 1px solid var(--danger);
  background: var(--danger-soft);
  cursor: pointer; transition: all 0.2s;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

/* ---------- toast ---------- */
.toast {
  position: fixed; top: 18px; left: 50%; transform: translate(-50%, -140%);
  z-index: 999;
  max-width: 86vw;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 13px; font-weight: 500;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  box-shadow: var(--sh-lg);
  color: var(--text);
  transition: transform 0.28s ease;
  word-break: break-all;
}
.toast.show { transform: translate(-50%, 0); }
.toast.ok { border-color: var(--ok); color: var(--ok); }
.toast.err { border-color: var(--danger); color: var(--danger); }

/* ---------- 移动端 ---------- */
@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .topbar-right { justify-content: space-between; flex-wrap: wrap; }
  .clock { flex: 1; text-align: center; }
  .grid { grid-template-columns: 1fr; }
  .sysline { display: none; }
  .user-chip { max-width: 130px; }
}
