:root {
  --bg: #0b0f16;
  --bg2: #111826;
  --card: #151e2e;
  --line: #223149;
  --text: #e7eefb;
  --muted: #8fa2c0;
  --accent: #4ea1ff;
  --accent2: #22d3a6;
  --danger: #ff5d6c;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #14233a 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 10%, #102b33 0%, transparent 55%), var(--bg);
  color: var(--text);
  font: 14px/1.5 "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: rgba(10, 15, 24, .72); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: .3px; }
.logo {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 22px rgba(78, 161, 255, .5);
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); font-size: 12px; background: rgba(255, 255, 255, .02);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #e0a33a; }
.pill.ok::before { background: var(--accent2); box-shadow: 0 0 10px var(--accent2); }
.pill.bad::before { background: var(--danger); }

.btn {
  border: 1px solid var(--line); background: rgba(255, 255, 255, .04);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; transition: .15s ease;
}
.btn:hover { border-color: #35507a; background: rgba(78, 161, 255, .12); }
.btn.primary { background: linear-gradient(135deg, #2f7fe0, #4ea1ff); border-color: #4a8fe0; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: #ffc9cf; border-color: #54303a; }
.btn.danger:hover { background: rgba(255, 93, 108, .14); border-color: #7b3b47; }
.btn.small { padding: 5px 9px; font-size: 12px; border-radius: 8px; }

main { max-width: 1440px; margin: 0 auto; padding: 22px; }
.summary { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
  flex: 1 1 170px; min-width: 150px; background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: .5px; }
.stat .v.green { color: var(--accent2); }

.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.empty {
  grid-column: 1 / -1; padding: 70px 20px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.card {
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: .18s ease;
}
.card:hover { border-color: #2f4a70; transform: translateY(-2px); }
.card .thumb { position: relative; aspect-ratio: 16 / 9; background: #05080d; cursor: pointer; }
.card canvas { width: 100%; height: 100%; display: block; object-fit: contain; }
.card .badge {
  position: absolute; left: 10px; top: 10px; display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 8px; font-size: 11px;
  background: rgba(5, 9, 15, .72); border: 1px solid rgba(255, 255, 255, .08);
}
.card .badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.card .badge.online .dot { background: var(--accent2); box-shadow: 0 0 8px var(--accent2); }
.card .noSignal {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #40536f; font-size: 12px; letter-spacing: 1px;
}
.card .body { padding: 12px 14px; }
.card .title { font-weight: 650; display: flex; justify-content: space-between; gap: 8px; }
.card .title .id { color: var(--muted); font-size: 11px; font-family: ui-monospace, Consolas, monospace; }
.card .meta { color: var(--muted); font-size: 12px; margin-top: 6px; display: grid; gap: 2px; }
.card .actions { display: flex; gap: 8px; margin-top: 12px; }

.viewer {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  background: #05080d; padding: 0;
}
.viewer-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: #0b1220;
  flex-wrap: wrap;
}
.viewer-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ctl { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.ctl input[type=range] { width: 110px; accent-color: var(--accent); }
.screen-wrap { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; }
#screen {
  max-width: 100%; max-height: 100%; outline: none; cursor: crosshair;
  background: #000; image-rendering: auto; box-shadow: 0 0 60px rgba(0,0,0,.7);
}
.v-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #9fb3d1; background: rgba(5, 8, 13, .55); backdrop-filter: blur(2px);
  font-size: 15px; letter-spacing: .5px; pointer-events: none;
}
.viewer-foot {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-top: 1px solid var(--line); background: #0b1220; flex-wrap: wrap;
}
.viewer-foot input[type=text] {
  flex: 1 1 200px; min-width: 160px; padding: 8px 10px; border-radius: 9px;
  border: 1px solid var(--line); background: #0e1625;
}
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.meta-line { display: flex; gap: 16px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }

.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(4, 7, 12, .66); backdrop-filter: blur(4px); }
.modal .box {
  width: min(520px, 92vw); background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); padding: 22px;
}
.modal h3 { margin: 0 0 6px; font-size: 17px; }
.modal p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.modal label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; }
.modal input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #0e1625;
}
.modal .row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login {
  width: min(380px, 92vw); background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: var(--shadow);
}
.login h1 { font-size: 20px; margin: 10px 0 4px; }
.login p { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.login input { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: #0e1625; }
.login .btn { width: 100%; margin-top: 14px; padding: 11px; }
.error { color: #ff8c97; font-size: 13px; min-height: 18px; margin-top: 10px; }

.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  background: #101a2b; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; box-shadow: var(--shadow); font-size: 13px;
}
@media (max-width: 720px) {
  .topbar { padding: 12px; }
  main { padding: 14px; }
  .viewer-head { padding: 8px 10px; }
  .screen-wrap { padding: 4px; }
}
