/* ============================================================
   Lighthouse — 代理信号控制台
   设计:深色仪表舱 + 琥珀信号 + 等宽读数(信标 / 航海刻度)
   ============================================================ */

/* ---- 设计令牌 ---- */
:root {
  --bg: #0a0e12;            /* 深墨蓝 海面 */
  --bg-panel: #10161c;      /* 面板背景 */
  --bg-raised: #141c24;     /* 浮起层/表格行 hover */
  --line: #22303d;          /* 发丝描边 */
  --line-strong: #2e4050;
  --text: #d7e0e8;          /* 正文 */
  --text-dim: #6b7a89;      /* 弱化文字 */
  --amber: #ffb54d;         /* 信号琥珀·主强调 */
  --amber-dim: #7a5a2b;
  --green: #4ec9a0;         /* healthy */
  --red: #e05c4b;           /* unhealthy / 危险 */
  --red-dim: #5c2a24;
  --info: #5b94ce;          /* unknown / 信息 */

  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  --font-cjk: "Source Han Sans SC", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;

  --radius: 2px;
  --gap: 16px;
  --pad: 18px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --anim: 300ms var(--ease);
}

/* ---- 基线 ---- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font: 14px/1.6 var(--font-mono);
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.018) 0 1px, transparent 1px 44px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 1px, transparent 1px 44px),
    linear-gradient(180deg, #0a0e12 0%, #0b1015 100%);
}
body::after { /* 微噪点气氛层,零网络请求 */
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAFElEQVR42mNkYGD4z0AEYJxoBKIHAAlzAgPZ3zDJAAAAAElFTkSuQmCC');
  opacity: .05;
}

a { color: var(--info); text-decoration: none; }
a:hover { color: var(--amber); }

/* ---- 顶部琥珀信标线 ---- */
.beacon-status {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 60;
  background: linear-gradient(90deg, transparent, var(--amber) 12%, var(--amber) 88%, transparent);
}
.beacon-status.pulse { animation: beaconPulse 1s ease; }
@keyframes beaconPulse { 0% { filter: brightness(1); } 50% { filter: brightness(2.4); } 100% { filter: brightness(1); } }

/* ---- 顶栏 ---- */
.topbar {
  position: sticky; top: 2px; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  padding: 0 var(--pad);
  height: 52px;
  background: rgba(10, 14, 18, .92);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); letter-spacing: .18em; }
.brand:hover { color: var(--amber); }
.brand-mark {
  font-size: 13px; font-weight: 600; color: #0a0e12;
  background: var(--amber); padding: 2px 6px; letter-spacing: .1em;
  clip-path: polygon(0 0, 100% 0, 100% 78%, 50% 100%, 0 78%);
}
.brand-name { font-size: 13px; font-weight: 600; }

.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--text-dim); font-size: 13px; letter-spacing: .1em;
  padding: 10px 12px; border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--amber); border-bottom-color: var(--amber); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.clock { color: var(--text-dim); font-size: 12px; letter-spacing: .06em; }

/* ---- 按钮 ---- */
.btn {
  appearance: none; cursor: pointer; border: 1px solid var(--line-strong);
  background: var(--bg-raised); color: var(--text);
  font: 13px/1 var(--font-mono); letter-spacing: .08em;
  padding: 8px 14px; border-radius: var(--radius);
  transition: border-color var(--anim), color var(--anim), background var(--anim);
}
.btn:hover { border-color: var(--amber); color: var(--amber); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--amber); color: #241503; border-color: var(--amber); font-weight: 600; }
.btn-primary:hover { background: #ffc77d; color: #241503; }
.btn-danger { border-color: var(--red-dim); color: var(--red); }
.btn-danger:hover { border-color: var(--red); color: var(--red); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 9px; font-size: 12px; }

/* ---- 表单 ---- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { color: var(--text-dim); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.input {
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius);
  color: var(--text); font: 14px var(--font-mono); padding: 9px 12px; width: 100%;
  transition: border-color var(--anim);
}
.input:focus { outline: none; border-color: var(--amber); }

/* ---- 面板(1px 描边 + 四角切角) ---- */
.panel {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,.015), transparent 60%), var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
}
.panel::before, .panel::after, .panel .corner-b::before, .panel .corner-b::after {
  content: ""; position: absolute; width: 8px; height: 8px; border-color: var(--amber); opacity: .55;
  pointer-events: none;
}
.panel::before { top: -1px; left: -1px; border-top: 1px solid; border-left: 1px solid; }
.panel::after { top: -1px; right: -1px; border-top: 1px solid; border-right: 1px solid; }
.panel .corner-b::before { bottom: -1px; left: -1px; border-bottom: 1px solid; border-left: 1px solid; }
.panel .corner-b::after { bottom: -1px; right: -1px; border-bottom: 1px solid; border-right: 1px solid; }

.panel-title {
  margin: 0 0 14px; font-size: 12px; font-weight: 600; letter-spacing: .18em;
  color: var(--amber); text-transform: uppercase;
}
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--gap); }

