/* WyDash v2 — 黑白高密度主题（与 logviewer 同规范） */
:root {
  --bg: #0a0a0a;
  --bg2: #141414;
  --bg3: #1a1a1a;
  --line: #262626;
  --fg: #d4d4d4;
  --fg-dim: #737373;
  --fg-faint: #4a4a4a;
  --accent: #ffffff;
  --ok: #22c55e;
  --err: #ef4444;
  --warn: #eab308;
  --orange: #f97316;   /* ≥80% 阈值色（顶栏/折线带） */
  --blue-rx: #3b82f6;  /* NET 下行 */
  --blue-tx: #60a5fa;  /* NET 上行 */
  --ok-glow: rgba(34, 197, 94, .28);
  --err-glow: rgba(239, 68, 68, .22);
  --card-border: #262626;
  --card-shadow: 0 1px 3px rgba(0,0,0,.45), 0 1px 2px rgba(0,0,0,.35);
  --card-shadow-hover: 0 8px 20px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.3);
  --bar-track: #1e1e1e;
}
[data-theme="light"] {
  --bg: #f5f5f5;
  --bg2: #ffffff;
  --bg3: #ebebeb;
  --line: #d9d9d9;
  --fg: #1a1a1a;
  --fg-dim: #666666;
  --fg-faint: #9a9a9a;
  --accent: #111111;
  --ok: #22c55e;      /* 与夜间模式一致（用户要求统一） */
  --err: #b91c1c;
  --warn: #a16207;
  --orange: #ea580c;  /* 浅色下加深保对比 */
  --blue-rx: #2563eb;
  --blue-tx: #3b82f6;
  --ok-glow: rgba(34, 197, 94, .28);  /* 与夜间模式一致 */
  --err-glow: rgba(185, 28, 28, .18);
  --card-border: rgba(0, 0, 0, .06);
  --card-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --card-shadow-hover: 0 8px 20px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
  --bar-track: #e6e6e6;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
}
#app {
  width: 100%; padding: 0 20px 24px;
  display: flex; flex-direction: column;
  /* 锁定视口高度（非 min-height）：卡片高度依赖 grid 高度，
     若用 min-height 会形成“卡片→grid→#app→卡片”循环反撑，resize 后不收敛 */
  height: 100vh;
  overflow: hidden;
}

/* ---------- 顶栏 ---------- */
.topbar {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; user-select: none; }
.brand-text { font-size: 15px; font-weight: 700; letter-spacing: 1px; color: var(--accent); }
.global-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn); align-self: center; margin-left: 4px;
  animation: pulse 1.2s ease-in-out infinite;
}
.global-dot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-glow);
  animation: breathe 2s ease-in-out infinite;
}
.global-dot.err {
  background: var(--err);
  box-shadow: 0 0 0 3px var(--err-glow);
  animation: none;
}
@keyframes pulse { 50% { opacity: .35; } }
@keyframes breathe { 50% { opacity: .7; } }

.topbar-right { display: flex; align-items: center; gap: 10px; }
/* 顶栏系统指标（NET/CPU/MEM/DISK）：2×2 网格靠右；b 固定 4ch 宽 → 四个 3 字母
   label（NET/CPU/MEM/DISK + 空格 = 4ch）同列左缘对齐 */
.topbar-metrics {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 16px;
  row-gap: 1px;
  margin-right: 2px;
}
.tm-item {
  font-size: 11px; letter-spacing: .5px; color: var(--fg-dim);
  font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.35;
}
.tm-item b {
  display: inline-block;
  width: 4ch; /* 等宽字体下「NET/CPU 三字母 + 空格」= 4 字符，两行从同一 x 起笔 */
  font-weight: 700; color: var(--fg);
}
.tm-item.warn { color: var(--orange); }
.tm-item.warn b { color: inherit; }
.tm-item.bad { color: var(--err); }
.tm-item.bad b { color: inherit; }
/* 顶栏 NET 上下行数值：两种蓝色 */
.tm-item .net-rx { color: var(--blue-rx); font-weight: 600; }
.tm-item .net-tx { color: var(--blue-tx); font-weight: 600; }
.icon-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--line); color: var(--fg);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn:active { background: var(--bg3); }
/* v7.1：Bot 视图激活态（再次点击切回主界面） */
.icon-btn.on { border-color: var(--accent); color: var(--accent); background: var(--bg3); }
.ic-sun { display: none; }
[data-theme="light"] .ic-moon { display: none; }
[data-theme="light"] .ic-sun { display: block; }

/* ---------- 服务网格 ----------
   竖屏（高≥宽）：2×2 田字；横屏（宽>高）：4 个一排。
   四个方形间距统一 = gap。卡片尺寸由 JS 的 --card-size 决定（min(列宽,行高)）。 */
