:root {
  --bg: #0b0d10;
  --panel: #12151a;
  --panel-2: #171b22;
  --panel-3: #1d222b;
  --border: #232833;
  --border-2: #2d3440;
  --text: #e6e9ef;
  --text-2: #a7afbd;
  --muted: #757e8e;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, .12);
  --ok: #35c88a;
  --warn: #f0a84c;
  --err: #f2637b;
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2b323d; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #3a4350; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- layout ---------------- */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 218px;
  flex: 0 0 218px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 20px; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(140deg, #4f8cff, #7b5cff);
  display: grid; place-items: center; flex: 0 0 30px;
}
.brand .logo svg { width: 17px; height: 17px; }
.brand .txt b { display: block; font-size: 14px; letter-spacing: .3px; }
.brand .txt span { font-size: 11px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav a svg { width: 16px; height: 16px; opacity: .8; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: #cfe0ff; }
.nav a.active svg { opacity: 1; color: var(--accent); }

.side-foot { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid var(--border); }
.status-line { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: 0 0 7px; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(53, 200, 138, .16); }
.dot.off { background: var(--err); box-shadow: 0 0 0 3px rgba(242, 99, 123, .14); }
.side-foot .addr { font-size: 11px; color: #5c6472; margin-top: 6px; word-break: break-all; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 58px; flex: 0 0 58px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; border-bottom: 1px solid var(--border); background: rgba(18, 21, 26, .78);
  backdrop-filter: blur(10px);
}
.topbar h1 { font-size: 16px; font-weight: 600; letter-spacing: .2px; }
.topbar .sub { font-size: 12px; color: var(--muted); margin-left: 10px; }
.topbar .actions { display: flex; gap: 8px; align-items: center; }

.content { flex: 1; overflow-y: auto; padding: 22px 24px 40px; }

/* ---------------- common ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 13px; border-radius: var(--radius-sm);
  background: var(--panel-3); color: var(--text); border: 1px solid var(--border-2);
  font-size: 13px; cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn:hover { background: #232a35; border-color: #3a4350; }
.btn svg { width: 14px; height: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #639af8; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn.ghost:hover { color: var(--text); border-color: var(--border-2); }
.btn.danger { color: #ffb3c0; border-color: rgba(242, 99, 123, .35); background: rgba(242, 99, 123, .1); }
.btn.danger:hover { background: rgba(242, 99, 123, .18); }
.btn.sm { height: 27px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* 视图切换（原图 / 裁剪图）：一段式按钮组 */
.seg {
  display: inline-flex; align-items: center; gap: 2px; padding: 2px;
  height: 32px; border-radius: var(--radius-sm);
  background: var(--panel-3); border: 1px solid var(--border-2);
}
.seg-btn {
  height: 26px; padding: 0 11px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-2); font-size: 12.5px;
  cursor: pointer; transition: .15s; white-space: nowrap;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--accent); color: #fff; }

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

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 13.5px; font-weight: 600; }
.card-head .hint { font-size: 12px; color: var(--muted); }

.grid { display: grid; gap: 14px; }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.c5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1180px) { .grid.c4, .grid.c5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .grid.c3, .grid.c2 { grid-template-columns: 1fr; } }

