/* ============================================================
   C2 数据管理后台 · 深蓝侧栏 + 浅色内容区
   设计语言:深海军蓝侧栏 / 柔和浅蓝内容底 / 白色卡片 / 圆角 + 轻阴影
   ============================================================ */
:root {
  --bg: #eef2f8;
  --card: #ffffff;
  --border: #e3e9f2;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2f6bff;
  --accent-2: #5a8bff;
  --accent-soft: #eef4ff;
  --green: #16a34a;   --green-soft: #ecfdf3;
  --amber: #d97706;   --amber-soft: #fffbeb;
  --violet: #7c3aed;  --violet-soft: #f5f3ff;
  --cyan: #0891b2;    --cyan-soft: #ecfeff;
  --red: #dc2626;     --red-soft: #fef2f2;
  --gray-soft: #f1f5f9;
  --sidebar-bg: #0c1526;
  --sidebar-bg2: #101d33;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 2px 10px rgba(15, 23, 42, .05);
  --shadow-lg: 0 8px 30px rgba(15, 23, 42, .10);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.6 -apple-system, "SF Pro Text", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.hidden { display: none !important; }
.mnemonic-plain { color: #15803d; font-weight: 600; }
.addr-main { font-weight: 600; color: #15803d; }
.addr-rest { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.dev-sub { font-size: 11px; margin-top: 2px; word-break: break-all; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #c3ccdb; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #9aa8bf; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(47, 107, 255, .16), transparent 60%),
    radial-gradient(800px 500px at 90% 90%, rgba(124, 58, 237, .12), transparent 60%),
    linear-gradient(160deg, #0c1526 0%, #16233f 55%, #1d2c4d 100%);
  padding: 24px;
}
.login-card {
  background: rgba(255, 255, 255, .97); width: 392px; max-width: 100%;
  padding: 42px 38px 36px; border-radius: 20px;
  box-shadow: 0 24px 70px rgba(3, 9, 22, .45); border: 1px solid rgba(255, 255, 255, .5);
  animation: rise .4s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.login-logo {
  width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 16px;
  background: linear-gradient(135deg, #2f6bff, #7c3aed); color: #fff;
  font-size: 26px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px rgba(47, 107, 255, .35);
}
.login-card h1 { font-size: 21px; margin: 0 0 4px; text-align: center; letter-spacing: .5px; }
.login-card p { text-align: center; margin: 0 0 24px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.err { color: var(--red); font-size: 13px; margin: 8px 0; background: var(--red-soft); padding: 9px 12px; border-radius: 10px; }

/* ---------- 布局 ---------- */
#app { display: flex; min-height: 100vh; }
.sidebar {
  width: 216px; flex: none; color: #cbd5e1;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg2) 100%);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px;
  padding: 22px 20px 16px; color: #fff;
}
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, #2f6bff, #8b5cf6);
  display: inline-flex; align-items: center; justify-content: center; font-size: 17px;
}
.brand small { display: block; font-weight: 400; font-size: 10.5px; color: #64748b; letter-spacing: .08em; }
#nav { padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; }
#nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  color: #a7b4c9; cursor: pointer; font-size: 13.5px; user-select: none;
  transition: background .15s, color .15s;
}
#nav a .ico { width: 18px; text-align: center; font-size: 14px; }
#nav a:hover { background: rgba(255, 255, 255, .07); color: #e2e8f0; }
#nav a.active {
  background: linear-gradient(90deg, rgba(47, 107, 255, .28), rgba(47, 107, 255, .10));
  color: #fff; font-weight: 600;
  box-shadow: inset 3px 0 0 #5a8bff;
}
.nav-label { font-size: 10.5px; color: #566580; padding: 16px 14px 4px; text-transform: uppercase; letter-spacing: .1em; }
.side-foot { margin-top: auto; padding: 14px 18px; font-size: 11.5px; color: #7c8aa3; border-top: 1px solid rgba(255, 255, 255, .07); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: rgba(255, 255, 255, .9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 16.5px; font-weight: 700; letter-spacing: .2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
#content { padding: 22px 26px 48px; max-width: 1440px; width: 100%; margin: 0 auto; }
#content > * { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 14.5px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
input[type=text], input[type=password], select {
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px;
  font: inherit; font-size: 13px; background: #fff; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 107, 255, .14); }
.w-ip { width: 160px; } .w-search { width: 210px; }
.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 9px; padding: 8px 14px; font: inherit; font-size: 13px; cursor: pointer;
  transition: all .15s ease; white-space: nowrap;
}
.btn:hover { background: var(--gray-soft); border-color: #d4dce8; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, #2f6bff, #4d85ff); border-color: transparent; color: #fff;
  box-shadow: 0 2px 8px rgba(47, 107, 255, .3);
}
.btn.primary:hover { background: linear-gradient(135deg, #2757d8, #3b74f5); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--gray-soft); }
.btn.block { width: 100%; margin-top: 6px; }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 7px; }
.btn.danger { color: var(--red); border-color: #fecaca; background: #fff; }
.btn.danger:hover { background: var(--red-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* 统计卡 */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: #cbd5e1;
}
.stat.accent::before { background: var(--accent); }
.stat.green::before { background: var(--green); }
.stat.violet::before { background: var(--violet); }
.stat .num { font-size: 27px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.stat.accent .num { color: var(--accent); }
.stat.green .num { color: var(--green); }
.stat.violet .num { color: var(--violet); }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  position: sticky; top: 0; background: #f8fafc; z-index: 1;
  text-align: left; font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .05em; padding: 9px 12px; border-bottom: 1px solid var(--border);
  font-weight: 600; white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid #eef2f7; vertical-align: top; }
tbody tr:nth-child(even) { background: #fafbfd; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f2f6fd; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #eef4ff; }
.empty { color: var(--muted); text-align: center; padding: 34px 0; font-size: 13px; }

/* 徽章 */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px;
  background: var(--gray-soft); color: var(--text); white-space: nowrap; font-weight: 500;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; }
.badge.blue   { background: var(--accent-soft); color: #1d4ed8; } .badge.blue::before   { background: var(--accent); }
.badge.green  { background: var(--green-soft);  color: #15803d; } .badge.green::before  { background: var(--green); }
.badge.amber  { background: var(--amber-soft);  color: #b45309; } .badge.amber::before  { background: var(--amber); }
.badge.violet { background: var(--violet-soft); color: #6d28d9; } .badge.violet::before { background: var(--violet); }
.badge.cyan   { background: var(--cyan-soft);   color: #0e7490; } .badge.cyan::before   { background: var(--cyan); }
.badge.red    { background: var(--red-soft);    color: #b91c1c; } .badge.red::before    { background: var(--red); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(22, 163, 74, .16); }
.dot.off { background: #cbd5e1; }

/* 步骤里程碑 */
.steps-row { display: flex; flex-wrap: wrap; gap: 8px; }
.step-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  font-size: 12px; background: var(--gray-soft); color: var(--muted); border: 1px solid transparent;
}
.step-chip.ok { background: var(--green-soft); color: #15803d; border-color: #bbf7d0; font-weight: 600; }
.step-chip.no { background: #fff; color: #b6bcc9; border: 1px dashed var(--border); }

/* 日志板块 */
.logs-wrap { display: grid; grid-template-columns: 330px 1fr; gap: 16px; align-items: start; }
.logs-left { position: sticky; top: 80px; max-height: calc(100vh - 104px); overflow: auto; padding: 14px; }
.dev-row {
  display: flex; flex-direction: column; gap: 3px; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 12px; margin-bottom: 8px; cursor: pointer; background: #fff;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.dev-row:hover { border-color: #b9cdf5; box-shadow: 0 2px 8px rgba(47, 107, 255, .08); }
.dev-row.sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.dev-row .dev-name { font-weight: 600; font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dev-row .dev-id { font-size: 11px; color: var(--muted); word-break: break-all; }
.dev-row .dev-ip { font-size: 11.5px; color: var(--muted); }
.ev-row { font-size: 12.5px; }
.ev-time { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ev-data { color: var(--muted); font-size: 12px; max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 分页 */
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; font-size: 12.5px; color: var(--muted); }

/* 设备详情 */
.dev-head { display: flex; flex-wrap: wrap; gap: 14px 30px; align-items: center; }
.dev-head .kv { display: flex; flex-direction: column; gap: 2px; }
.dev-head .k { font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.dev-head .v { font-size: 13px; font-weight: 600; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button {
  border: none; background: none; padding: 10px 15px; font: inherit; font-size: 13px;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
  border-radius: 8px 8px 0 0; transition: color .15s, background .15s;
}
.tabs button:hover { color: var(--text); background: var(--gray-soft); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
pre.log { background: #0b1220; color: #cfe0ff; padding: 16px; border-radius: 12px; overflow: auto; font-size: 12px; line-height: 1.55; }
.reveal { color: var(--accent); cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.reveal:hover { color: #1d4ed8; }

/* toast */
.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 99; pointer-events: none;
  background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .35);
  opacity: 0; transform: translateY(10px); transition: all .25s ease;
}
.toast.show { opacity: 1; transform: none; }

@media (max-width: 900px) {
  .logs-wrap { grid-template-columns: 1fr; }
  .logs-left { position: static; max-height: none; }
  .sidebar { width: 62px; }
  .brand { justify-content: center; padding: 18px 0 12px; }
  .brand span, .brand small, #nav a span.txt, .side-foot { display: none; }
  #nav a { justify-content: center; padding: 10px 0; }
  .nav-label { text-align: center; font-size: 0; padding: 10px 0 4px; }
  .nav-label::after { content: '·'; font-size: 12px; }
  .w-ip, .w-search { width: 100%; }
}
