:root {
  --brand: #1c4caf;
  --brand-2: #3b82f6;
  --ink-1: #101828;
  --ink-2: #364152;
  --ink-3: #667085;
  --ink-4: #98a2b3;
  --line: rgba(16, 40, 100, 0.09);
  --bg: #f2f5fb;
  --card: rgba(255, 255, 255, 0.82);
  --r: 16px;
  --sh: 0 8px 26px rgba(24, 45, 96, 0.07);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink-1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(900px 600px at 12% -10%, #dfe9ff 0%, transparent 60%),
    radial-gradient(760px 520px at 92% 0%, #e6f0ff 0%, transparent 55%),
    linear-gradient(180deg, #f7f9ff 0%, #eef3fc 100%);
}

.bg i {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
}

.bg i:nth-child(1) {
  width: 420px; height: 420px; left: -120px; top: 220px;
  background: #c7dbff;
}

.bg i:nth-child(2) {
  width: 360px; height: 360px; right: -100px; top: 520px;
  background: #d7e8ff;
}

/* ---------- 顶栏 ---------- */
.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 18px;
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: 20px;
  background: linear-gradient(135deg, #2f6fe0, #12326e);
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(18, 50, 110, 0.28);
}

.bt { display: flex; flex-direction: column; line-height: 1.25; }
.bt b { font-size: 15px; letter-spacing: -0.01em; }
.bt em { font-style: normal; font-size: 11.5px; color: var(--ink-4); }

.bar-r { display: flex; align-items: center; gap: 8px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
}

.pill i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #c8ced8;
}

.pill.on i { background: #12b76a; box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.16); }
.pill.on { color: #067647; }
.pill.off { color: var(--ink-3); }
.pill.warn i { background: #f79009; box-shadow: 0 0 0 3px rgba(247, 144, 9, 0.16); }
.pill.warn { color: #b54708; }

/* ---------- 布局 ---------- */
main { max-width: 980px; margin: 0 auto; padding: 4px 18px 40px; }

/* ---------- 登录 ---------- */
.gate {
  max-width: 360px;
  margin: 12vh auto 0;
  padding: 26px 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--sh);
  text-align: center;
}

.gate h1 { margin: 0 0 6px; font-size: 20px; letter-spacing: -0.02em; }
.gate p { margin: 0 0 18px; font-size: 13px; color: var(--ink-3); }

.gate form { display: flex; flex-direction: column; gap: 10px; }

.gate input, .gate button { height: 44px; border-radius: 12px; font-size: 14px; }

.gate input {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-1);
  outline: none;
}

.gate input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15); }

.gate button {
  border: 0;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, #2f6fe0, #12326e);
  cursor: pointer;
}

.err { color: #d92d20; font-size: 12.5px; margin: 12px 0 0; }

/* ---------- 标签 ---------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 6px 0 16px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tabs button {
  flex: 1;
  min-width: 62px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  background: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s, color 0.16s;
}

.tabs button.on { color: #fff; background: var(--brand); }

.panel { display: none; }
.panel.on { display: block; animation: fade 0.22s ease; }

@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 卡片 ---------- */
.card {
  padding: 18px;
  margin-bottom: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.card h3 {
  margin: 0 0 12px;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.hint { margin: -6px 0 12px; font-size: 12px; color: var(--ink-4); line-height: 1.5; }

.grid4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--sh);
}

.stat span { font-size: 11.5px; color: var(--ink-4); }
.stat b { display: block; margin-top: 5px; font-size: 19px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.kv {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 9px 12px;
  margin: 0;
  font-size: 13px;
}

.kv dt { color: var(--ink-4); }
.kv dd { margin: 0; color: var(--ink-1); font-weight: 600; word-break: break-all; }

/* ---------- 表单 ---------- */
input[type="text"], input[type="password"], input[type="number"], input:not([type]), textarea, select {
  width: 100%;
  padding: 10px 13px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink-1);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

textarea {
  resize: vertical;
  line-height: 1.65;
}

.row, .row2 { display: flex; gap: 10px; }
.row2 { flex-wrap: wrap; }
.row2 label { flex: 1 1 180px; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--ink-3);
}

label.full { width: 100%; }

.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.check input { width: 16px; height: 16px; accent-color: var(--brand); }

button {
  font-family: inherit;
  cursor: pointer;
}

.row button, .actions button {
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: 11px;
  white-space: nowrap;
  flex-shrink: 0;
}

.primary { background: linear-gradient(135deg, #2f6fe0, #12326e) !important; }

button.ghost {
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  background: #eef2f9;
  border-radius: 12px;
}

.seg button {
  flex: 1;
  padding: 8px 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
  background: none;
  border: 0;
  border-radius: 9px;
}

.seg button.on { color: var(--brand); background: #fff; box-shadow: 0 2px 6px rgba(24, 45, 96, 0.1); }

.actions { display: flex; align-items: center; gap: 12px; padding: 4px 2px 10px; }
.ok { color: #067647; font-size: 12.5px; }

.out {
  margin: 12px 0 0;
  padding: 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  background: #f6f8fc;
  border-radius: 11px;
  color: var(--ink-2);
}

/* ---------- 列表 ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.item .it-main { flex: 1; min-width: 0; }
.item b { display: block; font-size: 13px; }
.item em { display: block; font-style: normal; font-size: 11.5px; color: var(--ink-4); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .num { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.empty { padding: 26px 0; text-align: center; font-size: 12.5px; color: var(--ink-4); }

/* ---------- 图表 ---------- */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding: 8px 2px 0;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.chart .bar2 {
  flex: 1;
  min-width: 6px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 1px;
  height: 100%;
}

.chart .bar2 i {
  display: block;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #4a8cf5, #1c4caf);
  min-height: 2px;
}

.chart .bar2 span {
  display: none;
}

.chart .bar2 em {
  font-style: normal;
  font-size: 9px;
  color: var(--ink-4);
  text-align: center;
  margin-top: 4px;
}

/* ---------- 日志 ---------- */
.logs {
  max-height: 62vh;
  overflow: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.7;
}

.logs div { padding: 2px 0; color: var(--ink-2); word-break: break-all; }
.logs time { color: var(--ink-4); margin-right: 8px; }
.logs .info { color: var(--ink-2); }
.logs .warn { color: #b54708; }
.logs .error { color: #d92d20; }

.foot {
  padding: 22px 18px 40px;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-4);
}

.foot a { color: var(--ink-3); text-decoration: none; }

@media (max-width: 640px) {
  .grid4 { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 15px; }
  .bar { padding: 12px 14px; }
  main { padding: 0 14px 32px; }
}

/* ---------- 扫码 ---------- */
.qrwrap {
  display: flex;
  justify-content: center;
  padding: 6px 0 2px;
}

.qrwrap img {
  width: 190px;
  height: 190px;
  padding: 10px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 18px rgba(24, 45, 96, 0.1);
  image-rendering: pixelated;
}

.qrage {
  margin: 10px 0 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-4);
}

.qrage.stale { color: #b54708; }

.qrbtn {
  display: flex;
  justify-content: center;
  margin: 10px 0 2px;
}

.stgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.stcell {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.stcell img {
  display: block;
  width: 100%;
  height: 84px;
  object-fit: cover;
}

.stcell span {
  display: block;
  padding: 5px 6px;
  font-size: 11px;
  color: var(--ink-3);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stcell .del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  line-height: 18px;
  text-align: center;
  font-size: 13px;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  border: 0;
  border-radius: 50%;
  padding: 0;
}

.facelist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.facelist code {
  padding: 5px 9px;
  font-size: 11.5px;
  color: var(--brand);
  background: #eef3ff;
  border-radius: 8px;
}

.stcell .approve {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 26px;
  padding: 4px 0;
  font-size: 11px;
  color: #fff;
  background: rgba(28, 76, 175, 0.82);
  border: 0;
  border-radius: 7px;
}

.stgrid .empty {
  grid-column: 1 / -1;
  padding: 20px 0;
}

/* ---------- 定时 ---------- */
#schTextBox textarea { resize: vertical; }
#schAdd { margin-top: 4px; padding: 10px 22px; font-size: 13.5px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #2f6fe0, #12326e); border: 0; border-radius: 11px; }
.sch-when { font-size: 11.5px; color: var(--ink-4); }
.sch-tag { display: inline-block; margin-right: 6px; padding: 2px 7px; font-size: 10.5px; color: var(--brand); background: #eef3ff; border-radius: 6px; }
