/* jdops 主控台样式
 *
 * 手机优先：默认按窄屏写，≥768px 才切侧边栏布局。
 * 极简浅色 —— 白底、大留白、信息密度适中，手机上长时间看不累。
 */

:root {
  --bg: #fafafa;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-dim: #6b7280;
  --text-faint: #9ca3af;
  --line: #ededed;
  --line-strong: #e0e0e0;

  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --ok: #16a34a;
  --ok-soft: #f0fdf4;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --err: #dc2626;
  --err-soft: #fef2f2;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
  --tab-h: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── 布局骨架 ──────────────────────────────────────────── */

.app { min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: rgba(255,255,255,.88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 {
  margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em;
}
.topbar .spacer { flex: 1; }
.topbar .who {
  font-size: 13px; color: var(--text-dim);
  display: flex; align-items: center; gap: 6px;
}

.content {
  padding: 16px;
  padding-bottom: calc(var(--tab-h) + 24px);
  max-width: 1200px; margin: 0 auto;
}

/* ── 底部 tab（手机） ──────────────────────────────────── */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  height: var(--tab-h);
  background: rgba(255,255,255,.94);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--text-faint); font-size: 11px;
  transition: color .15s;
}
.tabbar button.active { color: var(--accent); }
.tabbar .ico { font-size: 18px; line-height: 1; }
.tabbar .badge {
  position: absolute; transform: translate(14px, -10px);
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--err); color: #fff; border-radius: 8px;
  font-size: 10px; line-height: 16px; text-align: center;
}

/* ── 卡片 ──────────────────────────────────────────────── */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  margin-bottom: 12px; box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.card-head h2 {
  margin: 0; font-size: 15px; font-weight: 600;
}
.card-head .spacer { flex: 1; }

/* ── 统计格 ────────────────────────────────────────────── */

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.stat .k { font-size: 12px; color: var(--text-dim); }
.stat .v {
  font-size: 24px; font-weight: 600; letter-spacing: -.02em;
  margin-top: 2px; font-variant-numeric: tabular-nums;
}
.stat .u { font-size: 12px; color: var(--text-faint); margin-left: 3px; font-weight: 400; }

/* ── 列表项 ────────────────────────────────────────────── */

.row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; padding-bottom: 0; }
.row:first-child { padding-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title {
  font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.row .sub {
  font-size: 12px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}

/* ── 徽标 ──────────────────────────────────────────────── */

.tag {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; line-height: 18px; font-weight: 500;
  background: #f3f4f6; color: var(--text-dim);
  white-space: nowrap;
}
.tag.ok   { background: var(--ok-soft);   color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.err  { background: var(--err-soft);  color: var(--err); }
.tag.info { background: var(--accent-soft); color: var(--accent); }

.dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint); margin-right: 6px; vertical-align: middle;
}
.dot.on  { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.off { background: var(--text-faint); }

/* ── 表单 ──────────────────────────────────────────────── */

.field { margin-bottom: 12px; }
.field label {
  display: block; font-size: 13px; color: var(--text-dim);
  margin-bottom: 5px; font-weight: 500;
}

input[type=text], input[type=password], input[type=number],
input[type=datetime-local], select, textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--text); font-size: 15px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 72px; line-height: 1.5; }

/* ── 按钮 ──────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: #fff; color: var(--text);
  font-size: 14px; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: all .15s;
  -webkit-user-select: none; user-select: none;
}
.btn:hover:not(:disabled) { background: #fafafa; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn.primary:hover:not(:disabled) { background: #1d4ed8; }
.btn.danger { color: var(--err); border-color: #fecaca; }
.btn.danger:hover:not(:disabled) { background: var(--err-soft); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.block { width: 100%; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── 提示 ──────────────────────────────────────────────── */

.empty {
  text-align: center; padding: 40px 20px; color: var(--text-faint);
  font-size: 14px;
}
.empty .big { font-size: 32px; display: block; margin-bottom: 8px; opacity: .5; }

