/* ==============================================
   华禹智控 - Mobile Web App
   工业科技风 · 深色主题 · v1.0
   ============================================== */

:root {
  --bg-primary: #0A1628;
  --bg-secondary: #0F1F36;
  --bg-card: #152238;
  --bg-card-hover: #1A2A4A;
  --accent-blue: #1E90FF;
  --accent-blue-dim: #1565C0;
  --accent-cyan: #00BCD4;
  --success: #00E676;
  --danger: #FF1744;
  --warning: #FF9100;
  --info: #448AFF;
  
  --text-primary: #E0E8F0;
  --text-secondary: #8AA0B8;
  --text-dim: #5A7A9A;
  --border: #1E3050;
  
  --gradient-bg: linear-gradient(180deg, #0A1628 0%, #0F1F36 50%, #0A1628 100%);
  --gradient-blue: linear-gradient(135deg, #1E90FF, #00BCD4);
  --gradient-card: linear-gradient(135deg, #152238, #1A2A4A);
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.3);
  
  --nav-height: 64px;
  --status-height: 24px;
  --font-mono: 'JetBrains Mono', 'Menlo', 'Consolas', 'Courier New', monospace;
  --font-cn: -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: var(--font-cn);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--gradient-bg);
  overflow: hidden;
}

/* ========== PAGES ========== */
.page {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(var(--nav-height) + 12px);
  display: none;
  -webkit-overflow-scrolling: touch;
}
.page.active {
  display: block;
}
.page::-webkit-scrollbar {
  width: 2px;
}
.page::-webkit-scrollbar-track {
  background: transparent;
}
.page::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ========== STATUS BAR ========== */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}
.status-icons {
  display: flex;
  gap: 6px;
  font-size: 11px;
}

