:root {
  --bg-deep:   #050e1f;
  --bg-card:   #0d1b2e;
  --bg-input:  #0a1628;
  --bg-hover:  #112240;
  --accent:    #6366f1;
  --accent2:   #00e5ff;
  --border:    #1e3a5f;
  --text:      #e2e8f0;
  --text-muted:#7a9cbf;
  --success:   #22c55e;
  --error:     #ef4444;
  --warning:   #f59e0b;
  --online:    #22c55e;
  --offline:   #64748b;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: .75rem; }
.logo-text { font-size: 1.1rem; font-weight: 700; color: var(--accent2); }
.role-tag {
  background: rgba(99,102,241,.15); color: var(--accent);
  border: 1px solid rgba(99,102,241,.3);
  padding: .2rem .6rem; border-radius: 20px; font-size: .75rem;
}
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.user-badge { color: var(--text-muted); font-size: .9rem; }

/* 布局 */
.app-layout { display: flex; height: calc(100vh - 56px); }

.sidebar {
  width: 200px; min-width: 200px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
}
.sidebar-nav { display: flex; flex-direction: column; gap: .25rem; padding: 0 .75rem; }
.nav-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem .9rem; border-radius: 8px;
  cursor: pointer; color: var(--text-muted);
  transition: all .2s; font-size: .9rem;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: rgba(99,102,241,.15); color: var(--accent); }
.nav-icon { font-size: 1rem; }

.main-content {
  flex: 1; overflow-y: auto; padding: 1.5rem;
}

/* 视图 */
.view { display: none; }
.view.active { display: block; }

/* 卡片 */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

/* 按钮 */
.btn-ghost {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); padding: .45rem .9rem;
  border-radius: 8px; cursor: pointer; font-size: .85rem;
  transition: all .2s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-primary {
  background: var(--accent); color: #fff; border: none;
  padding: .5rem 1.1rem; border-radius: 8px;
  cursor: pointer; font-size: .85rem; font-weight: 600;
  transition: opacity .2s;
}
.btn-primary:hover { opacity: .85; }

.btn-danger {
  background: var(--error); color: #fff; border: none;
  padding: .5rem 1.1rem; border-radius: 8px;
  cursor: pointer; font-size: .85rem; font-weight: 600;
  transition: opacity .2s;
}
.btn-danger:hover { opacity: .85; }

.btn-success {
  background: var(--success); color: #fff; border: none;
  padding: .5rem 1.1rem; border-radius: 8px;
  cursor: pointer; font-size: .85rem; font-weight: 600;
  transition: opacity .2s;
}
.btn-success:hover { opacity: .85; }

.btn-warning {
  background: var(--warning); color: #fff; border: none;
  padding: .5rem 1.1rem; border-radius: 8px;
  cursor: pointer; font-size: .85rem; font-weight: 600;
  transition: opacity .2s;
}
.btn-warning:hover { opacity: .85; }

/* 表格 */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  padding: .75rem 1rem; text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
}
.data-table th { color: var(--text-muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table td.empty { text-align: center; color: var(--text-muted); padding: 2rem; }

/* 在线状态点 */
.dot-online { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--online); margin-right: 5px; }
.dot-offline { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--offline); margin-right: 5px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 480px; max-width: 95vw;
  max-height: 90vh; overflow-y: auto;
}
.modal-box-sm { width: 360px; }
.modal-box-lg { width: 600px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 1rem;
}
.modal-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1.1rem; padding: .2rem;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.25rem 1.5rem; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: .75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}
.modal-error {
  color: var(--error); font-size: .85rem;
  margin-top: .5rem; padding: .5rem;
  background: rgba(239,68,68,.1); border-radius: 6px;
}
.modal-warn { color: var(--warning); font-size: .85rem; margin-top: .5rem; }

/* 表单 */
.form-row { margin-bottom: 1rem; }
.form-row label { display: block; font-size: .83rem; color: var(--text-muted); margin-bottom: .35rem; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: .65rem .9rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: .9rem;
  outline: none; transition: border-color .2s;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  border-color: var(--accent);
}
.form-row textarea { resize: vertical; min-height: 80px; }

/* Toast */
.toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
  background: #1e293b; border: 1px solid var(--border);
  color: var(--text); padding: .75rem 1.5rem;
  border-radius: 10px; font-size: .9rem;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  z-index: 9999; pointer-events: none;
  animation: fadeInUp .3s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* 统计卡片 */
.stats-cards { display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.stat-card {
  flex: 1; min-width: 140px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 1.25rem;
}
.stat-card .stat-label { color: var(--text-muted); font-size: .8rem; margin-bottom: .4rem; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; color: var(--accent2); }

/* 页头 */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.page-header h2 { font-size: 1.1rem; font-weight: 600; }

/* 徽章 */
.badge {
  display: inline-block; padding: .2rem .55rem;
  border-radius: 20px; font-size: .75rem; font-weight: 600;
}
.badge-online  { background: rgba(34,197,94,.15);  color: var(--online); }
.badge-offline { background: rgba(100,116,139,.15); color: var(--offline); }
.badge-locked  { background: rgba(239,68,68,.15);   color: var(--error); }

/* 标签列表 */
.tag-list { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.tag {
  display: flex; align-items: center; gap: .3rem;
  background: rgba(99,102,241,.12); border: 1px solid rgba(99,102,241,.25);
  color: var(--accent); padding: .25rem .6rem; border-radius: 20px; font-size: .8rem;
}
.tag-del {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: .9rem; line-height: 1; padding: 0;
}
.tag-del:hover { color: var(--error); }
.tag-input-row { display: flex; gap: .5rem; margin-top: .5rem; }
.tag-input-row input {
  flex: 1; padding: .5rem .75rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: .85rem; outline: none;
}
.tag-input-row input:focus { border-color: var(--accent); }
.tag-input-row button {
  background: var(--accent); color: #fff; border: none;
  padding: .5rem .9rem; border-radius: 8px; cursor: pointer; font-size: .85rem;
}

/* 搜索框 */
.search-input {
  padding: .55rem .9rem;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: .88rem; outline: none;
  width: 220px; transition: border-color .2s;
}
.search-input:focus { border-color: var(--accent); }

/* 时间滑块 */
.range-row { display: flex; align-items: center; gap: .75rem; }
.range-row input[type=range] { flex: 1; accent-color: var(--accent); }
.range-val { min-width: 60px; text-align: right; color: var(--accent2); font-weight: 600; }

/* 设备卡片网格 */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.device-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 1.25rem;
  transition: border-color .2s;
}
.device-card:hover { border-color: var(--accent); }
.device-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.device-card-name { font-weight: 600; font-size: 1rem; }
.device-card-child { color: var(--text-muted); font-size: .85rem; margin-bottom: .75rem; }
.device-card-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.device-card-actions button { font-size: .8rem; padding: .35rem .75rem; }
.battery-bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: .5rem; }
.battery-fill { height: 100%; border-radius: 2px; background: var(--success); transition: width .3s; }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 1rem; }
  .stats-cards { flex-direction: column; }
}