.stat { padding: 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--border); }
.stat .label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 26px; font-weight: 600; margin-top: 8px; letter-spacing: .5px; }
.stat .value small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.stat .foot { font-size: 12px; color: var(--muted); margin-top: 4px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11.5px;
  background: var(--panel-3); color: var(--text-2); border: 1px solid var(--border-2);
}
.tag.ok { color: #8fe7c0; background: rgba(53, 200, 138, .12); border-color: rgba(53, 200, 138, .28); }
.tag.warn { color: #ffd79a; background: rgba(240, 168, 76, .12); border-color: rgba(240, 168, 76, .28); }
.tag.err { color: #ffb0bd; background: rgba(242, 99, 123, .12); border-color: rgba(242, 99, 123, .28); }
.tag.blue { color: #b7d0ff; background: var(--accent-soft); border-color: rgba(79, 140, 255, .3); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid #1a1f27; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, .015); }
.mono { font-family: "SF Mono", ui-monospace, Consolas, "Courier New", monospace; font-size: 12px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.empty { padding: 44px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.empty svg { width: 30px; height: 30px; opacity: .35; margin-bottom: 10px; display: block; margin-inline: auto; }

input, select, textarea {
  width: 100%; background: #0e1116; color: var(--text);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 13px; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 140, 255, .13);
}
textarea { resize: vertical; min-height: 74px; line-height: 1.6; }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 5px; }
label.field .tip { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
label.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
label.check input { width: auto; }

.switch { position: relative; display: inline-block; width: 34px; height: 19px; flex: 0 0 34px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute; inset: 0; background: #2b323d; border-radius: 20px;
  transition: .18s; cursor: pointer;
}
.switch i::before {
  content: ""; position: absolute; width: 13px; height: 13px; left: 3px; top: 3px;
  background: #98a1b0; border-radius: 50%; transition: .18s;
}
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::before { transform: translateX(15px); background: #fff; }

/* ---------------- group cards ---------------- */
.group-card { overflow: hidden; }
.group-card .gc-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.group-card .gc-title { min-width: 0; }
.group-card .gc-title b { font-size: 14px; font-weight: 600; }
.group-card .gc-title div { font-size: 12px; color: var(--muted); margin-top: 2px; }
.group-card .gc-body { padding: 0 16px 14px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------------- task grid ---------------- */
.task-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; }
.task-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: .16s;
}
.task-card:hover { border-color: #3a4350; transform: translateY(-2px); }
.task-card .cover {
  height: 132px; background: #0e1116 center/cover no-repeat;
  display: grid; place-items: center; color: #3d4654; font-size: 12px;
}
.task-card .body { padding: 10px 12px 12px; }
.task-card .row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.task-card .row1 b { font-size: 13px; font-weight: 600; }
.task-card .meta { font-size: 11.5px; color: var(--muted); margin-top: 5px; display: flex; gap: 8px; }

/* ---------------- device gallery ---------------- */
.dev-block { margin-bottom: 22px; }
.dev-block .dev-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.dev-block .dev-head b { font-size: 13.5px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 9px; }
.thumb {
  position: relative; padding-top: 62%; border-radius: 9px; overflow: hidden;
  background: #0e1116 center/cover no-repeat; cursor: zoom-in;
  border: 1px solid var(--border);
}
.thumb:hover { border-color: var(--accent); }
.thumb .idx {
  position: absolute; left: 6px; bottom: 6px; font-size: 10.5px;
  background: rgba(0, 0, 0, .62); color: #d7dde8; padding: 1px 6px; border-radius: 4px;
  font-family: ui-monospace, monospace;
}

/* ---------------- modal ---------------- */
.mask {
  position: fixed; inset: 0; background: rgba(4, 6, 9, .68); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.mask.show { display: flex; }
.modal {
  width: min(620px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
}
.modal.wide { width: min(880px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--panel); z-index: 2;
}
.modal-head h3 { font-size: 14.5px; font-weight: 600; }
.modal-head .x { cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; }
.modal-head .x:hover { color: var(--text); }
.modal-body { padding: 18px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 9px; padding: 13px 18px;
  border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--panel);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row.c3 { grid-template-columns: repeat(3, 1fr); }

/* ---------------- lightbox ---------------- */
.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .9); z-index: 90;
  display: none; align-items: center; justify-content: center; flex-direction: column; gap: 12px;
}
.lightbox.show { display: flex; }
.lightbox img { max-width: 92vw; max-height: 82vh; border-radius: 8px; box-shadow: 0 20px 60px #000; }
.lightbox .lb-bar { display: flex; gap: 10px; align-items: center; color: var(--text-2); font-size: 12.5px; }
.lightbox .lb-close { position: absolute; top: 22px; right: 26px; font-size: 28px; color: #8c94a3; cursor: pointer; }

/* ---------------- toast ---------------- */
.toast-wrap { position: fixed; top: 16px; right: 16px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 200px; max-width: 380px; padding: 10px 14px; border-radius: 9px;
  background: #1b212a; border: 1px solid var(--border-2); color: var(--text); font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: slide .2s ease;
}
.toast.ok { border-color: rgba(53, 200, 138, .4); }
.toast.err { border-color: rgba(242, 99, 123, .45); }
@keyframes slide { from { opacity: 0; transform: translateX(14px); } }

.spinner {
  width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .25);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sec-title { font-size: 12px; color: var(--muted); margin: 22px 0 10px; letter-spacing: .4px; }
.sec-title:first-child { margin-top: 0; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 18px 0 12px; }
.sub-h { font-size: 13px; font-weight: 600; color: var(--text-1); margin: 4px 0 10px; }
.kv { display: flex; justify-content: space-between; padding: 7px 0; font-size: 13px; }
.kv span:first-child { color: var(--muted); }
.code-box {
  background: #0d1015; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-family: ui-monospace, Consolas, monospace; font-size: 12px;
  color: #9fb4d8; white-space: pre-wrap; word-break: break-all; line-height: 1.7;
}