/* ---- 摘要 tile ---- */
.tile { text-align: left; }
.tile .tile-num {
  font-size: 30px; font-weight: 600; line-height: 1.1; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.tile .tile-label {
  margin-top: 6px; font-size: 11px; letter-spacing: .16em; color: var(--text-dim); text-transform: uppercase;
}
.tile .tile-sub { margin-top: 8px; font-size: 12px; color: var(--text-dim); }
.tile.accent .tile-num { color: var(--amber); }
.tile.good .tile-num { color: var(--green); }
.tile.bad .tile-num { color: var(--red); }

/* ---- 徽章 / 状态灯 ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-strong);
  color: var(--text-dim);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.healthy { color: var(--green); border-color: rgba(78,201,160,.4); }
.badge.unhealthy { color: var(--red); border-color: rgba(224,92,75,.4); }
.badge.unknown { color: var(--info); border-color: rgba(91,148,206,.35); }
.badge.disabled { color: var(--text-dim); }
.badge .dot.pulse-anim { animation: dotPulse 1.2s ease infinite; }
@keyframes dotPulse { 50% { opacity: .25; } }

/* ---- 表格 ---- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-weight: 600; font-size: 11px; letter-spacing: .12em;
  color: var(--text-dim); text-transform: uppercase;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr { transition: background var(--anim); }
.tbl tbody tr:hover { background: var(--bg-raised); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.muted { opacity: .55; }

/* ---- 开关(节点启停)---- */
.switch { position: relative; display: inline-block; width: 40px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .sl {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--bg-raised); border: 1px solid var(--line-strong); border-radius: 999px;
  transition: background var(--anim), border-color var(--anim);
}
.switch .sl::before {
  content: ""; position: absolute; width: 12px; height: 12px; left: 3px; top: 50%;
  transform: translateY(-50%); border-radius: 50%;
  background: var(--text-dim); transition: left var(--anim), background var(--anim);
}
.switch input:checked + .sl { background: rgba(78,201,160,.14); border-color: var(--green); }
.switch input:checked + .sl::before { left: 22px; background: var(--green); }
.switch input:disabled + .sl { opacity: .5; cursor: not-allowed; }

/* ---- 进度条(指标)---- */
.meter { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.meter .bar {
  flex: 1; height: 6px; background: var(--bg-raised); border: 1px solid var(--line); border-radius: 999px;
  overflow: hidden;
}
.meter .bar .fill { height: 100%; background: var(--green); transition: width 400ms var(--ease), background var(--anim); }
.meter .bar .fill.hot { background: var(--amber); }
.meter .bar .fill.danger { background: var(--red); }
.meter .val { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }

/* ---- api_key 回显 ---- */
.apikey-reveal {
  border: 1px dashed var(--amber-dim); background: rgba(255,181,77,.05);
  padding: 14px; margin: 0 0 14px;
}
.apikey-reveal .row { display: flex; gap: 10px; align-items: center; }
.apikey-reveal input { flex: 1; }
.apikey-reveal .hint { margin-top: 8px; font-size: 12px; color: var(--amber); }

/* ---- 图表容器 ---- */
.chart-box { position: relative; width: 100%; height: 240px; }
.chart-box canvas { width: 100%; height: 100%; display: block; }
.chart-empty { height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--text-dim); }
.chart-empty .glyph { font-size: 30px; opacity: .5; }

/* ---- chips(top_targets)---- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 11px; color: var(--text-dim); border: 1px solid var(--line-strong);
  padding: 1px 8px; border-radius: 999px; background: var(--bg);
}

/* ---- 登录 ---- */
.login-wrap { max-width: 380px; margin: 9vh auto 0; }
.login-wrap .brand-big {
  font-size: 20px; letter-spacing: .3em; color: var(--amber); margin: 0 0 4px; font-weight: 600;
}

/* ---- 空态 / 提示 ---- */
.empty { padding: 40px 0; text-align: center; color: var(--text-dim); font-size: 13px; }
.muted { color: var(--text-dim); }
.mono { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 12px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 4px; }
.spread { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.mt0 { margin-top: 0; }
.mt1 { margin-top: 8px; }
.mt2 { margin-top: 16px; }
.mb2 { margin-bottom: 16px; }

/* ---- toast ---- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-raised); border: 1px solid var(--line-strong); border-left: 3px solid var(--info);
  color: var(--text); font-size: 13px; padding: 10px 14px; border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0,0,0,.45);
  animation: slideIn .25s var(--ease);
  max-width: 360px;
}
.toast.error { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
@keyframes slideIn { from { transform: translateY(8px); opacity: 0; } }

/* ---- 分层入场 ---- */
#view > [data-order] { animation: rise var(--anim) backwards; animation-delay: calc(var(--order, 0) * 70ms); }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

/* ---- 终端视图 ---- */
.term-toolbar {
  display: flex; align-items: center; gap: 12px; padding: 0 0 10px;
  border-bottom: 1px solid var(--line); margin-bottom: 12px;
}
.term-box { background: #05070a; border: 1px solid var(--line); padding: 10px; height: 60vh; }
.term-box .xterm { height: 100%; }

/* ---- 响应式 ---- */
@media (max-width: 720px) {
  .topbar { gap: 12px; }
  .brand-name { display: none; }
  .panel-grid { grid-template-columns: 1fr; }
}

/* ---- 减少动态 ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
}