/* ============================================================================
   页面级布局 —— 依赖 toolpage.css 的令牌与组件，不重复定义任何颜色字面量
   ========================================================================= */

/* ---------------------------------------------------------------- 通用壳 */
.tp-shell { display: flex; gap: var(--sp-6); align-items: flex-start; padding: var(--sp-6) 0 var(--sp-16); }

.tp-sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  position: sticky; top: calc(60px + var(--sp-6));
  max-height: calc(100vh - 60px - var(--sp-10));
  overflow-y: auto; overscroll-behavior: contain;
}
.tp-main { flex: 1 1 auto; min-width: 0; }

.tp-sidebar__group { margin-bottom: var(--sp-6); }
.tp-sidebar__heading {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 0 var(--sp-3) var(--sp-2);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-subtle);
}
.tp-sidebar__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.tp-sidebar__link {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  font-size: var(--fs-sm); color: var(--fg-muted);
  border-left: 2px solid transparent;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.tp-sidebar__link:hover { background: var(--bg-hover); color: var(--fg-default); }
.tp-sidebar__link.is-active {
  background: var(--accent-soft); color: var(--accent);
  border-left-color: var(--accent); font-weight: var(--fw-medium);
}
.tp-sidebar__link i { width: 16px; text-align: center; font-size: var(--fs-xs); opacity: 0.8; }
.tp-sidebar__link .tp-badge { margin-left: auto; }

/* ---------------------------------------------------------------- 首页 */
.tp-hero {
  padding: var(--sp-8) var(--sp-6);
  margin-bottom: var(--sp-6);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xs);
  position: relative; overflow: hidden;
}
/* 顶部渐隐强调线，替代原版的整块高饱和色头图 */
.tp-hero::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent 70%);
}
.tp-hero__title { font-size: var(--fs-3xl); margin-bottom: var(--sp-2); }
.tp-hero__quote {
  display: flex; align-items: center; gap: var(--sp-2);
  min-height: 24px; font-size: var(--fs-sm); color: var(--fg-muted);
  font-style: italic;
}
.tp-hero__meta { display: flex; flex-wrap: wrap; gap: var(--sp-4); margin-top: var(--sp-5); }
.tp-hero__stat { display: flex; flex-direction: column; gap: 2px; }
.tp-hero__stat b {
  font-size: var(--fs-xl); font-weight: var(--fw-bold);
  font-variant-numeric: var(--fv-num); line-height: 1;
}
.tp-hero__stat span { font-size: var(--fs-xs); color: var(--fg-subtle); }

.tp-toolbar {
  position: sticky; top: 60px; z-index: calc(var(--z-sticky) - 1);
  display: flex; flex-direction: column; gap: var(--sp-3);
  padding: var(--sp-4) 0;
  background: var(--bg-canvas);
}
.tp-toolbar__row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.tp-toolbar .tp-search { flex: 1 1 320px; min-width: 0; }

.tp-section { margin-bottom: var(--sp-8); scroll-margin-top: 130px; }
.tp-section__head {
  display: flex; align-items: baseline; gap: var(--sp-3);
  padding-bottom: var(--sp-3); margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.tp-section__title { font-size: var(--fs-lg); }
.tp-subsection { margin-bottom: var(--sp-6); }
.tp-subsection__title {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-3);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--fg-muted);
}
.tp-subsection__title::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