.grid {
  flex: 1;
  min-height: 0;   /* 防固定高度卡片反撑 grid → 缩小窗口时保持锁定可用高度 */
  display: grid;
  /* 竖屏 4 行 × 2 列（8 卡）：轨道 auto 尺寸，整组靠顶、水平居中 → 间距统一 = gap */
  grid-template-columns: repeat(2, auto);
  grid-template-rows: repeat(4, auto);
  gap: 14px;
  padding-top: 16px;
  justify-content: center;
  align-content: start;
}
@media (orientation: landscape) {
  .grid {
    grid-template-columns: repeat(4, auto);
    grid-template-rows: repeat(2, auto);
    justify-content: center;
    align-items: start;
  }
}
.card {
  display: flex; flex-direction: column;
  width: var(--card-size, auto);
  height: var(--card-size, auto);
  padding: 16px 18px;
  min-height: 0;
  background: var(--bg2);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  text-decoration: none; color: inherit;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
  border-color: var(--accent);
  background: var(--bg3);
}
.card.off { opacity: .55; }

.card-title {
  display: flex; align-items: center; justify-content: center;
  gap: 9px;
  padding-bottom: 12px;
}
.card-name {
  font-size: 19px; font-weight: 700; color: var(--fg);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn);
  animation: pulse 1.2s ease-in-out infinite;
}
.dot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-glow);
  animation: breathe 2s ease-in-out infinite;
}
.dot.err {
  background: var(--err);
  box-shadow: 0 0 0 3px var(--err-glow);
  animation: none;
}
.dot.warn {
  background: var(--orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, .25);
  animation: breathe 2s ease-in-out infinite;
}
.dot.bad {
  background: var(--err);
  box-shadow: 0 0 0 3px var(--err-glow);
  animation: none;
}

/* ---------- 24h 历史柱状条（柱高=数值强度，无数据=灰底整高条） ---------- */
.hist-wrap {
  flex: 1;
  display: flex; flex-direction: column; justify-content: center;
  gap: 8px;
  padding: 4px 0 10px;
}
.hist-title {
  font-size: 10px; letter-spacing: 1.5px; color: var(--fg-faint);
  text-align: center;
}
.hist-bar {
  display: flex; align-items: flex-end; gap: 2px;
  width: 60%;         /* 两侧各留 1/5 空白 */
  margin: 0 auto;
  flex: 1;            /* 高度自适应填满方形卡片（上限 300px 防超高屏过夸张） */
  min-height: 140px;
  max-height: 300px;
}
.hist-bar i {
  flex: 1; min-width: 0;
  height: 100%;       /* 默认 = 无数据灰底整高条 */
  background: var(--bar-track);
  border-radius: 2px;
  transition: height .4s ease, background .3s ease;
}
.hist-bar i.hl { background: var(--ok); }

