/* 后台统一样式 - 14px 基准字号 */
:root {
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Code", Consolas, monospace;
  --bg: #0c1222;
  --surface: #151d32;
  --surface2: #1c2640;
  --border: #2a3655;
  --text: #e8edf7;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --radius: 10px;
  --text-base: 14px;
  --text-sm: 13px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--text-base); }

body {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: #93c5fd; text-decoration: none; }
a:hover { text-decoration: underline; }

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.page-header {
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.page-header .desc {
  margin-top: 6px;
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.5;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: 16px;
  padding: 6px 0;
}
.back-link:hover { color: var(--text); text-decoration: none; }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: var(--text-base);
  line-height: 1.5;
  margin-bottom: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.alert.ok {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
  color: #86efac;
}
.alert.err {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.4;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.form-row .input {
  flex: 1;
  min-width: 160px;
  margin-bottom: 0;
}

.input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.4;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  margin-bottom: 12px;
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 1.4;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, opacity 0.15s;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-warn {
  background: #f59e0b;
  color: #1a1a1a;
  font-weight: 600;
}
.btn-warn:active:not(:disabled) { background: #d97706; }
.btn-warn.active { background: #dc2626; color: #fff; }
.btn-call {
  background: #10b981;
  color: #fff;
  font-weight: 600;
}
.btn-call:hover:not(:disabled) { background: #059669; }
.btn-call.active { background: #ef4444; }
.btn-call.active:hover:not(:disabled) { background: #dc2626; }
.btn-video {
  background: #6366f1;
  color: #fff;
  font-weight: 600;
}
.btn-video:hover:not(:disabled) { background: #4f46e5; }
.btn-video.active { background: #ef4444; }
.btn-video.active:hover:not(:disabled) { background: #dc2626; }
.talk-hint {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: 8px;
}
.btn-ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--border); }
.btn-sm {
  padding: 6px 12px;
  font-size: var(--text-sm);
}

.login-card {
  max-width: 400px;
  margin: 40px auto 0;
  padding: 28px 24px;
}
.login-card .input { margin-bottom: 14px; }
.login-card .btn { width: 100%; }

.hidden { display: none !important; }

/* 表格 */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}
.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}
.data-table th {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
  background: var(--surface2);
}
.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}
.data-table .cell-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.data-table .mono {
  font-family: var(--mono);
  font-size: var(--text-sm);
  color: #cbd5e1;
}
.data-table .cell-name {
  font-size: var(--text-base);
  font-weight: 500;
}

.empty-tip {
  font-size: var(--text-base);
  color: var(--muted);
  line-height: 1.6;
  padding: 8px 0;
}

/* 标签 */
.tag {
  display: inline-block;
  padding: 4px 10px;
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.4;
  border-radius: 20px;
}
.tag-on {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}
.tag-off {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}

/* 设备详情页 */
.device-head {
  margin-bottom: 16px;
}
.device-head h1 {
  font-size: var(--text-xl);
  font-weight: 600;
  margin-bottom: 6px;
}
.device-head .device-id {
  font-family: var(--mono);
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: 10px;
}

.video-box {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  margin-top: 4px;
}
.video-box video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scaleX(-1);
}
.video-box .video-pip.local-pip {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 28%;
  max-width: 180px;
  min-width: 96px;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid #6366f1;
  z-index: 2;
  transform: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
}
.video-ph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  color: var(--muted);
}

.section-gap { margin-bottom: 14px; }