.note {
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 13px; line-height: 1.6; margin-bottom: 12px;
}
.note.info { background: var(--accent-soft); color: #1e40af; }
.note.ok   { background: var(--ok-soft);     color: #166534; }
.note.warn { background: var(--warn-soft);   color: #92400e; }
.note.err  { background: var(--err-soft);    color: #991b1b; }

/* ── 二维码 ────────────────────────────────────────────── */

.qrbox {
  display: flex; flex-direction: column; align-items: center;
  padding: 20px; gap: 12px;
}
.qrbox img {
  width: min(240px, 70vw); height: auto;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; padding: 8px;
}

/* ── 日志流 ────────────────────────────────────────────── */

.logs {
  background: #1a1a1a; border-radius: var(--radius);
  padding: 12px; max-height: 60vh; overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.7;
}
.logs .l { color: #d4d4d4; word-break: break-all; }
.logs .l.warn { color: #fbbf24; }
.logs .l.error { color: #f87171; }
.logs .t { color: #6b7280; margin-right: 8px; }

/* ── 弹层 ──────────────────────────────────────────────── */

.mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.35);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 520px;
  border-radius: 16px 16px 0 0;
  padding: 20px; max-height: 88vh; overflow-y: auto;
  animation: slideUp .2s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal h3 { margin: 0 0 16px; font-size: 16px; font-weight: 600; }

/* ── 登录页 ────────────────────────────────────────────── */

.login-wrap {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center; padding: 24px;
}
.login-box {
  width: 100%; max-width: 360px;
  background: #fff; border-radius: 16px; padding: 32px 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 12px 32px rgba(0,0,0,.06);
}
.login-box h1 {
  margin: 0 0 4px; font-size: 22px; font-weight: 600;
  letter-spacing: -.02em; text-align: center;
}
.login-box .sub {
  text-align: center; color: var(--text-dim);
  font-size: 13px; margin-bottom: 24px;
}

/* ── 进度条 ────────────────────────────────────────────── */

.bar {
  height: 4px; background: #f3f4f6; border-radius: 2px;
  overflow: hidden; margin-top: 8px;
}
.bar > i {
  display: block; height: 100%; background: var(--accent);
  border-radius: 2px; transition: width .3s;
}
.bar.ok > i  { background: var(--ok); }
.bar.err > i { background: var(--err); }

/* ── 加载 ──────────────────────────────────────────────── */

.spin {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(0,0,0,.1); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 工具类 ────────────────────────────────────────────── */

.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mb0 { margin-bottom: 0; }
.center { text-align: center; }
.hidden { display: none; }

/* ══════════════════════════════════════════════════════════
   宽屏：切侧边栏
   ══════════════════════════════════════════════════════════ */

@media (min-width: 768px) {
  .app { display: flex; }

  .sidebar {
    width: 208px; flex: 0 0 208px;
    border-right: 1px solid var(--line);
    background: #fff;
    height: 100vh; position: sticky; top: 0;
    display: flex; flex-direction: column;
  }
  .sidebar .brand {
    padding: 20px 20px 16px; font-size: 17px; font-weight: 600;
    letter-spacing: -.02em;
  }
  .sidebar nav { flex: 1; padding: 0 10px; }
  .sidebar nav button {
    width: 100%; display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; margin-bottom: 2px;
    border: 0; background: none; border-radius: var(--radius-sm);
    font-size: 14px; color: var(--text-dim); cursor: pointer;
    font-family: inherit; text-align: left;
    transition: all .15s;
  }
  .sidebar nav button:hover { background: #fafafa; color: var(--text); }
  .sidebar nav button.active {
    background: var(--accent-soft); color: var(--accent); font-weight: 500;
  }
  .sidebar .foot {
    padding: 12px 20px; border-top: 1px solid var(--line);
    font-size: 12px; color: var(--text-faint);
  }

  .main { flex: 1; min-width: 0; }
  .content { padding: 24px; padding-bottom: 24px; }
  .tabbar { display: none; }

  .stats { grid-template-columns: repeat(4, 1fr); }
  .mask { align-items: center; }
  .modal {
    border-radius: 16px; max-height: 80vh;
    animation: fadeUp .18s ease-out;
  }
  @keyframes fadeUp {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
  }
}

@media (min-width: 1100px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
}
