:root {
  --blue: #0b63ce;
  --blue-deep: #084a9c;
  --teal: #0a8f8a;
  --ink: #10283f;
  --muted: #6b7f93;
  --line: #e3ebf3;
  --bg: #edf2f8;
  --red: #c03535;
  --green: #12805c;
  --amber: #b66a00;
  --radius: 16px;
  --shadow-sm: 0 2px 10px rgba(15, 39, 66, .06);
  --shadow-md: 0 12px 34px rgba(15, 39, 66, .10);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: linear-gradient(170deg, var(--bg) 0%, #f7fafd 60%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus, .tab:focus, .btn:focus, .link:focus { outline: none; -webkit-tap-highlight-color: transparent; }

/* ============ 登录页 ============ */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 22px;
  background: linear-gradient(155deg, var(--blue-deep) 0%, var(--blue) 48%, var(--teal) 100%);
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 28px;
  padding: 36px 28px 30px;
  box-shadow: 0 24px 70px rgba(8, 40, 72, .28);
  text-align: center;
}
.logo {
  width: 76px; height: 76px;
  margin: 0 auto 20px;
  border-radius: 24px;
  display: grid; place-items: center;
  color: #fff; font-weight: 800; letter-spacing: 2px; font-size: 26px;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  box-shadow: 0 12px 26px rgba(11, 99, 206, .30);
}
.login-card h1 { font-size: 23px; letter-spacing: .5px; }
.login-card p { color: var(--muted); font-size: 13px; margin: 10px 0 26px; line-height: 1.75; }
.login-card input {
  width: 100%;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #f7fbff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(11, 99, 206, .12);
}
.login-card button {
  width: 100%;
  margin-top: 16px;
  padding: 15px;
  border: 0;
  border-radius: 15px;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--blue), var(--blue-deep));
  box-shadow: 0 10px 22px rgba(11, 99, 206, .28);
  transition: transform .12s, box-shadow .15s;
}
.login-card button:active { transform: scale(.98); }
.error { color: var(--red); font-size: 13px; margin-top: 12px; }