/* 工具卡片 */
.tp-tool {
  position: relative; display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4); min-height: 76px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); color: var(--fg-default);
  transition: border-color var(--dur-base) var(--ease-standard),
              box-shadow var(--dur-base) var(--ease-standard),
              transform var(--dur-base) var(--ease-standard),
              background var(--dur-base);
}
.tp-tool:hover {
  border-color: var(--accent); color: var(--fg-default);
  box-shadow: var(--shadow-md); transform: translateY(-2px);
}
.tp-tool:active { transform: translateY(0); }
.tp-tool__icon {
  display: grid; place-items: center; flex-shrink: 0;
  width: 34px; height: 34px; border-radius: var(--r-md);
  background: var(--accent-soft); color: var(--accent); font-size: var(--fs-base);
  transition: background var(--dur-base), color var(--dur-base), transform var(--dur-base) var(--ease-spring);
}
.tp-tool:hover .tp-tool__icon { background: var(--accent); color: var(--fg-onAccent); transform: scale(1.06); }
.tp-tool__text { min-width: 0; flex: 1; }
.tp-tool__title {
  font-size: var(--fs-sm); font-weight: var(--fw-medium); line-height: var(--lh-snug);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.tp-tool__sub {
  margin-top: 3px; font-size: var(--fs-xs); color: var(--fg-subtle);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tp-tool__flag {
  position: absolute; top: var(--sp-2); right: var(--sp-2);
  font-size: 10px; color: var(--fg-subtle); opacity: 0; transition: opacity var(--dur-fast);
}
.tp-tool:hover .tp-tool__flag { opacity: 1; }

/* 收藏按钮 */
.tp-fav {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; display: grid; place-items: center;
  border: 0; border-radius: var(--r-sm); background: transparent;
  color: var(--fg-subtle); font-size: 11px; cursor: pointer;
  opacity: 0; transition: opacity var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
}
.tp-tool:hover .tp-fav, .tp-fav.is-on { opacity: 1; }
.tp-fav:hover { color: var(--warning); transform: scale(1.2); background: var(--bg-hover); }
.tp-fav.is-on { color: var(--warning); }
.tp-fav.is-on:hover { color: var(--fg-subtle); }

/* 搜索命中高亮 */
.tp-hl { background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 2px; font-weight: var(--fw-semibold); }

/* 搜索结果视图 */
.tp-results__meta { margin-bottom: var(--sp-4); font-size: var(--fs-sm); color: var(--fg-muted); }

/* ---------------------------------------------------------------- 看板 */
.tp-kpi { padding: var(--sp-5); display: flex; align-items: center; gap: var(--sp-4); }
.tp-kpi__icon {
  display: grid; place-items: center; flex-shrink: 0;
  width: 44px; height: 44px; border-radius: var(--r-md);
  background: var(--accent-soft); color: var(--accent); font-size: var(--fs-lg);
}
.tp-kpi__label { font-size: var(--fs-xs); color: var(--fg-subtle); margin-bottom: 3px; }
.tp-kpi__value {
  font-size: var(--fs-2xl); font-weight: var(--fw-bold); line-height: 1.1;
  font-variant-numeric: var(--fv-num);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tp-kpi__value--text { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.tp-kpi__sub { font-size: var(--fs-xs); color: var(--fg-subtle); margin-top: 3px; }
.tp-kpi--success .tp-kpi__icon { background: var(--success-bg); color: var(--success); }
.tp-kpi--warning .tp-kpi__icon { background: var(--warning-bg); color: var(--warning); }
.tp-kpi--info .tp-kpi__icon    { background: var(--info-bg);    color: var(--info); }

.tp-chart { position: relative; height: 280px; }
.tp-chart--tall { height: 320px; }
.tp-chart canvas { max-width: 100%; }

.tp-dash-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap; padding: var(--sp-6) 0 var(--sp-4);
}
.tp-dash-head__meta { font-size: var(--fs-xs); color: var(--fg-subtle); margin-top: 4px; }

/* 数据切换时的柔和遮罩，避免图表闪烁 */
.tp-refreshing { position: relative; }
.tp-refreshing::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: color-mix(in srgb, var(--bg-surface) 60%, transparent);
  animation: tp-fade-in var(--dur-fast);
}

/* ---------------------------------------------------------------- 关于 */
.tp-feature { padding: var(--sp-5); height: 100%; }
.tp-feature__icon {
  display: grid; place-items: center; width: 40px; height: 40px;
  margin-bottom: var(--sp-3); border-radius: var(--r-md);
  background: var(--accent-soft); color: var(--accent); font-size: var(--fs-md);
  transition: transform var(--dur-base) var(--ease-spring);
}
.tp-card:hover .tp-feature__icon { transform: scale(1.08) rotate(-4deg); }
.tp-feature__title { font-size: var(--fs-md); margin-bottom: var(--sp-2); }
.tp-feature__desc { font-size: var(--fs-sm); color: var(--fg-muted); margin: 0; line-height: var(--lh-snug); }

.tp-modlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
.tp-modlist li {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  font-size: var(--fs-sm); transition: background var(--dur-fast);
}
.tp-modlist li:hover { background: var(--bg-hover); }
.tp-modlist__dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--success); }
.tp-modlist__dot--fail { background: var(--danger); }
.tp-modlist__path { margin-left: auto; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--fg-subtle); }

/* ---------------------------------------------------------------- 登录 */
.tp-auth { min-height: 100vh; display: grid; place-items: center; padding: var(--sp-4); }
.tp-auth__card { width: 100%; max-width: 380px; padding: var(--sp-8); }
.tp-auth__logo {
  display: grid; place-items: center; width: 48px; height: 48px;
  margin: 0 auto var(--sp-4); border-radius: var(--r-lg);
  background: var(--accent); color: var(--fg-onAccent); font-size: var(--fs-lg);
}