/* ---------- 系统卡 24h 折线（v4：NET/CPU/MEM/DISK，深底绿线） ---------- */
.line-chart {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: block;
}
.line-chart path {
  fill: none;
  stroke: var(--ok);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke; /* 拉伸不变线宽 */
}
.line-chart path.ln-rx { stroke: var(--blue-rx); } /* NET 下行 */
.line-chart path.ln-tx { stroke: var(--blue-tx); } /* NET 上行 */
/* 百分比卡分段着色：<80 绿（默认）/ 80-90 橙 / ≥90 红（无背景色带，用户要求仅线变色） */
.line-chart path.ln-warn { stroke: var(--orange); }
.line-chart path.ln-bad { stroke: var(--err); }
/* 横线网格（v7.1，2026-08-16）：25/50/75 刻度，细线弱对比，随主题取 --line */
.line-chart line.ln-grid {
  stroke: var(--line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

/* ---------- meta 行（code · 运行时长 / 峰值 · 均值） ---------- */
.meta {
  display: block; text-align: center;
  font-size: 10px; letter-spacing: .3px; color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.meta.off { color: var(--err); }

/* Relay 卡异常渠道行（v8）：仅 ch_bad 非空时显示 */
.meta-bad {
  display: block; text-align: center;
  font-size: 10px; letter-spacing: .3px; color: var(--err);
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }

/* 空网格占位（后端未响应时） */
.empty {
  grid-column: 1 / -1;
  padding: 40px 0;
  text-align: center;
  color: var(--fg-dim);
}

/* ---------- 登录界面（v6：UI 登录替代 basic auth） ---------- */
.login-wrap {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 18vh;
}
.login-wrap[hidden] { display: none; }
.login-box {
  width: min(320px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 26px;
  background: var(--bg2);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
}
.login-brand {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--accent);
  text-align: center;
  padding-bottom: 6px;
}
.login-box input {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;            /* 16px 防 iOS 聚焦缩放 */
  font-family: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}
.login-box input:focus { border-color: var(--accent); }
.login-box input::placeholder { color: var(--fg-faint); }
.login-btn {
  padding: 10px 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.login-btn:disabled { opacity: .5; cursor: default; }
.login-btn:not(:disabled):hover { opacity: .88; }
.login-err {
  min-height: 16px;
  font-size: 12px;
  color: var(--err);
  text-align: center;
}

/* 键盘焦点 */
a:focus-visible, button:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

/* 尊重系统减弱动效 */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- 移动端（2026-08-09 晚：卡片同桌面方形化，其余规则由用户确认过） ---------- */
@media (max-width: 640px) {
  #app { padding: 0 12px 20px; }
  .grid { gap: 10px; padding-top: 12px; }
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn svg { width: 19px; height: 19px; }
  .card { padding: 12px; min-height: 0; }
  .hist-bar { gap: 2px; width: 100%; margin: 0; min-height: 0; max-height: none; }
  /* v7.1：手机端不显示顶栏系统信息（NET/CPU/MEM/DISK），只留品牌+按钮 */
  .topbar-metrics { display: none; }
}

/* 横屏但高度受限（手机横屏，>640px 宽不命中上面断点）：柱区下限放低防溢出 */
@media (orientation: landscape) and (max-height: 500px) {
  .hist-bar { min-height: 0; max-height: none; }
}

/* ============================================================
   Bot 日程与任务视图（v7，2026-08-14）
   黑白主题、紧凑高密度：与网格/顶栏同规范。
   ============================================================ */
/* topbar 入口按钮的状态点（叠在图标左上角） */
.btn-bot-dot {
  position: absolute;
  top: -1px; right: -1px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--fg-faint);
  border: 1px solid var(--bg);
}
.btn-bot-dot.ok { background: var(--ok); }
.btn-bot-dot.warn { background: var(--warn); }
.btn-bot-dot.err { background: var(--err); }
.icon-btn { position: relative; }

.bot-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;      /* 内容可滚动（日程+任务可能超一屏） */
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.bot-view[hidden] { display: none; }

.bot-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.bot-title { font-size: 15px; font-weight: 700; letter-spacing: 1px; color: var(--accent); }
.bot-date { font-size: 11px; color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }

.bot-sec {
  background: var(--bg2);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 14px;
  flex-shrink: 0;
}
.sec-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}
.sec-title { font-size: 13px; font-weight: 700; letter-spacing: 1px; color: var(--fg); }

.sched-status { font-size: 11px; color: var(--fg-dim); }
.sched-status.ok { color: var(--ok); }
.sched-status.pending { color: var(--warn); }

.mini-btn {
  padding: 3px 10px;
  font-size: 11px;
  font-family: inherit;
  color: var(--fg);
  background: none;
  border: 1px solid var(--line);
  cursor: pointer;
  white-space: nowrap;
}
.mini-btn:hover { border-color: var(--accent); color: var(--accent); }
.mini-btn.primary { color: var(--bg); background: var(--accent); border-color: var(--accent); font-weight: 700; }
.mini-btn.primary:hover { opacity: .88; }
.mini-btn.danger { color: var(--err); border-color: var(--line); }
.mini-btn.danger:hover { border-color: var(--err); }

/* ---------- 日程时间线 ---------- */
.sched-list { display: flex; flex-direction: column; }
.sched-item {
  padding: 7px 4px;
  border-bottom: 1px solid var(--line);
}
.sched-item:last-child { border-bottom: none; }
.sched-item.past { opacity: .5; }
.sched-item.now {
  background: var(--bg3);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}
.sched-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.sched-time {
  font-size: 11px;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.sched-time .cross { font-style: normal; font-size: 10px; color: var(--fg-faint); }
.sched-tag {
  font-size: 10px;
  color: var(--fg-faint);
  border: 1px solid var(--line);
  padding: 0 4px;
  white-space: nowrap;
}
.sched-title { font-size: 13px; font-weight: 600; color: var(--fg); }
.sched-mood { font-size: 11px; color: var(--fg-dim); white-space: nowrap; margin-left: auto; }
.sched-emo {
  display: flex;
  gap: 14px;
  margin-top: 5px;
  align-items: center;
}
.emo-item { display: inline-flex; align-items: center; gap: 5px; }
.emo-label { font-style: normal; font-size: 10px; color: var(--fg-faint); }
.emo-track {
  display: inline-block;
  width: 64px; height: 4px;
  background: var(--bar-track);
  border-radius: 2px;
  overflow: hidden;
  font-style: normal;
}
.emo-fill { display: block; height: 100%; background: var(--fg-dim); }
.emo-val { font-style: normal; font-size: 10px; color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.sched-notes {
  font-size: 11px;
  color: var(--fg-dim);
  margin-top: 4px;
  line-height: 1.5;
}

/* ---------- Bot 实时状态（v7.2，2026-08-17） ---------- */
.mood-now { padding: 2px 0; }
.mood-updated { font-size: 10px; color: var(--fg-faint); margin-top: 4px; font-variant-numeric: tabular-nums; }
.mood-chart { margin-top: 8px; }
.mood-chart-svg { height: 72px; }
.mood-empty {
  padding: 16px 0;
  font-size: 11px;
  color: var(--fg-dim);
}
/* 三维三线（黑白灰阶）：能量=实线 / 愉悦=虚线 / 社交=点线 */
.mood-chart-svg path.ln-en { stroke: var(--fg); }
.mood-chart-svg path.ln-va { stroke: var(--fg-dim); stroke-dasharray: 4 3; }
.mood-chart-svg path.ln-so { stroke: var(--fg-faint); stroke-dasharray: 1.5 3; }
.mood-chart-svg circle.ln-en { fill: var(--fg); stroke: none; }
.mood-chart-svg circle.ln-va { fill: var(--fg-dim); stroke: none; }
.mood-chart-svg circle.ln-so { fill: var(--fg-faint); stroke: none; }
.mood-legend {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 4px;
  font-size: 10px;
  color: var(--fg-dim);
}
.mood-lg { display: inline-flex; align-items: center; gap: 4px; }
.mood-lg-line { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--fg); font-style: normal; }
.mood-lg-line.ln-en { border-top-color: var(--fg); }
.mood-lg-line.ln-va { border-top-color: var(--fg-dim); border-top-style: dashed; }
.mood-lg-line.ln-so { border-top-color: var(--fg-faint); border-top-style: dotted; }
.mood-x { margin-left: auto; color: var(--fg-faint); }

/* ---------- 任务列表 ---------- */
.filters { display: flex; gap: 2px; }
.filter-btn {
  padding: 2px 8px;
  font-size: 11px;
  font-family: inherit;
  color: var(--fg-dim);
  background: none;
  border: 1px solid var(--line);
  border-right: none;
  cursor: pointer;
}
.filter-btn:last-child { border-right: 1px solid var(--line); }
.filter-btn:hover { color: var(--fg); }
.filter-btn.on { background: var(--accent); color: var(--bg); font-weight: 700; }

.task-list { display: flex; flex-direction: column; }
.task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--line);
}
.task-item:last-child { border-bottom: none; }
/* 任务状态点：待触发=灰 / 进行中=主题色呼吸 / 完成=实心 / 失败=叉 / 取消=空心 */
.t-status {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--fg-faint);
  flex-shrink: 0;
}
.t-status.running { background: var(--accent); animation: breathe 2s ease-in-out infinite; }
.t-status.done { background: var(--ok); border-radius: 2px; }
.t-status.failed { background: var(--err); border-radius: 0; }
.t-status.cancelled { background: none; border: 1px solid var(--fg-dim); }
.t-time {
  font-size: 11px;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 132px;
  flex-shrink: 0;
}
.t-title { font-size: 12px; color: var(--fg); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-prio { font-size: 10px; color: var(--fg-faint); border: 1px solid var(--line); padding: 0 4px; white-space: nowrap; }
.t-prio.high { color: var(--err); border-color: var(--err); }
.t-prio.low { color: var(--fg-dim); }
.t-state { font-size: 10px; color: var(--fg-faint); white-space: nowrap; }
.t-extra {
  font-size: 11px;
  color: var(--fg-dim);
  padding: 2px 4px 8px 21px;
  line-height: 1.5;
}

/* ---------- 新建任务表单 ---------- */
.task-form-wrap {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
  z-index: 30;
}
.task-form-wrap[hidden] { display: none; }
.task-form {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--bg2);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--card-shadow-hover);
}
.tf-title { font-size: 13px; font-weight: 700; letter-spacing: 1px; color: var(--accent); }
.task-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--fg-dim);
}
.task-form input, .task-form textarea, .task-form select {
  padding: 7px 9px;
  font-size: 14px;
  font-family: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}
.task-form input:focus, .task-form textarea:focus, .task-form select:focus { border-color: var(--accent); }
.task-form textarea { resize: vertical; min-height: 44px; }
.tf-row { display: flex; gap: 10px; }
.tf-row label { flex: 1; }
.tf-err { min-height: 15px; font-size: 11px; color: var(--err); }
.tf-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Bot 视图移动端 ---------- */
@media (max-width: 640px) {
  .bot-view { padding-top: 12px; }
  .bot-sec { padding: 10px 10px; }
  .t-time { width: 108px; }
  .emo-track { width: 44px; }
  .sched-mood { margin-left: 0; }
  .task-form-wrap { padding-top: 8vh; }
}