/* ============ 主界面 ============ */
#appView { width: min(720px, 100%); margin: 0 auto; padding: 18px 16px 64px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 18px 18px;
  border-radius: 22px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue-deep) 0%, var(--blue) 52%, var(--teal) 100%);
  box-shadow: var(--shadow-md);
}
.topbar h1 { font-size: 20px; letter-spacing: .5px; }
.topbar p { color: rgba(255, 255, 255, .82); font-size: 12px; margin-top: 4px; }
.ghost {
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .35);
  color: #fff;
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.device-bar { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 12px; scrollbar-width: none; }
.device-bar::-webkit-scrollbar { display: none; }
.device-chip {
  flex: 0 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 13px;
  font-size: 12px;
  min-width: 158px;
  box-shadow: var(--shadow-sm);
}
.device-chip b { display: block; font-size: 13px; }
.device-chip span { color: var(--muted); }
.device-chip.on { border-color: #bfe3d4; background: #f4fbf8; }
.device-chip.off { border-color: #f0d4d4; background: #fdf8f8; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #b9c6d4; margin-right: 6px; }
.dot.on { background: var(--green); box-shadow: 0 0 0 4px rgba(18, 128, 92, .14); }
.dot.off { background: var(--red); }

.tabs {
  display: flex;
  gap: 4px;
  background: #e6eef6;
  padding: 4px;
  border-radius: 16px;
  margin-bottom: 14px;
}
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: #516a82;
  padding: 11px 4px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s, color .15s, box-shadow .15s;
}
.tab.active { background: #fff; color: var(--blue-deep); box-shadow: var(--shadow-sm); }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px 18px;
  box-shadow: var(--shadow-md);
}
.panel-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel-title h2 { font-size: 17px; }
.badge { background: #fff4e3; color: var(--amber); font-size: 11px; font-weight: 700; border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.sub { color: var(--muted); font-size: 12px; margin-top: 6px; }
.apply-entry { margin-top: 10px; font-size: 12px; color: var(--muted); background: #f0f7ff; border: 1px dashed #b9d6f2; border-radius: 12px; padding: 10px 12px; }
.apply-entry a { color: var(--blue); font-weight: 700; text-decoration: none; }
.qr-card { margin-top: 12px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px 12px; }
.qr-card img { width: 200px; height: 200px; display: block; margin: 0 auto; }
.qr-card p { color: var(--muted); font-size: 12px; margin-top: 10px; }

/* ============ 照片 ============ */
.photo-row { display: flex; gap: 16px; margin: 20px 0; }
.panel .photo-row { justify-content: center; }
.photo-box {
  width: 132px; height: 176px;
  flex: 0 0 132px;
  border: 1.5px dashed #b9cce1;
  border-radius: 18px;
  overflow: hidden;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #f8fbff, #eef5fc);
  transition: border-color .15s, background .15s;
}
.photo-box:active { border-color: var(--blue); }
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.photo-hint { text-align: center; color: #5f7890; font-size: 12px; padding: 0 8px; }
.photo-hint b { display: block; color: #2c4a66; margin-top: 6px; }
.photo-hint span { font-size: 10px; color: #8296aa; }
.plus { font-size: 34px; color: var(--blue); font-weight: 300; line-height: 1; }
.photo-side { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 9px; }
.muted { color: var(--muted); font-size: 12px; }
.tiny { font-size: 11px; }

/* ============ 按钮 ============ */
.btn {
  border: 1px solid var(--line);
  background: #eef4fb;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 600;
  color: #23415c;
  transition: transform .12s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn.small { padding: 9px 12px; font-size: 12px; }
.btn.primary { border: 0; color: #fff; background: linear-gradient(135deg, var(--blue), var(--blue-deep)); box-shadow: 0 10px 22px rgba(11, 99, 206, .24); }
.btn.big { width: 100%; padding: 15px; border-radius: 15px; font-size: 16px; margin-top: 10px; letter-spacing: .5px; }
.btn:disabled { opacity: .55; }

/* ============ 表单 ============ */
label { display: block; margin-bottom: 14px; color: #38516c; font-size: 13px; font-weight: 600; }
label input, .search-row input, .search-row select {
  width: 100%;
  margin-top: 6px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfdff;
  color: var(--ink);
  outline: none;
  font-weight: 400;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
label input:focus, .search-row input:focus, .search-row select:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(11, 99, 206, .10);
}
.two { display: flex; gap: 12px; }
.two label { flex: 1; min-width: 0; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input { flex: 1; }
.link { border: 0; background: none; color: var(--blue); font-size: 12px; font-weight: 700; white-space: nowrap; padding: 0 2px; }
.field > span { display: block; color: #38516c; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.checks { display: flex; flex-direction: column; gap: 9px; }
.check {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 13px;
  background: #fbfdff;
  font-size: 13px;
  font-weight: 500;
  margin: 0;
}
.check input { width: 18px; height: 18px; accent-color: var(--blue); margin: 0; }
.check.on { border-color: #9cc4ee; background: #f0f7ff; }
.check.disabled { opacity: .5; }

/* ============ 结果 / 记录 ============ */
.result { margin-top: 18px; border-radius: 16px; padding: 15px; background: #f5fcf9; border: 1px solid #bfe8d8; font-size: 13px; }
.result.bad { background: #fff7f7; border-color: #f3caca; }
.result .line { padding: 6px 0; border-top: 1px solid rgba(15, 39, 66, .06); }
.result .line:first-child { border-top: 0; }

.records { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.record { border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: #fff; box-shadow: var(--shadow-sm); }
.record-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.record-name { font-weight: 700; font-size: 15px; }
.record-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.record-actions { display: flex; gap: 14px; margin-top: 10px; }
.app-main { display: flex; gap: 11px; align-items: center; min-width: 0; }
.app-thumb { width: 48px; height: 60px; border-radius: 10px; object-fit: cover; flex: 0 0 48px; background: #eef4fb; }
.record-actions button { border: 1px solid transparent; background: none; color: var(--blue); font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 9px; }
.record-actions .del { color: var(--red); background: #fdeeec; border-color: #f3c4c2; }
.tag { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.tag.ok { background: #e7f7f0; color: var(--green); }
.tag.bad { background: #fdecec; color: var(--red); }
.tag.warn { background: #fff4e3; color: var(--amber); }
.tag.gray { background: #eef1f5; color: #6b7b8d; }
.empty { text-align: center; color: #8296aa; padding: 42px 16px; font-size: 13px; }

.search-row { display: flex; gap: 10px; margin-top: 14px; }
.search-row select { width: 42%; }
.search-row input { flex: 1; }

/* ============ 浮层 ============ */
.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translateX(-50%);
  background: #10283f;
  color: #fff;
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 13px;
  z-index: 80;
  max-width: calc(100% - 32px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .25);
}
.toast.bad { background: #8f2424; }
.busy { position: fixed; inset: 0; background: rgba(245, 249, 253, .85); z-index: 70; display: grid; place-items: center; text-align: center; backdrop-filter: blur(2px); }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid #d9e6f3; border-top-color: var(--blue); animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.busy p { color: #33506b; font-size: 13px; font-weight: 600; }

/* ============ 修改密码弹层 ============ */
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.modal {
  position: fixed; inset: 0; z-index: 75;
  display: grid; place-items: center; padding: 22px;
  background: rgba(13, 32, 54, .5); backdrop-filter: blur(3px);
}
.modal-card {
  width: min(420px, 100%); background: #fff; border-radius: 24px;
  padding: 26px 22px; box-shadow: var(--shadow-md);
}
.modal-card h2 { font-size: 18px; letter-spacing: .5px; }
.modal-card .sub { margin-top: 4px; }
.modal-actions { display: flex; gap: 12px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }
.modal-card .btn.ghost { background: #f2f6fb; color: var(--ink); border: 1px solid var(--line); }

/* ============ 响应式 ============ */
@media (max-width: 380px) {
  .photo-row { gap: 12px; }
  .photo-box { width: 114px; height: 152px; flex-basis: 114px; }
  .tab { font-size: 12px; }
}
@media (max-width: 360px) {
  .two { flex-direction: column; gap: 0; }
}