/* ========== HEADER ========== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px 14px;
}
.back-header {
  padding: 8px 12px 14px;
}
.logo {
  flex: 1;
}
.logo-dot {
  display: none;
}
.env {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 400;
  margin-right: 4px;
}
.page-header h1 {
  font-size: 18px;
  font-weight: 600;
}
.page-title-ellipsis {
  flex: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 8px;
  font-size: 15px !important;
  color: var(--text-primary);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}
.icon-btn:active {
  color: var(--accent-blue);
}
.add-project-btn {
  background: var(--gradient-blue);
  border: none;
  border-radius: 16px;
  color: #fff;
  font-family: var(--font-cn);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 8px 12px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(30, 144, 255, 0.24);
  white-space: nowrap;
}
.add-project-btn:active {
  transform: scale(0.97);
}

/* ========== ADD PROJECT MODAL ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 10, 22, 0.68);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-overlay.closing {
  opacity: 0;
  transition: opacity .18s ease;
}
.add-project-modal {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  animation: modalPop .2s ease;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}
.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(138, 160, 184, 0.12);
  color: var(--text-secondary);
  font-size: 22px;
  line-height: 26px;
  cursor: pointer;
}
.modal-body {
  padding: 16px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.form-field span {
  color: var(--text-secondary);
  font-size: 12px;
}
.form-field input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-cn);
  font-size: 14px;
  outline: none;
  padding: 11px 12px;
}
.form-field input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(30, 144, 255, 0.12);
}
.modal-actions {
  display: flex;
  gap: 10px;
  padding: 14px 18px 18px;
}
.modal-btn {
  flex: 1;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-cn);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 12px;
  cursor: pointer;
}
.modal-btn.secondary {
  background: rgba(138, 160, 184, 0.12);
  color: var(--text-secondary);
}
.modal-btn.primary {
  background: var(--gradient-blue);
  color: #fff;
}
@keyframes modalPop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ========== STATS GRID ========== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px 12px;
}
.stat-card {
  background: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  border-radius: 0 2px 2px 0;
}
.stat-project::before { background: var(--accent-blue); }
.stat-box::before { background: var(--success); }
.stat-alert::before { background: var(--danger); }

.stat-card:last-child {
  grid-column: 1 / -1;
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.stat-project .stat-icon { background: rgba(30, 144, 255, 0.15); color: var(--accent-blue); }
.stat-box .stat-icon { background: rgba(0, 230, 118, 0.15); color: var(--success); }
.stat-alert .stat-icon { background: rgba(255, 23, 68, 0.15); color: var(--danger); }

.stat-info {
  flex: 1;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
}
.stat-project .stat-value { color: var(--accent-blue); }
.stat-box .stat-value { color: var(--success); }
.stat-alert .stat-value { color: var(--danger); }
.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.stat-percent {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--success);
  padding: 2px 8px;
  background: rgba(0, 230, 118, 0.1);
  border-radius: 20px;
  white-space: nowrap;
}
.stat-percent.small {
  color: var(--text-dim);
  background: rgba(90, 122, 154, 0.1);
}

/* ========== SECTIONS ========== */
.section {
  padding: 12px 16px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.section-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-header h2 i {
  color: var(--accent-blue);
  font-size: 14px;
}
.section-more {
  color: var(--text-dim);
  cursor: pointer;
}

/* ========== DEVICE PREVIEW ========== */
.device-preview-list {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.device-preview-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.2s;
}
.device-preview-item:active {
  background: var(--bg-card-hover);
}
.device-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.device-status-dot.online {
  background: var(--success);
  box-shadow: 0 0 6px rgba(0, 230, 118, 0.5);
}
.device-status-dot.warning {
  background: var(--warning);
  box-shadow: 0 0 6px rgba(255, 145, 0, 0.5);
}
.device-status-dot.offline {
  background: var(--text-dim);
}
.device-preview-info {
  flex: 1;
  min-width: 0;
}
.device-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.device-tag {
  font-size: 11px;
  color: var(--success);
  margin-top: 2px;
}
.device-id-tag {
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.empty-state {
  padding: 18px 14px;
  text-align: center;
  color: var(--text-dim);
  background: rgba(21, 34, 56, 0.72);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* ========== AI ASSISTANT ========== */
.ai-scope-card {
  margin: 0 16px 12px;
  padding: 0;
  background: transparent;
  border: none;
}
.ai-service-status {
  display: inline-flex;
  margin-top: 0;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(138,160,184,0.12);
  color: var(--text-secondary);
  font-size: 11px;
}
.ai-service-status.ok {
  background: rgba(0,230,118,0.12);
  color: var(--success);
}
.ai-service-status.warn {
  background: rgba(255,145,0,0.12);
  color: var(--warning);
}
.ai-chat-list {
  height: calc(100vh - var(--nav-height) - 128px);
  min-height: 390px;
  overflow-y: auto;
  padding: 4px 16px 88px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ai-msg {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  width: 100%;
}
.ai-msg-user {
  flex-direction: row-reverse;
}
.ai-avatar {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--gradient-blue);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}
.ai-msg-user .ai-avatar {
  background: rgba(138,160,184,0.22);
  color: var(--text-primary);
}
.ai-bubble {
  max-width: 78%;
  position: relative;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-line;
}
.ai-msg-user .ai-bubble {
  background: #1E90FF;
  border-color: #1E90FF;
  color: #fff;
}
.ai-msg-assistant .ai-bubble::before,
.ai-msg-user .ai-bubble::before {
  content: '';
  position: absolute;
  top: 11px;
  width: 8px;
  height: 8px;
  transform: rotate(45deg);
}
.ai-msg-assistant .ai-bubble::before {
  left: -5px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.ai-msg-user .ai-bubble::before {
  right: -5px;
  background: #1E90FF;
}
.ai-header-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(138,160,184,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}
.ai-info-text {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.65;
}
.ai-info-text p + p {
  margin-top: 8px;
}
.ai-memory-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}
.ai-memory-item {
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.45;
}
.ai-memory-item span {
  display: block;
  margin-top: 5px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
}
.ai-input-bar {
  position: fixed;
  left: 50%;
  bottom: var(--nav-height);
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(10, 22, 40, 0.96);
  border-top: 1px solid var(--border);
  z-index: 99;
}
.ai-input-bar input {
  flex: 1;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-primary);
  outline: none;
  padding: 10px 14px;
  font-size: 13px;
  font-family: var(--font-cn);
}
.ai-input-bar input:focus {
  border-color: var(--accent-blue);
}
.ai-input-bar button {
  border: none;
  border-radius: 18px;
  padding: 0 16px;
  background: var(--gradient-blue);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-cn);
  cursor: pointer;
}
.device-preview-item i {
  color: var(--text-dim);
  font-size: 12px;
}

/* ========== MAP PLACEHOLDER ========== */
.map-placeholder {
  height: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.map-placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    linear-gradient(45deg, transparent 48%, var(--border) 48%, var(--border) 52%, transparent 52%),
    repeating-linear-gradient(0deg, transparent, transparent 30px, rgba(30, 144, 255, 0.03) 30px, rgba(30, 144, 255, 0.03) 31px),
    repeating-linear-gradient(90deg, transparent, transparent 30px, rgba(30, 144, 255, 0.03) 30px, rgba(30, 144, 255, 0.03) 31px);
}
.map-overlay {
  text-align: center;
  z-index: 1;
  color: var(--text-dim);
}
.map-overlay i {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
  opacity: 0.5;
}
.map-overlay p {
  font-size: 12px;
  margin-bottom: 8px;
}
.map-btn {
  background: rgba(30, 144, 255, 0.15);
  border: 1px solid rgba(30, 144, 255, 0.3);
  color: var(--accent-blue);
  padding: 6px 16px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
}

/* ========== SEARCH BAR ========== */
.search-bar {
  margin: 4px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
}
.search-bar i {
  color: var(--text-dim);
  font-size: 14px;
}
.search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-cn);
  font-size: 13px;
}
.search-bar input::placeholder {
  color: var(--text-dim);
}

