* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; color: #2c3e50; }
body { height: 100vh; display: flex; flex-direction: column; }

/* ============== 登录页 ============== */
.login-body {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
/* 装饰光斑 */
.login-bg {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}
.login-bg::before, .login-bg::after {
  content: ''; position: absolute; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  filter: blur(60px);
}
.login-bg::before { width: 420px; height: 420px; top: -120px; left: -120px; }
.login-bg::after  { width: 520px; height: 520px; bottom: -160px; right: -160px;
                    background: rgba(255, 200, 150, 0.18); }

.login-card {
  position: relative; z-index: 1;
  width: 400px; max-width: calc(100vw - 32px);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  padding: 36px 36px 28px;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25),
              0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  animation: cardIn 0.5s cubic-bezier(.2,.8,.2,1);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-brand { text-align: center; margin-bottom: 26px; }
.brand-icon {
  font-size: 38px; width: 64px; height: 64px; line-height: 64px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 18px;
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.35);
}
.brand-title { margin: 0; font-size: 22px; font-weight: 600; color: #1f2a44; letter-spacing: 0.5px; }
.brand-subtitle { margin: 4px 0 0; color: #95a5a6; font-size: 13px; }

.field {
  display: flex; align-items: center;
  margin-bottom: 14px;
  padding: 0 14px;
  height: 48px;
  background: #f5f7fa;
  border: 1px solid transparent;
  border-radius: 10px;
  transition: all 0.2s ease;
}
.field:focus-within {
  background: #fff;
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.12);
}
.field-icon { font-size: 16px; color: #95a5a6; margin-right: 10px; user-select: none; }
.field input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 14px; color: #2c3e50;
}
.field input::placeholder { color: #b2bec3; }

.login-error {
  min-height: 18px; margin: 4px 2px 10px;
  font-size: 13px; color: #e74c3c;
}
.login-error:empty { margin: 0 2px; }

.btn-primary {
  width: 100%; height: 46px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff; border: none; border-radius: 10px;
  font-size: 15px; font-weight: 500; letter-spacing: 2px;
  cursor: pointer; position: relative; overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.35);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(102, 126, 234, 0.45); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { cursor: not-allowed; opacity: 0.85; }
.btn-primary.loading .btn-text { opacity: 0; }
.btn-primary.success { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.btn-spinner {
  position: absolute; left: 50%; top: 50%;
  width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff; border-radius: 50%;
  opacity: 0;
}
.btn-primary.loading .btn-spinner { opacity: 1; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-tip { text-align: center; margin: 14px 0 0; font-size: 12px; color: #b2bec3; }

.shake { animation: shake 0.4s; }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

/* ============== 地图页 ============== */
.topbar {
  height: 56px; background: linear-gradient(90deg, #2c3e50, #34495e);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.brand { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.actions { display: flex; align-items: center; gap: 16px; }
.who { color: #bdc3c7; font-size: 13px; }
.btn-link {
  color: #fff; text-decoration: none; font-size: 13px;
  padding: 6px 12px; border-radius: 6px;
  transition: background 0.2s;
}
.btn-link:hover { background: rgba(255,255,255,0.1); text-decoration: none; }

.filters {
  padding: 14px 22px; background: #fff;
  border-bottom: 1px solid #e6ebf1;
  box-shadow: 0 1px 2px rgba(0,0,0,.02);
}
.filters form { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.filters label { display: flex; flex-direction: column; font-size: 12px; color: #95a5a6; font-weight: 500; }
.filters input {
  margin-top: 6px; padding: 8px 12px; border: 1px solid #dcdfe6;
  border-radius: 8px; font-size: 13px; min-width: 180px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.filters input:focus { outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,.12); }
.filters .btn-primary { width: auto; padding: 0 22px; height: 36px; font-size: 14px; letter-spacing: 1px; }
.status { margin-left: auto; font-size: 13px; color: #16a085; padding-bottom: 8px; }

#map { flex: 1; min-height: 0; }

.legend {
  position: absolute; right: 14px; top: 78px; background: #fff;
  padding: 10px 12px; border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
  font-size: 12px; max-width: 220px; z-index: 1000;
}
.legend-item { display: flex; align-items: center; gap: 8px; margin: 5px 0; color: #2c3e50; }
.legend .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(255,255,255,0.8); }

/* ============== 记住我 ============== */
.remember {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 4px 14px;
  font-size: 13px; color: #7f8c8d; cursor: pointer;
  user-select: none;
}
.remember input[type=checkbox] {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid #dcdfe6; border-radius: 4px;
  background: #f5f7fa;
  cursor: pointer; position: relative;
  transition: all 0.15s ease;
}
.remember input[type=checkbox]:hover { border-color: #667eea; }
.remember input[type=checkbox]:checked {
  background: #667eea; border-color: #667eea;
}
.remember input[type=checkbox]:checked::after {
  content: ''; position: absolute;
  left: 4px; top: 1px;
  width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ============== 密码可见切换 ============== */
.toggle-pwd {
  border: none; background: transparent;
  color: #95a5a6; cursor: pointer;
  padding: 4px; margin-left: 4px;
  display: inline-flex; align-items: center;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.toggle-pwd:hover { color: #667eea; background: rgba(102, 126, 234, 0.08); }
.toggle-pwd.active { color: #667eea; }

/* ============== 错误样式 ============== */
.login-error {
  display: flex; align-items: center; gap: 6px;
  margin: 4px 4px 10px;
  min-height: 18px;
  font-size: 13px; color: #e74c3c;
  opacity: 0; max-height: 0;
  overflow: hidden;
  transition: opacity 0.2s ease, max-height 0.2s ease, margin 0.2s ease;
}
.login-error.show { opacity: 1; max-height: 40px; }
.login-error .err-icon { flex-shrink: 0; }
.login-error .err-text { line-height: 1.4; }

/* ============== 设备数据 popup ============== */
.leaflet-popup-content-wrapper {
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 0;
}
.leaflet-popup-content { margin: 0; min-width: 220px; }
.leaflet-popup-tip { box-shadow: 0 4px 8px rgba(0,0,0,0.08); }

.popup-card { padding: 12px 14px; }
.popup-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 8px; margin-bottom: 8px;
  border-bottom: 1px solid #f0f2f5;
  gap: 10px;
}
.popup-device {
  font-weight: 600; font-size: 14px; color: #1f2a44;
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.popup-time { font-size: 11px; color: #95a5a6; }
.popup-body { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.popup-row { display: flex; flex-direction: column; gap: 2px; }
.popup-label { font-size: 11px; color: #95a5a6; }
.popup-value {
  font-size: 13px; color: #2c3e50; font-weight: 500;
  display: flex; align-items: center; gap: 4px;
}
.popup-value .badge {
  font-size: 10px; padding: 1px 5px; border-radius: 3px;
  background: #f0f2f5; color: #7f8c8d; font-weight: normal;
}
.popup-value.bat-low { color: #e74c3c; }
.popup-value.bat-mid { color: #f39c12; }
.popup-value.bat-ok  { color: #27ae60; }

/* ============== 地图回放控制 ============== */
.playback {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 22px; background: #fff;
  border-bottom: 1px solid #e6ebf1;
  flex-wrap: wrap;
}
.playback-group { display: flex; align-items: center; gap: 6px; }
.play-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 32px; padding: 0 12px;
  background: #fff; color: #2c3e50;
  border: 1px solid #dcdfe6; border-radius: 6px;
  font-size: 13px; cursor: pointer;
  transition: all 0.15s;
}
.play-btn:hover:not(:disabled) { border-color: #667eea; color: #667eea; }
.play-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.play-btn.primary { background: #667eea; color: #fff; border-color: #667eea; }
.play-btn.primary:hover { background: #556cd6; border-color: #556cd6; color: #fff; }

.speed-picker { display: inline-flex; border: 1px solid #dcdfe6; border-radius: 6px; overflow: hidden; }
.speed-picker button {
  border: none; background: #fff; padding: 6px 10px;
  font-size: 12px; color: #7f8c8d; cursor: pointer;
  border-right: 1px solid #dcdfe6;
}
.speed-picker button:last-child { border-right: none; }
.speed-picker button:hover { background: #f5f7fa; }
.speed-picker button.active { background: #667eea; color: #fff; }

.playback-progress {
  flex: 1; min-width: 180px;
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: #7f8c8d;
}
.playback-bar {
  flex: 1; height: 4px; background: #f0f2f5; border-radius: 2px;
  position: relative; overflow: hidden; cursor: pointer;
}
.playback-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, #667eea, #764ba2);
  width: 0; transition: width 0.05s linear;
}
.playback-time { font-variant-numeric: tabular-nums; min-width: 80px; text-align: right; }
