:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #059669;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); min-height: 100%;
}
a { color: var(--primary); text-decoration: none; }
.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
.header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.header h1 { margin: 0; font-size: 1.45rem; font-weight: 700; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: #ecfdf5; color: var(--success); border: 1px solid #a7f3d0;
  padding: 4px 10px; border-radius: 999px; font-size: .85rem; font-weight: 600;
}
.badge.offline { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border); padding: 18px 18px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 14px; font-size: 1.05rem; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }
.btn {
  appearance: none; border: none; cursor: pointer;
  background: var(--primary); color: #fff; border-radius: 8px;
  padding: 8px 14px; font-size: .9rem; font-weight: 600;
  transition: background .15s;
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: #f9fafb; }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.sm { padding: 5px 10px; font-size: .8rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
input[type=text], input[type=password], input[type=number], input[type=color], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: .92rem; background: #fff; color: var(--text);
}
textarea { min-height: 72px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 4px; }
.form-row { margin-bottom: 12px; }
.form-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card { width: 100%; max-width: 400px; }
.login-card h1 { text-align: center; margin-bottom: 8px; }
.login-card p.sub { text-align: center; color: var(--muted); margin-top: 0; margin-bottom: 20px; }
.scheme-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px;
  background: #fafafa;
}
.color-dot {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.08); box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);
}
.scheme-meta { flex: 1; min-width: 0; }
.scheme-meta .name { font-weight: 700; margin-bottom: 4px; }
.scheme-meta .url {
  font-size: .75rem; color: var(--muted); word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.toggles { display: flex; gap: 12px; margin: 8px 0; flex-wrap: wrap; font-size: .85rem; }
.toggles label { display: inline-flex; align-items: center; gap: 6px; color: var(--text); margin: 0; cursor: pointer; }
.device-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .9rem;
}
.device-item:last-child { border-bottom: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.on { background: var(--success); }
.dot.off { background: #9ca3af; }
.muted { color: var(--muted); font-size: .85rem; }
.toast {
  position: fixed; top: 16px; right: 16px; z-index: 99;
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px;
  opacity: 0; transform: translateY(-8px); transition: .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.overlay-preview {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0;
}
.overlay-chip {
  color: #fff; font-weight: 700; font-size: .85rem;
  padding: 10px 14px; border-radius: 10px; min-width: 88px; text-align: center;
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.hint-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: .88rem; line-height: 1.6; }
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none;
  align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 12px; padding: 20px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.modal h3 { margin-top: 0; }

.pin-box {
  text-align: center; padding: 16px; background: #111827; color: #fff;
  border-radius: 12px; margin-top: 8px;
}
.pin-code {
  font-size: 2.4rem; font-weight: 800; letter-spacing: 0.35em;
  font-variant-numeric: tabular-nums; margin-bottom: 6px;
}
.device-item label.dev-check {
  display: flex; align-items: flex-start; gap: 10px; flex: 1; cursor: pointer; margin: 0; color: var(--text);
}
.device-item input[type=checkbox] { margin-top: 4px; width: auto; }
.device-name { font-size: 1.02rem; font-weight: 700; }
.tag-app {
  display: inline-block; font-size: .7rem; background: #ecfdf5; color: var(--success);
  border: 1px solid #a7f3d0; border-radius: 999px; padding: 1px 7px; margin-left: 6px; font-weight: 600;
}

.device-item.is-offline { opacity: 0.78; }
.device-item.is-offline input[type=checkbox]:disabled { cursor: not-allowed; }