/* ========== PROJECT LIST ========== */
.project-list {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 80px;
}
.project-card {
  background: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.project-card:active {
  background: var(--bg-card-hover);
  transform: scale(0.99);
}
.project-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.project-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(30, 144, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
  font-size: 18px;
  flex-shrink: 0;
}
.project-meta {
  flex: 1;
  min-width: 0;
}
.project-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 3px;
}
.status-badge {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.status-badge.online { background: var(--success); }
.status-badge.warning { background: var(--warning); }
.status-badge.offline { background: var(--text-dim); }
.project-chevron {
  color: var(--text-dim);
  font-size: 12px;
}
.project-detail-tags {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.tag {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 400;
}
.tag-online {
  background: rgba(0, 230, 118, 0.12);
  color: var(--success);
}
.tag-idle {
  background: rgba(138, 160, 184, 0.1);
  color: var(--text-secondary);
}
.tag-warning {
  background: rgba(255, 145, 0, 0.12);
  color: var(--warning);
}
.tag-offline {
  background: rgba(90, 122, 154, 0.1);
  color: var(--text-dim);
}

/* ========== DETAIL TABS ========== */
.detail-tabs {
  display: flex;
  padding: 0 12px;
  gap: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.detail-tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  flex-shrink: 0;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-cn);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition: color 0.2s;
}
.tab.active {
  color: var(--accent-blue);
}
.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 14px;
  right: 14px;
  height: 2px;
  background: var(--accent-blue);
  border-radius: 1px;
}
.tab-content {
  display: none;
  padding: 12px 16px;
  height: calc(100vh - 180px - var(--nav-height));
  overflow-y: auto;
}
.tab-content.active {
  display: block;
}

/* ========== MONITOR GRID ========== */
.monitor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.monitor-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.monitor-item.alert {
  border-color: rgba(255, 23, 68, 0.3);
  background: rgba(255, 23, 68, 0.05);
}
.monitor-label {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.monitor-label i {
  font-size: 11px;
  color: var(--text-dim);
}
.monitor-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}
.monitor-value[data-type="digital"] {
  min-width: 24px;
  text-align: center;
}

