/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #f25e86;
  --primary-light: #f25e851c;
  --primary-dark: #d94a70;
  --bg: #f8f8f8;
  --card-bg: #ffffff;
  --text-primary: #333333;
  --text-secondary: #888888;
  --text-muted: #aaaaaa;
  --border: #e8e8e8;
  --success: #10b981;
  --warning: #f59e0b;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Title Bar ──────────────────────────────────────────── */
.titlebar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 28px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: #e4e4e4;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
  -webkit-app-region: drag;
  user-select: none;
}

.titlebar .icon {
  width: 18px;
  height: 18px;
}

/* ── Header ─────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 28px;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--bg) linear-gradient(90deg, #f25e8500 0%, var(--primary-light) 50%, var(--primary-light) 100%);
  border-bottom: 1px solid var(--border);
}

.header .title {
  font-size: 18px;
  font-weight: 500;
}

.header .actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.additional {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.status-dot.offline {
  background: var(--text-muted);
}

.status-text {
  font-size: 12px;
}

/* ── Main Content ───────────────────────────────────────── */
.main-content {
  position: fixed;
  top: calc(28px + 53px); /* titlebar + header */
  left: 0;
  right: 0;
  bottom: 36px;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Heart Rate Section ─────────────────────────────────── */
.hr-section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 30px 20px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.hr-value-wrapper {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

.hr-value {
  font-size: 72px;
  font-weight: 700;
  line-height: 1;
  color: var(--primary);
  letter-spacing: -2px;
}

.hr-unit {
  font-size: 24px;
  font-weight: 500;
  color: var(--text-secondary);
}

.hr-label {
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* ── Chart Section ──────────────────────────────────────── */
.chart-section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 260px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.range-input {
  width: 56px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
  font-size: 12px;
  color: var(--text-primary);
  background: var(--bg);
  outline: none;
  -moz-appearance: textfield;
}
.range-input::-webkit-outer-spin-button,
.range-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.range-input:focus {
  border-color: var(--primary);
}

.chart-range-lbl {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 6px;
}

.chart-range {
  font-size: 12px;
  color: var(--text-muted);
}

.chart-container {
  flex: 1;
  position: relative;
  min-height: 200px;
}

/* ── Bottom Bar ─────────────────────────────────────────── */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 480px) {
  .hr-value {
    font-size: 56px;
  }
  .main-content {
    padding: 12px;
  }
}

/* ── Login Overlay ──────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.login-box {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 40px 36px 32px;
  width: 340px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  animation: login-fade-in 0.3s ease-out;
}

@keyframes login-fade-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-heart {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
}

.login-input:focus {
  border-color: var(--primary);
}

.login-btn {
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.login-btn:hover {
  background: var(--primary-dark);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-error {
  font-size: 13px;
  color: #e74c3c;
  display: none;
}