:root {
  --bg: #f0f6fd;
  --card: #ffffff;
  --ink: #16233a;
  --muted: #7a8aa0;
  --line: #e3edf9;
  --primary: #2e6be6;
  --primary-2: #5b8df7;
  --primary-soft: #eaf1ff;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #e5484d;
  --radius: 18px;
  --shadow: 0 12px 32px rgba(26, 62, 122, 0.07);
  --shadow-sm: 0 4px 14px rgba(26, 62, 122, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 12% -10%, #dbeafe 0%, transparent 60%),
    radial-gradient(700px 500px at 100% 110%, #e0ecff 0%, transparent 55%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 26px;
  padding: 40px 36px 32px;
  box-shadow: 0 30px 70px rgba(25, 60, 120, 0.14);
  backdrop-filter: blur(12px);
  text-align: center;
}

.login-card h1 { font-size: 26px; letter-spacing: 0.5px; margin-top: 16px; }
.login-card > .muted { margin: 8px 0 26px; font-size: 13px; }
.login-card label { display: block; text-align: left; margin-bottom: 16px; }
.login-card label span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; }

input[type="text"], input[type="password"], input[type="number"], input[type="url"], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #f7faff;
  border-radius: 12px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
input:focus, select:focus, textarea:focus {
  border-color: #b9d1ff;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(46, 107, 230, 0.1);
}

.login-card .btn { margin-top: 8px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 12px; }

.brand-mark {
  width: 54px;
  height: 54px;
  margin: 0 auto;
  border-radius: 16px;
  background: linear-gradient(145deg, #2e6be6, #7aa8ff);
  color: #fff;
  font-weight: 800;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 26px rgba(46, 107, 230, 0.3);
}
.brand-mark.small { width: 40px; height: 40px; font-size: 20px; border-radius: 12px; margin: 0; box-shadow: none; }

/* ---------- 结构 ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 244px;
  flex: 0 0 244px;
  background: rgba(255, 255, 255, 0.78);
  border-right: 1px solid rgba(227, 237, 249, 0.9);
  padding: 26px 18px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.brand-text strong { display: block; font-size: 15px; letter-spacing: 0.3px; }
.brand-text span { font-size: 11px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: #4a5a72;
  padding: 11px 14px;
  border-radius: 12px;
  text-align: left;
  font-size: 14px;
  transition: background 0.16s, color 0.16s;
}
.nav-item svg { width: 18px; height: 18px; fill: currentColor; opacity: 0.72; }
.nav-item:hover { background: #f4f8ff; }
.nav-item.active {
  background: linear-gradient(120deg, #eaf1ff, #f4f9ff);
  color: var(--primary);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 16px 8px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.sidebar-foot .link { margin-left: auto; border: 0; background: none; color: var(--primary); padding: 4px; }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: #c8d4e4; }
.dot.online { background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14); }
.dot.offline { background: #c3cede; }

.main { flex: 1; min-width: 0; padding: 30px 36px 60px; }

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.topbar h2 { font-size: 24px; letter-spacing: 0.4px; }
.topbar .muted { margin-top: 6px; font-size: 13px; }
.top-actions { display: flex; gap: 10px; align-items: center; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid transparent;
  background: #fff;
  border-radius: 11px;
  padding: 9px 16px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: transform 0.12s, box-shadow 0.18s, background 0.18s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, #2e6be6, #5b8df7);
  color: #fff;
  box-shadow: 0 10px 20px rgba(46, 107, 230, 0.22);
}
.btn.primary:hover { box-shadow: 0 12px 26px rgba(46, 107, 230, 0.3); }
.btn.ghost { border-color: var(--line); color: #3d4d66; }
.btn.ghost:hover { background: #f6faff; }
.btn.danger { background: #fdf1f1; color: var(--danger); }
.btn.small { padding: 6px 11px; font-size: 12px; border-radius: 9px; }
.btn.block { width: 100%; padding: 12px; font-size: 14px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid rgba(227, 237, 249, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.card-head h3 { font-size: 15px; }
.card-head .muted { font-size: 12px; margin-top: 4px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { display: flex; align-items: center; gap: 16px; }
.stat-icon {
  width: 46px; height: 46px; border-radius: 14px;
  background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
}
.stat-icon svg { width: 22px; height: 22px; fill: currentColor; }
.stat .num { font-size: 26px; font-weight: 700; letter-spacing: 0.5px; }
.stat .label { color: var(--muted); font-size: 12px; margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; align-items: start; }

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 4px;
  border-bottom: 1px solid #f1f6fd;
}
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item strong { font-size: 13.5px; font-weight: 600; display: block; }
.list-item small { color: var(--muted); font-size: 12px; }

.empty {
  padding: 40px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.9;
}

/* ---------- 应用列表 ---------- */
.app-list { display: flex; flex-direction: column; gap: 12px; }
.app-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid #eef4fd;
  border-radius: 15px;
  background: #fbfdff;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.app-row:hover { border-color: #dbe8fb; box-shadow: var(--shadow-sm); }
.app-icon {
  width: 52px; height: 52px; border-radius: 14px; overflow: hidden;
  background: linear-gradient(145deg, #e9f1ff, #dce9ff);
  display: flex; align-items: center; justify-content: center;
  color: #6b8fe0; font-weight: 700; font-size: 20px; flex: none;
}
.app-icon img { width: 100%; height: 100%; object-fit: cover; }
.app-meta { flex: 1; min-width: 0; }
.app-meta .title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.app-meta .sub { color: var(--muted); font-size: 12px; margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  background: #eef4ff; color: #4a74c9; font-size: 11px; font-weight: 500;
}
.badge.gray { background: #f1f4f8; color: #8291a6; }
.badge.green { background: #ecfdf3; color: #15803d; }
.badge.amber { background: #fff7e6; color: #b45309; }
.app-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- 开关 ---------- */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 42px; height: 24px; border-radius: 999px;
  background: #d7e3f4; position: relative; transition: background 0.2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(20, 50, 100, 0.25);
  transition: transform 0.2s;
}
.switch input:checked + .track { background: linear-gradient(135deg, #2e6be6, #5b8df7); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch .txt { font-size: 13px; color: #42536c; }

/* ---------- 素材 ---------- */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}
.media-card {
  border: 1px solid #eef4fd;
  border-radius: 16px;
  overflow: hidden;
  background: #fbfdff;
  display: flex;
  flex-direction: column;
}
.media-thumb { position: relative; aspect-ratio: 16 / 9; background: #e8f0fb; overflow: hidden; }
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-thumb .tag {
  position: absolute; left: 8px; top: 8px;
  background: rgba(12, 22, 40, 0.62); color: #fff;
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  backdrop-filter: blur(6px);
}
.media-body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 9px; }
.media-body .name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-body .meta { font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.media-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.active-wallpaper { display: flex; gap: 20px; align-items: center; }
.active-wallpaper .preview {
  width: 260px; aspect-ratio: 16/9; border-radius: 14px; overflow: hidden;
  background: #e8f0fb; flex: none; border: 1px solid #e6effb;
}
.active-wallpaper .preview img, .active-wallpaper .preview video { width: 100%; height: 100%; object-fit: cover; }
.active-wallpaper .info { flex: 1; min-width: 0; }
.active-wallpaper .info h4 { font-size: 14px; margin-bottom: 6px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 720px; }
.table th {
  text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 500;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 13px 12px; border-bottom: 1px solid #f2f7fd; font-size: 13px; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fbfdff; }
.device-name { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.td-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.field .hint { font-size: 11.5px; color: #9aa9bd; margin-top: 6px; }
.file-box {
  border: 1px dashed #cfe0f7; background: #f8fbff; border-radius: 12px;
  padding: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.file-box input[type="file"] { font-size: 12px; color: var(--muted); max-width: 100%; }

/* ---------- 弹窗 ---------- */
.modal-root:empty { display: none; }
.modal-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(12, 28, 55, 0.42);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade 0.16s ease;
}
.modal {
  width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  background: #fff; border-radius: 22px;
  box-shadow: 0 40px 90px rgba(12, 35, 80, 0.3);
  padding: 26px;
  animation: pop 0.18s ease;
}
.modal.wide { max-width: 720px; }
.modal h3 { font-size: 17px; margin-bottom: 6px; }
.modal .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: translateY(10px) scale(0.985); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 20px);
  background: rgba(15, 30, 55, 0.94); color: #fff;
  padding: 11px 20px; border-radius: 12px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all 0.22s ease; z-index: 90;
  box-shadow: 0 18px 40px rgba(10, 25, 50, 0.28);
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: rgba(150, 32, 38, 0.95); }

.qr-box { background: #f7faff; border: 1px solid #e8f1fc; border-radius: 16px; padding: 14px; text-align: center; }
.qr-box img { width: 170px; height: 170px; border-radius: 10px; background: #fff; }
.qr-box p { font-size: 12px; color: var(--muted); margin-top: 8px; word-break: break-all; }

.tip {
  background: #f4f9ff; border: 1px solid #e3eefd; color: #4c6285;
  border-radius: 12px; padding: 11px 14px; font-size: 12.5px; line-height: 1.75;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { width: 76px; flex: 0 0 76px; padding: 20px 10px; }
  .brand { padding: 0 4px 20px; justify-content: center; }
  .brand-text { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .nav-item span { display: none; }
  .sidebar-foot span:not(.dot), .sidebar-foot .link { display: none; }
  .main { padding: 22px 18px 50px; }
  .topbar { flex-direction: column; align-items: flex-start; }
}