/* ========== CURVE TAB ========== */
.curve-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.curve-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.curve-select {
  display: flex;
  align-items: center;
  gap: 8px;
}
.curve-select label {
  font-size: 12px;
  color: var(--text-secondary);
}
.curve-select select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 10px;
  font-family: var(--font-cn);
  font-size: 12px;
  outline: none;
}
.curve-time {
  display: flex;
  gap: 4px;
}
.time-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}
.time-btn.active {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}
.curve-chart {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.curve-svg {
  width: 100%;
  height: 150px;
}
.chart-hint {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* ========== ALARM TAB ========== */
.alarm-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.alarm-filter-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 16px;
  border-radius: 20px;
  font-family: var(--font-cn);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.alarm-filter-btn.active {
  background: rgba(255, 23, 68, 0.12);
  border-color: rgba(255, 23, 68, 0.3);
  color: var(--danger);
}
.alarm-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.alarm-item {
  display: flex;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.alarm-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}
.alarm-danger { color: var(--danger); }
.alarm-warning { color: var(--warning); }
.alarm-info { color: var(--info); }
.alarm-content {
  flex: 1;
  min-width: 0;
}
.alarm-type {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.alarm-level {
  font-size: 10px;
  padding: 1px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.level-generic {
  background: rgba(90, 122, 154, 0.15);
  color: var(--text-secondary);
}
.level-warning {
  background: rgba(255, 145, 0, 0.15);
  color: var(--warning);
}
.alarm-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}
.alarm-device {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.alarm-device i {
  margin-right: 4px;
}

/* ========== CONFIG TAB ========== */
.config-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}
.config-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-blue);
}
.config-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.config-field:last-of-type {
  border-bottom: none;
}
.config-field label {
  font-size: 13px;
  color: var(--text-secondary);
}
.config-val {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  background: rgba(30, 144, 255, 0.06);
  padding: 2px 10px;
  border-radius: 4px;
}
.config-actions {
  margin-top: 16px;
  text-align: center;
}
.config-btn {
  background: rgba(30, 144, 255, 0.12);
  border: 1px solid rgba(30, 144, 255, 0.3);
  color: var(--accent-blue);
  padding: 8px 24px;
  border-radius: 20px;
  font-family: var(--font-cn);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.config-btn:active {
  background: rgba(30, 144, 255, 0.25);
}

/* ========== VIDEO SECTION ========== */
.video-section {
  padding: 12px 16px;
}
.video-platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(30, 144, 255, 0.12);
  color: var(--accent-blue);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  margin-bottom: 10px;
}
.video-player {
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  aspect-ratio: 16 / 9;
  position: relative;
  overflow: hidden;
}
.video-player::before {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.4)),
    repeating-linear-gradient(0deg, transparent, transparent 30px, rgba(255,255,255,0.02) 30px, rgba(255,255,255,0.02) 31px);
}
.video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 1;
}
.video-overlay > i {
  font-size: 36px;
  color: rgba(255,255,255,0.2);
}
.video-datetime {
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgba(255,255,255,0.7);
}
.video-label {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
}
.video-controls {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}
.video-control-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}
.video-control-btn:active {
  background: rgba(255,255,255,0.2);
}
.video-sdk-btn {
  margin-top: 4px;
  background: rgba(30, 144, 255, 0.15);
  border: 1px solid rgba(30, 144, 255, 0.3);
  color: var(--accent-blue);
  padding: 5px 14px;
  border-radius: 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
}