/* ---------------------------------------------------------------- 错误页 */
.tp-error { min-height: 100vh; display: grid; place-items: center; padding: var(--sp-6); text-align: center; }
.tp-error__code {
  font-size: 88px; font-weight: var(--fw-bold); line-height: 1;
  font-variant-numeric: var(--fv-num);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 40%, var(--fg-subtle)));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.tp-error__detail {
  margin-top: var(--sp-5); padding: var(--sp-3) var(--sp-4);
  background: var(--bg-sunken); border-radius: var(--r-md);
  font-family: var(--font-mono); font-size: var(--fs-xs);
  color: var(--fg-muted); text-align: left; max-width: 560px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}

/* ---------------------------------------------------------------- 页脚 */
.tp-footer {
  border-top: 1px solid var(--border); margin-top: var(--sp-12);
  padding: var(--sp-6) 0; font-size: var(--fs-xs); color: var(--fg-subtle);
}
.tp-footer a { color: var(--fg-muted); }
.tp-footer a:hover { color: var(--accent); }

/* ---------------------------------------------------------------- 移动端 */
.tp-sidebar-toggle { display: none; }

@media (max-width: 1080px) {
  .tp-shell { flex-direction: column; gap: var(--sp-4); }
  .tp-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: var(--z-drawer);
    width: 280px; max-height: none; padding: var(--sp-4);
    background: var(--bg-surface); border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform var(--dur-base) var(--ease-standard);
  }
  .tp-sidebar.is-open { transform: none; }
  .tp-sidebar-toggle { display: inline-flex; }
  .tp-scrim {
    position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1);
    background: rgba(9, 13, 20, 0.5); animation: tp-fade-in var(--dur-fast);
  }
  .tp-main { width: 100%; }
}

@media (max-width: 640px) {
  .tp-hero { padding: var(--sp-5) var(--sp-4); }
  .tp-hero__meta { gap: var(--sp-3); }
  .tp-kpi { padding: var(--sp-4); gap: var(--sp-3); }
  .tp-kpi__icon { width: 36px; height: 36px; font-size: var(--fs-base); }
  .tp-kpi__value { font-size: var(--fs-xl); }
  .tp-chart { height: 220px; }
  .tp-error__code { font-size: 64px; }
}

/* ============================================================================
   监控台 /monitor
   ---------------------------------------------------------------------------
   这几类组件原库里没有对应物，故新增：
     状态点  需要「脉冲」表达实时心跳，静态色块看不出死活
     控制台  需要等宽字体 + 下沉底色，用正文排版读日志很痛苦
     模态层  新增/编辑服务字段较多，弹层比行内展开更清爽
   ========================================================================= */

/* ---------------------------------------------------------------- 状态点 */
.tp-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: var(--r-full);
  background: var(--fg-subtle); flex: none; position: relative;
}
.tp-dot--running { background: var(--success); }
.tp-dot--running::after {
  content: ""; position: absolute; inset: -4px; border-radius: var(--r-full);
  border: 2px solid var(--success); opacity: 0;
  animation: tp-dot-pulse 1.8s var(--ease-out) infinite;
}
.tp-dot--starting { background: var(--info); animation: tp-dot-blink 1s infinite; }
.tp-dot--unhealthy,
.tp-dot--crashed  { background: var(--danger); animation: tp-dot-blink .8s infinite; }
.tp-dot--error    { background: var(--danger); }
.tp-dot--stopped  { background: var(--fg-subtle); }
.tp-dot--disabled { background: var(--border-strong); }

@keyframes tp-dot-pulse {
  0%   { opacity: .65; transform: scale(.7); }
  100% { opacity: 0;   transform: scale(1.7); }
}
@keyframes tp-dot-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: .3; }
}
@media (prefers-reduced-motion: reduce) {
  .tp-dot--running::after, .tp-dot--starting,
  .tp-dot--unhealthy, .tp-dot--crashed { animation: none; }
}

