:root {
  --bg: #0f1419;
  --panel: #161d26;
  --panel-2: #1c2530;
  --border: #263241;
  --text: #dbe4ee;
  --muted: #7d8fa3;
  --accent: #3b82f6;
  --ok: #22c55e;
  --err: #ef4444;
  --warn: #f59e0b;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  display: flex;
  min-height: 100vh;
}

body.drawer-open { overflow: hidden; }

code, pre, .mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ---------- 侧边栏 / 移动端抽屉 ---------- */
.sidebar {
  flex: 0 0 220px;
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 60;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-close {
  display: none;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.drawer-close:hover { color: var(--text); }

.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
}

.sidebar-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 14px;
  transition: .15s;
}
.sidebar-nav a:hover { color: var(--text); background: var(--panel-2); }
.sidebar-nav a.active { color: #fff; background: var(--accent); }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }

.logout {
  display: block;
  text-align: center;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.logout:hover { color: var(--err); border-color: var(--err); }

.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 55;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
}
.drawer-mask.show { opacity: 1; visibility: visible; }

/* 移动端顶栏（仅窄屏显示） */
.mobilebar {
  display: none;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.mobilebar-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hamburger {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.hamburger span {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}
.hamburger:hover { border-color: #3d4d61; }

/* ---------- 布局 ---------- */
.main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
}

h1 { font-size: 20px; margin: 0 0 20px; font-weight: 600; }
h2 { font-size: 15px; margin: 0 0 14px; font-weight: 600; color: #fff; }

/* ---------- 卡片 ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}

.card-label { color: var(--muted); font-size: 12px; }
.card-value { font-size: 22px; font-weight: 600; margin: 6px 0 2px; }
.card-value.on { color: var(--ok); }
.card-value.off { color: var(--err); }
.card-sub { color: var(--muted); font-size: 12px; }

/* ---------- 面板 ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 18px;
}

.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.empty { color: var(--muted); margin: 0; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; }

table.data th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

table.data td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--panel-2); }

table.kv th {
  text-align: left;
  color: var(--muted);
  font-weight: 400;
  padding: 7px 16px 7px 0;
  white-space: nowrap;
  width: 190px;
  vertical-align: top;
}

table.kv td { padding: 7px 0; }

.nowrap { white-space: nowrap; color: var(--muted); font-size: 12.5px; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
}
.tag.on { background: rgba(34,197,94,.15); color: var(--ok); }
.tag.off { background: rgba(239,68,68,.15); color: var(--err); }
.tag.warn { background: rgba(245,158,11,.15); color: var(--warn); }

/* ---------- 按钮 ---------- */
.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
  font-family: inherit;
}
.btn:hover { border-color: #3d4d61; background: #222d3a; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2f6fd8; }
.btn.danger { color: var(--err); border-color: rgba(239,68,68,.4); }
.btn.danger:hover { background: rgba(239,68,68,.12); }
.btn.ghost { color: var(--muted); }
.btn.tiny { padding: 3px 9px; font-size: 12px; }
.btn.block { width: 100%; margin-top: 8px; }

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

/* ---------- 表单 ---------- */
input[type=text], input[type=password], input[type=date], select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: .15s;
}
input[type=text]:focus, input[type=password]:focus,
input[type=date]:focus, select:focus { border-color: var(--accent); }
input::placeholder { color: #5a6b7d; }
select { cursor: pointer; }

.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row input[type=text] { flex: 1; min-width: 180px; }

.form-col { display: flex; flex-direction: column; gap: 8px; max-width: 460px; }
.form-col label { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.form-col .btn { align-self: flex-start; margin-top: 8px; }

.ops { display: flex; gap: 6px; }
.ops form { display: inline; }

/* ---------- 分页 ---------- */
.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.pager-info { color: var(--muted); font-size: 12.5px; }

.pw { font-family: monospace; }

/* ---------- 提示条 ---------- */
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}
.flash.ok { background: rgba(34,197,94,.12); color: var(--ok); border: 1px solid rgba(34,197,94,.3); }
.flash.error { background: rgba(239,68,68,.12); color: var(--err); border: 1px solid rgba(239,68,68,.3); }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-box h1 { font-size: 18px; margin: 0; text-align: center; }
.login-box .sub { color: var(--muted); font-size: 12.5px; text-align: center; margin: 0 0 14px; }
.login-box label { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.login-box .btn { margin-top: 18px; }

/* ---------- 弹窗 ---------- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  width: 100%;
  max-width: 720px;
}

.modal-box h3 { margin: 0 0 12px; font-size: 15px; }
.modal-box pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  max-height: 50vh;
  overflow: auto;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0 0 14px;
}

ol, ul { padding-left: 22px; margin: 0; }
ol li, ul li { margin-bottom: 6px; }

/* ---------- 桌面端：抽屉遮罩不参与布局 ---------- */
@media (min-width: 861px) {
  .drawer-mask { display: none; }
}

/* ---------- 移动端：侧边栏转为抽屉 ---------- */
@media (max-width: 860px) {
  body { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 258px;
    max-width: 82vw;
    height: 100%;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, .5);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar.open { transform: translateX(0); }
  .drawer-close { display: block; }
  .mobilebar { display: flex; }

  .main { min-height: auto; }
  .container { padding: 16px 14px 32px; }
  h1 { font-size: 18px; }

  .cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .card { padding: 14px; }
  .card-value { font-size: 19px; }

  /* 数据表横向滚动，避免窄屏挤压 */
  .panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.data { min-width: 600px; }
  table.kv th { width: 106px; padding-right: 10px; font-size: 13px; }
  table.kv td { font-size: 13px; word-break: break-word; }

  /* 放大触摸目标 */
  .btn { padding: 9px 14px; }
  .btn.tiny { padding: 6px 10px; font-size: 12px; }
  .ops { flex-wrap: wrap; }
  .form-row input[type=text] { min-width: 100%; }
  .modal { padding: 14px; }
  .login-box { padding: 24px 20px; }
}

@media (max-width: 400px) {
  .sidebar { width: 84vw; }
  .card-value { font-size: 17px; }
}

/* ---------- 客户端下载页 ---------- */
.dl-hero {
  text-align: center;
  padding: 34px 16px 10px;
}

.dl-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--accent);
  background: rgba(59, 130, 246, .12);
  border: 1px solid rgba(59, 130, 246, .35);
  margin-bottom: 14px;
}

.dl-title { font-size: 32px; margin: 0 0 6px; color: #fff; }

.dl-sub { color: var(--muted); margin: 0 0 24px; }

.dl-btn {
  display: inline-block;
  padding: 12px 28px;
  font-size: 15px;
  text-decoration: none;
}

.dl-meta { color: var(--muted); font-size: 12.5px; margin-top: 12px; }

.dl-body { max-width: 720px; margin: 18px auto 0; }

@media (max-width: 860px) {
  .dl-title { font-size: 26px; }
  .dl-btn { display: block; text-align: center; }
}