/* ========== BOTTOM NAV ========== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-height);
  background: rgba(10, 22, 40, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-cn);
  font-size: 10px;
  cursor: pointer;
  padding: 6px 12px;
  transition: color 0.2s;
  min-width: 48px;
}
.nav-item i {
  font-size: 18px;
}
.nav-item.active {
  color: var(--accent-blue);
}
.nav-item.active i {
  text-shadow: 0 0 8px rgba(30, 144, 255, 0.4);
}

/* ========== RESPONSIVE ========== */
@media (min-width: 481px) {
  #app {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.page.active .stat-card {
  animation: fadeIn 0.3s ease both;
}
.page.active .stat-card:nth-child(2) { animation-delay: 0.05s; }
.page.active .stat-card:nth-child(3) { animation-delay: 0.1s; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.device-status-dot.online {
  animation: pulse 2s ease-in-out infinite;
}

/* ========== WEATHER CARD ========== */
.weather-card {
  margin: 6px 16px 4px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  position: relative;
}
/* 左侧色条 */
.weather-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  border-radius: 0 2px 2px 0;
}
.weather-card[data-weather="sunny"]::before { background: var(--accent-blue); }
.weather-card[data-weather="rain"]::before { background: var(--info); }
.weather-card[data-weather="cloud"]::before { background: var(--text-secondary); }
.weather-card[data-weather="fog"]::before { background: var(--text-dim); }

/* 左侧图标 */
.wc-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 2px;
}
.weather-card[data-weather="sunny"] .wc-icon { background: rgba(255,213,79,0.15); }
.weather-card[data-weather="rain"] .wc-icon { background: rgba(79,195,247,0.15); }
.weather-card[data-weather="cloud"] .wc-icon { background: rgba(144,164,174,0.15); }
.weather-card[data-weather="fog"] .wc-icon { background: rgba(120,144,156,0.15); }

/* 右侧三行 */
.wc-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* 第一行：温度 + 描述 + 更新时间 */
.wc-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wc-temp {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}
.wc-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: 4px;
}
.wc-update {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* 第二行：定位 */
.wc-row-mid {
  font-size: 11px;
  color: var(--text-dim);
}

/* 第三行：标签 */
.wc-row-bot {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.wc-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 100px;
  white-space: nowrap;
  line-height: 1;
}
.wc-tag-hum {
  color: #E1F5FE;
  background: #0D47A1;
  border: 1px solid #1565C0;
}
.wc-tag-wind {
  color: #E0F7FA;
  background: #006064;
  border: 1px solid #00838F;
}
.wc-tag-rain {
  color: #E3F2FD;
  background: #01579B;
  border: 1px solid #0277BD;
}

/* ========== WEATHER SKELETON ========== */
.weather-card.loading .wc-temp,
.weather-card.loading .wc-desc,
.weather-card.loading .wc-row-mid,
.weather-card.loading .wc-tag {
  color: transparent !important;
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.10) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  -webkit-background-clip: text;
  background-clip: text;
  border-radius: 4px;
}
.weather-card.loading .wc-icon {
  opacity: 0.3;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========== RAINFALL CHART ========== */
.rain-section {
  padding: 0 16px;
  margin-top: 4px;
}
.rain-section .section-header {
  margin-bottom: 8px;
}
.rain-chart-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 12px 8px;
  position: relative;
  overflow: hidden;
}
.rain-chart-wrap canvas {
  display: block;
  margin: 0 auto;
  min-width: 200px;
}
.rain-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
  color: var(--text-dim);
  font-size: 13px;
}
.rain-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
  color: var(--text-dim);
  font-size: 13px;
}

/* ========== ALERT SECTION ========== */
.alert-section {
  padding: 0 16px;
  margin-top: 4px;
}
.alert-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.alert-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.alert-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  background: #D32F2F;
  color: #fff;
}