/* ---------------------------------------------------------------- 开关 */
.tp-switch {
  position: relative; display: inline-flex; align-items: center;
  width: 38px; height: 22px; flex: none; cursor: pointer;
}
.tp-switch input {
  position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0;
  cursor: pointer;
}
.tp-switch__track {
  width: 100%; height: 100%; border-radius: var(--r-full);
  background: var(--border-strong);
  transition: background var(--dur-base) var(--ease-standard);
}
.tp-switch__thumb {
  position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: var(--r-full); background: #fff; box-shadow: var(--shadow-xs);
  transition: transform var(--dur-base) var(--ease-spring);
  pointer-events: none;
}
.tp-switch input:checked ~ .tp-switch__track { background: var(--success); }
.tp-switch input:checked ~ .tp-switch__thumb { transform: translateX(16px); }
.tp-switch input:focus-visible ~ .tp-switch__track {
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.tp-switch input:disabled ~ .tp-switch__track { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- 服务卡片 */
.tp-svc {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--bg-surface); overflow: hidden;
  transition: border-color var(--dur-base) var(--ease-standard),
              box-shadow var(--dur-base) var(--ease-standard);
}
.tp-svc:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.tp-svc.is-running  { border-left: 3px solid var(--success); }
.tp-svc.is-problem  { border-left: 3px solid var(--danger); }
.tp-svc.is-starting { border-left: 3px solid var(--info); }
.tp-svc.is-idle     { border-left: 3px solid var(--border-strong); }

.tp-svc__head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4); flex-wrap: wrap;
}
.tp-svc__name {
  font-weight: var(--fw-semibold); font-size: var(--fs-md);
  display: flex; align-items: center; gap: var(--sp-2);
}
.tp-svc__detail { font-size: var(--fs-sm); color: var(--fg-muted); }
.tp-svc__cmd {
  font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--fg-subtle);
  background: var(--bg-sunken); padding: 2px var(--sp-2);
  border-radius: var(--r-sm); word-break: break-all;
}
.tp-svc__meta {
  display: flex; gap: var(--sp-4); flex-wrap: wrap;
  padding: 0 var(--sp-4) var(--sp-3);
  font-size: var(--fs-xs); color: var(--fg-subtle);
}
.tp-svc__meta b {
  color: var(--fg-muted); font-weight: var(--fw-medium);
  font-variant-numeric: var(--fv-num);
}
.tp-svc__out {
  border-top: 1px solid var(--border); background: var(--bg-sunken);
  padding: var(--sp-3) var(--sp-4);
}

/* ---------------------------------------------------------------- 控制台 */
.tp-console {
  font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1.7;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-3);
  max-height: 320px; overflow: auto;
  white-space: pre-wrap; word-break: break-all;
}
.tp-console__line { display: block; }
.tp-console__line--warn  { color: var(--warning); }
.tp-console__line--error { color: var(--danger); }
.tp-console__line--info  { color: var(--fg-muted); }
.tp-console__ts { color: var(--fg-subtle); margin-right: var(--sp-2); }

/* ---------------------------------------------------------------- 表单弹层
   ⚠️ 命名为 tp-sheet 而非 tp-modal：toolpage.css 里 .tp-modal 已被 TP.confirm
   占用（那里 .tp-modal 指「面板」、.tp-modal-backdrop 指「遮罩」），语义正好
   相反。若沿用同名，所有确认框会被这里的全屏遮罩样式打穿。 */
.tp-sheet {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4); background: rgba(9, 13, 20, .5);
  animation: tp-fade-in var(--dur-fast) var(--ease-out);
}
.tp-sheet[hidden] { display: none; }
.tp-sheet__panel {
  width: min(560px, 100%); max-height: 88vh; overflow: auto;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  animation: tp-pop-in var(--dur-base) var(--ease-spring);
}
.tp-sheet__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); padding: var(--sp-5); border-bottom: 1px solid var(--border);
}
.tp-sheet__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.tp-sheet__body { padding: var(--sp-5); display: grid; gap: var(--sp-4); }
.tp-sheet__foot {
  display: flex; justify-content: flex-end; gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border);
  background: var(--bg-sunken);
}
@keyframes tp-pop-in {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------- 字段说明 */
.tp-hint { font-size: var(--fs-xs); color: var(--fg-subtle); line-height: var(--lh-snug); }
.tp-hint code {
  font-family: var(--font-mono); background: var(--bg-sunken);
  padding: 1px 4px; border-radius: var(--r-sm);
}

/* ---------------------------------------------------------------- 提示条 */
.tp-notice {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-4); border-radius: var(--r-lg);
  border: 1px solid var(--border); background: var(--bg-sunken);
  font-size: var(--fs-sm); line-height: var(--lh-snug);
}
.tp-notice--warning { border-color: var(--warning); background: var(--warning-bg); }
.tp-notice--danger  { border-color: var(--danger);  background: var(--danger-bg); }
.tp-notice__icon { font-size: var(--fs-lg); flex: none; line-height: 1.2; }
.tp-notice--warning .tp-notice__icon { color: var(--warning); }
.tp-notice--danger  .tp-notice__icon { color: var(--danger); }
.tp-notice code {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  background: var(--bg-surface); padding: 1px 5px;
  border-radius: var(--r-sm); border: 1px solid var(--border);
}

@media (max-width: 640px) {
  .tp-svc__head { gap: var(--sp-2); }
  .tp-svc__meta { gap: var(--sp-3); }
  .tp-sheet__body { padding: var(--sp-4); }
}