/* ========== WORKBENCH: 快捷功能 ========== */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 4px 16px 16px;
}
.quick-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.quick-item:active .quick-icon {
  transform: scale(0.92);
}
.quick-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: transform 0.15s;
}
.quick-blue { background: rgba(30,144,255,0.15); color: #1E90FF; }
.quick-green { background: rgba(0,230,118,0.15); color: #00E676; }
.quick-cyan { background: rgba(0,188,212,0.15); color: #00BCD4; }
.quick-orange { background: rgba(255,145,0,0.15); color: #FF9100; }
.quick-red { background: rgba(255,23,68,0.15); color: #FF1744; }
.quick-purple { background: rgba(156,39,176,0.15); color: #CE93D8; }
.quick-teal { background: rgba(0,150,136,0.15); color: #4DB6AC; }
.quick-more { background: rgba(90,122,154,0.12); color: var(--text-dim); }
.quick-item span {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
}

/* ========== TODO LIST ========== */
.todo-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.todo-priority {
  width: 4px;
  height: 32px;
  border-radius: 2px;
  flex-shrink: 0;
}
.todo-priority.high { background: var(--danger); }
.todo-priority.mid { background: var(--warning); }
.todo-priority.low { background: var(--accent-cyan); }
.todo-content {
  flex: 1;
  min-width: 0;
}
.todo-title {
  font-size: 13px;
  font-weight: 500;
}
.todo-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}
.todo-btn {
  background: rgba(30,144,255,0.12);
  border: 1px solid rgba(30,144,255,0.3);
  color: var(--accent-blue);
  padding: 5px 14px;
  border-radius: 14px;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font-cn);
  flex-shrink: 0;
}

/* ========== RECENT LIST ========== */
.recent-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.recent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.recent-item i {
  color: var(--text-dim);
  font-size: 12px;
}
.recent-time {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* ========== MESSAGES ========== */
.msg-tabs {
  display: flex;
  gap: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}
.msg-tab {
  flex: 1;
  padding: 10px 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-cn);
  font-size: 13px;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}
.msg-tab.active {
  color: var(--accent-blue);
}
.msg-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--accent-blue);
  border-radius: 1px;
}
.msg-list {
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.msg-item {
  display: flex;
  gap: 10px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  position: relative;
}
.msg-item.unread {
  border-color: rgba(30,144,255,0.3);
}
.msg-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.msg-avatar-danger { background: rgba(255,23,68,0.15); color: #FF1744; }
.msg-avatar-warning { background: rgba(255,145,0,0.15); color: #FF9100; }
.msg-avatar-notice { background: rgba(30,144,255,0.15); color: #1E90FF; }
.msg-avatar-system { background: rgba(0,230,118,0.15); color: #00E676; }
.msg-body {
  flex: 1;
  min-width: 0;
}
.msg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.msg-sender {
  font-size: 13px;
  font-weight: 500;
}
.msg-time {
  font-size: 11px;
  color: var(--text-dim);
}
.msg-title {
  font-size: 12px;
  color: var(--text-primary);
  margin-top: 4px;
}
.msg-preview {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-blue);
  position: absolute;
  top: 12px;
  right: 12px;
  box-shadow: 0 0 6px rgba(30,144,255,0.5);
}

/* ========== PROFILE ========== */
.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px 20px;
}
.profile-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1E90FF, #00BCD4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 20px rgba(30,144,255,0.3);
}
.profile-info {
  flex: 1;
}
.profile-name {
  font-size: 18px;
  font-weight: 600;
}
.profile-role {
  font-size: 12px;
  color: var(--accent-blue);
  margin-top: 2px;
}
.profile-org {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.profile-org i {
  margin-right: 4px;
  font-size: 11px;
}
.profile-edit-btn {
  background: rgba(30,144,255,0.12);
  border: 1px solid rgba(30,144,255,0.3);
  color: var(--accent-blue);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 0 16px 16px;
}
.profile-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
}
.profile-stat-num {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-blue);
}
.profile-stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.profile-menu {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.menu-item:active {
  background: var(--bg-card-hover);
}

/* ========== 页面内容容器（统一滚动区域） ========== */
.page-content {
  padding-bottom: 80px;
}
.menu-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(30,144,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
  font-size: 15px;
  flex-shrink: 0;
}
.menu-label {
  flex: 1;
  font-size: 14px;
}
.menu-badge {
  background: rgba(255,23,68,0.15);
  color: var(--danger);
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  font-family: var(--font-mono);
}
.menu-arrow {
  color: var(--text-dim);
  font-size: 12px;
}

.profile-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 20px 16px 30px;
  padding: 12px;
  background: rgba(255,23,68,0.06);
  border: 1px solid rgba(255,23,68,0.2);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 14px;
  cursor: pointer;
}
.profile-logout:active {
  background: rgba(255,23,68,0.12);
}
