/* ============================================================
   CSS Variables & Reset
   ============================================================ */
:root {
  --black: #000000;
  --white: #FFFFFF;
  --bg: #FFFFFF;
  --card: #F5F5F7;
  --card-hover: #EDEDF0;
  --border: #E5E5EA;
  --text-primary: #1D1D1F;
  --text-secondary: #6E6E73;
  --text-tertiary: #AEAEB2;
  --accent: #000000;
  --accent-light: #F5F5F7;
  --danger: #FF3B30;
  --danger-bg: #FFF2F1;
  --success: #34C759;
  --blue: #007AFF;
  --orange: #FF9500;
  --purple: #AF52DE;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.16);
  --font-display: -apple-system, BlinkMacSystemFont, 'Noto Sans SC', 'Helvetica Neue', 'PingFang SC', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  width: 100%;
  overflow-x: clip;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100dvh;
  width: 100%;
  overflow-x: clip;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* 允许输入框和文本域选择文字 */
input, textarea, [contenteditable] {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  left: 0;
  -webkit-overflow-scrolling: auto;
  touch-action: none;
}

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes confirmPop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.animate-in {
  animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}

/* ============================================================
   Custom Confirm Dialog （问题4）
   ============================================================ */
.confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 500;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.confirm-overlay.show { opacity: 1; visibility: visible; }

.confirm-dialog {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: calc(100% - 48px);
  max-width: 300px;
  background: var(--white);
  border-radius: var(--radius-md);
  z-index: 501;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
}
.confirm-dialog.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.confirm-body {
  padding: 24px 20px 16px;
  text-align: center;
}
.confirm-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.confirm-msg {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.confirm-actions {
  display: flex;
  border-top: 0.5px solid var(--border);
}
.confirm-btn {
  flex: 1;
  padding: 14px;
  font-size: 1rem;
  font-family: var(--font-display);
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}
.confirm-btn:active { background: var(--card); }
.confirm-cancel {
  color: var(--text-secondary);
  font-weight: 400;
  border-right: 0.5px solid var(--border);
}
.confirm-ok {
  color: var(--danger);
  font-weight: 600;
}

/* ============================================================
   Login Page
   ============================================================ */
#loginPage {
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  background: var(--bg);
}

.login-container {
  width: 100%;
  max-width: 380px;
  animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-logo {
  text-align: center;
  margin-bottom: 48px;
}

.login-logo h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--black);
}

.login-logo p {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  margin-top: 8px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 密码输入框容器 */
.password-wrap {
  position: relative;
}
.password-wrap .input-field {
  padding-right: 52px;
}
.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}
.password-toggle:active { color: var(--text-secondary); }

.input-field {
  width: 100%;
  padding: 16px 20px;
  font-size: 1rem;
  font-family: var(--font-display);
  background: var(--card);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: all 0.25s ease;
}

.input-field::placeholder { color: var(--text-tertiary); }

.input-field:focus {
  border-color: var(--black);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(0,0,0,0.06);
}

.btn-primary {
  width: 100%;
  padding: 16px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-display);
  background: var(--black);
  color: var(--white);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.25s ease;
  margin-top: 8px;
  letter-spacing: -0.01em;
}

.btn-primary:hover { background: #333; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { background: var(--text-tertiary); cursor: not-allowed; transform: none; }

.login-error {
  text-align: center;
  color: var(--danger);
  font-size: 0.875rem;
  min-height: 20px;
  margin-top: 8px;
}

/* ============================================================
   Main App
   ============================================================ */
#appPage {
  min-height: 100dvh;
  padding-bottom: calc(100px + var(--safe-bottom));
}

/* --- Top Nav --- */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--border);
  padding: calc(12px + var(--safe-top)) 20px 0;
}

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 600px;
  margin: 0 auto;
}

.nav-logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.03em; }

.nav-actions { display: flex; align-items: center; gap: 6px; }

.nav-btn {
  padding: 8px 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: var(--font-display);
  background: var(--card);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}

.nav-btn svg { width: 15px; height: 15px; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.nav-btn:hover { background: var(--card-hover); color: var(--text-primary); }

/* --- [问题5] View Toggle 带滑块动画 --- */
.view-toggle {
  display: flex;
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin: 12px auto 0;
  max-width: 600px;
  position: relative;
}
/* stats-bar 跟在 view-toggle 后，需要与 nav 居中对齐 */
.top-nav .stats-bar {
  margin-left: auto;
  margin-right: auto;
}

.toggle-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: var(--white);
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 0;
  pointer-events: none;
}

.toggle-btn {
  flex: 1;
  padding: 8px 16px;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: var(--font-display);
  background: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.25s ease;
  position: relative;
  z-index: 1;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.toggle-btn:active { background: none; }

.toggle-btn.active {
  color: var(--text-primary);
}

/* --- Content --- */
.content {
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 20px;
  overflow: hidden;
}

/* --- Stats Bar（位于 top-nav 内，随导航栏一起吸顶）--- */
.stats-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 8px 4px;
  margin: 10px 0 12px;
  overflow: hidden;
  max-width: 600px;
  gap: 2px;
}

.stats-nav-btn {
  width: 28px; height: 28px; min-width: 28px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 50%;
  cursor: pointer; color: var(--text-tertiary);
  transition: all 0.2s ease; flex-shrink: 0; padding: 0;
}
.stats-nav-btn:active { background: var(--card-hover); color: var(--text-primary); }

.stats-center {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer;
}

.stats-month-label {
  font-size: 0.6875rem; font-weight: 600;
  color: var(--text-tertiary); letter-spacing: 0.02em;
  transition: color 0.2s ease;
}
.stats-month-label.is-current { color: var(--blue); }

.stats-data {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0;
  padding: 0 4px;
}

.stat-item {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.stat-val {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.stat-val.positive { color: var(--success); }
.stat-val.negative { color: var(--danger); }

.stat-lbl {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.stat-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

/* --- List View --- */
.record-list { display: flex; flex-direction: column; gap: 6px; }

.record-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  background: var(--card);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.record-item:hover { background: var(--card-hover); transform: translateX(2px); }

.record-date { font-weight: 600; font-size: 0.9375rem; letter-spacing: -0.01em; }
.record-date-sub { font-size: 0.6875rem; color: var(--text-tertiary); font-weight: 400; }

.record-time {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  min-width: 46px;
  text-align: center;
}

.record-hours {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  min-width: 48px;
  text-align: right;
}

.record-badge {
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--accent-light);
  color: var(--text-secondary);
}

.badge-home { background: #E8F5E9; color: #2E7D32; }
.badge-rest { background: #FFF3E0; color: #E65100; }
.badge-leave { background: #E3F2FD; color: #1565C0; }
.badge-holiday { background: #F3E5F5; color: #7B1FA2; }

/* [问题1] 预计下班时间提示 */
.est-hint {
  color: var(--blue);
  font-style: italic;
  opacity: 0.7;
  font-size: 0.75rem;
}

/* 列表工时状态小点 — 低调内敛 */
.record-dot {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  margin-right: 5px;
  margin-left: -2px;
  vertical-align: middle;
  position: relative;
  top: -0.5px;
}
.record-dot.dot-ok { background: var(--success); opacity: 0.35; }
.record-dot.dot-short { background: var(--orange); opacity: 0.45; }
.record-dot.dot-pending { background: var(--text-tertiary); opacity: 0.3; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-tertiary); }
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.9375rem; }

/* 月份分组标题 */
.month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 4px 8px;
}
.month-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}
.month-stats {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

/* --- Calendar View --- */
.calendar-header { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.calendar-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; flex: 1; text-align: center; }

.cal-nav-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); border: none; border-radius: 50%;
  cursor: pointer; color: var(--text-secondary);
  transition: all 0.2s ease; flex-shrink: 0;
  padding: 0; line-height: 1;
}
.cal-nav-btn svg { display: block; flex-shrink: 0; }
.cal-nav-btn:hover { background: var(--card-hover); color: var(--text-primary); }

.cal-today-btn {
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-display);
  background: var(--card);
  border: none;
  border-radius: 20px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  flex-shrink: 0;
  white-space: nowrap;
}
.cal-today-btn:active { background: var(--card-hover); color: var(--text-primary); }
.cal-today-btn.is-current { display: none; }

.calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.weekday-label { text-align: center; font-size: 0.6875rem; font-weight: 600; color: var(--text-tertiary); padding: 8px 0; letter-spacing: 0.04em; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }

.cal-day {
  aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500;
  cursor: pointer; transition: all 0.2s ease;
  position: relative;
  padding: 4px 0; gap: 1px;
}
.cal-day:hover { background: var(--card); }
.cal-day.empty { cursor: default; }
.cal-day.empty:hover { background: transparent; }
.cal-day.today { background: var(--black); color: var(--white); }
.cal-day.today:hover { background: #333; }

.cal-day-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.cal-day-dot.is-short { background: var(--orange); }
.cal-day-dot.is-pending { background: var(--text-tertiary); opacity: 0.4; }
.cal-day-dot.is-rest { background: var(--blue); }
.cal-day.today .cal-day-dot { background: rgba(255,255,255,0.8) !important; opacity: 1; }

.cal-day-hours { font-size: 0.5rem; font-family: var(--font-mono); color: var(--text-tertiary); font-weight: 400; line-height: 1; }
.cal-day.today .cal-day-hours { color: rgba(255,255,255,0.6); }

/* --- FAB --- */
.fab {
  position: fixed;
  bottom: calc(28px + var(--safe-bottom));
  right: 24px; width: 56px; height: 56px;
  background: var(--black); color: var(--white);
  border: none; border-radius: 50%;
  font-size: 1.75rem; font-weight: 300;
  cursor: pointer; box-shadow: var(--shadow-lg);
  transition: all 0.25s ease;
  display: flex; align-items: center; justify-content: center;
  z-index: 90;
}
.fab:hover { transform: scale(1.08); box-shadow: var(--shadow-xl); }
.fab:active { transform: scale(0.95); }

/* ============================================================
   Modal / Sheet
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal-overlay.show { opacity: 1; visibility: visible; }

.modal-sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: 201;
  max-height: 85dvh;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  padding-bottom: calc(20px + var(--safe-bottom));
}
.modal-sheet.show { transform: translateY(0); }

.sheet-handle-area { padding: 12px 0 4px; cursor: grab; touch-action: none; }
.sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto; }

.sheet-header { padding: 12px 24px 16px; display: flex; align-items: center; justify-content: space-between; }
.sheet-title { font-size: 1.125rem; font-weight: 700; letter-spacing: -0.02em; }

.sheet-close {
  width: 32px; height: 32px; background: var(--card);
  border: none; border-radius: 50%;
  cursor: pointer; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s ease;
  padding: 0; flex-shrink: 0; line-height: 1;
}
.sheet-close svg { display: block; }
.sheet-close:hover { background: var(--card-hover); }

.sheet-body { padding: 0 24px; display: flex; flex-direction: column; gap: 16px; }

/* --- Form --- */
.form-group label {
  display: block; font-size: 0.75rem; font-weight: 600;
  color: var(--text-tertiary); margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: 0.05em;
}

.est-time {
  font-weight: 500;
  color: var(--blue);
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-mono);
}
.est-clickable:not(:empty) {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background 0.15s ease;
}
.est-clickable:not(:empty):active {
  background: rgba(0,122,255,0.1);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.form-row .form-group label {
  height: 2.2em;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  overflow: hidden;
}

.input-sm {
  width: 100%; padding: 14px 16px;
  font-size: 0.9375rem; font-family: var(--font-display);
  background: var(--card); border: 2px solid transparent;
  border-radius: var(--radius-sm); color: var(--text-primary);
  outline: none; transition: all 0.25s ease;
  -webkit-appearance: none; appearance: none;
}
.input-sm:focus { border-color: var(--black); background: var(--white); }
.input-sm:disabled { opacity: 0.35; cursor: not-allowed; }
.input-sm:disabled ~ .time-placeholder { display: none !important; }

.input-sm[type="time"],
.input-sm[type="date"] {
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  line-height: 1.2;
  color: var(--text-primary);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  position: relative;
  font-family: var(--font-mono);
}

.input-sm[type="date"]::-webkit-date-and-time-value,
.input-sm[type="time"]::-webkit-date-and-time-value {
  text-align: left;
}

.input-sm[type="time"]:not(:valid)::-webkit-datetime-edit,
.input-sm[type="date"]:not(:valid)::-webkit-datetime-edit {
  color: var(--text-tertiary);
}

/* [问题8] 时间输入占位符 */
.time-input-wrap {
  position: relative;
}
.time-input-wrap .input-sm {
  position: relative;
  z-index: 1;
}
.time-placeholder {
  position: absolute;
  top: 50%; left: 16px;
  transform: translateY(-50%);
  font-size: 0.875rem;
  color: var(--text-tertiary);
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.2s ease;
}

/* 时间锁定遮罩 */
.time-lock-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: var(--card);
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-tertiary);
  font-size: 0.8125rem;
  font-weight: 500;
  z-index: 3;
  pointer-events: none;
}

/* 设置页分隔线 */
.form-divider {
  height: 0.5px;
  background: var(--border);
  margin: 8px 0 20px;
}

/* 状态配置列表 */
.status-config-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
}

.status-config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border);
  gap: 8px;
}
.status-config-row:last-child { border-bottom: none; }

.status-config-name {
  font-size: 0.9375rem;
  color: var(--text-primary);
  flex: 1;
}

.status-config-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.status-config-lock {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* 颜色选择器圆点 */
.color-dot-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.1);
  cursor: pointer;
  padding: 0;
  position: relative;
  overflow: hidden;
}
.color-dot-btn input[type="color"] {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}

/* 锁定 toggle（小开关） */
.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 10px;
  transition: background 0.2s ease;
  cursor: pointer;
}
.toggle-track::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 2px; top: 2px;
  background: var(--white);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.2s ease;
}
.toggle-switch input:checked + .toggle-track {
  background: var(--black);
}
.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(16px);
}

/* 状态名称可编辑输入框 */
.status-name-input {
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: none;
  border: none;
  padding: 8px 8px;
  flex: 1;
  min-width: 0;
  border-radius: 6px;
  font-family: var(--font-display);
  -webkit-user-select: text;
  user-select: text;
  min-height: 38px;
}
.status-name-input:focus {
  outline: none;
  background: var(--card);
}

/* 状态删除按钮 */
.status-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: color 0.15s;
}
.status-delete-btn:active { color: var(--danger); }

/* 新增状态按钮 */
.status-add-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 12px 0 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-family: var(--font-display);
  color: var(--blue);
}

/* 数据 sheet tab 栏 */
.data-tab-bar {
  display: flex;
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin: 0 24px 16px;
  position: relative;
}
.data-tab-slider {
  position: absolute;
  top: 3px; left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: var(--white);
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.data-tab-btn {
  flex: 1;
  padding: 8px 16px;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: var(--font-display);
  background: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.25s ease;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  -webkit-tap-highlight-color: transparent;
}
.data-tab-btn.active { color: var(--text-primary); }

/* 数据 sheet 滑动面板 */
.data-panels-wrap { overflow: hidden; }
.data-panels {
  display: flex;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.data-panel {
  width: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 340px;
}

/* 虚拟休息记录（当月无数据的过去日期） */
.record-virtual { opacity: 0.45; }

/* 刷新按钮旋转动画 */
.spinning svg { animation: spin 0.8s linear infinite; }

/* --- Status Grid --- */
.status-grid { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; }
.status-grid::-webkit-scrollbar { display: none; }

.status-chip {
  padding: 10px 14px; font-size: 0.8125rem; font-weight: 500;
  font-family: var(--font-display);
  background: var(--card); border: 2px solid transparent;
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-secondary); transition: all 0.2s ease;
  text-align: center; white-space: nowrap; flex-shrink: 0;
}
.status-chip:hover { background: var(--card-hover); }
.status-chip.active { background: var(--black); color: var(--white); border-color: var(--black); }

/* --- Buttons --- */
.sheet-actions { padding: 20px 24px; display: flex; flex-direction: column; gap: 10px; }

.btn-save {
  width: 100%; padding: 16px; font-size: 1rem; font-weight: 600;
  font-family: var(--font-display);
  background: var(--black); color: var(--white);
  border: none; border-radius: var(--radius-md);
  cursor: pointer; transition: all 0.25s ease;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-save:hover { background: #333; }
.btn-save:active { transform: scale(0.98); }
.btn-save:disabled { background: var(--text-tertiary); cursor: not-allowed; transform: none; }

.btn-save .spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn-delete {
  width: 100%; padding: 14px; font-size: 0.9375rem; font-weight: 500;
  font-family: var(--font-display);
  background: var(--danger-bg); color: var(--danger);
  border: none; border-radius: var(--radius-md);
  cursor: pointer; transition: all 0.2s ease;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-delete:hover { background: #FFE5E3; }
.btn-delete:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Import/Export --- */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius-md);
  padding: 32px; text-align: center; cursor: pointer;
  transition: all 0.25s ease; position: relative;
}
.upload-zone:hover { border-color: var(--text-tertiary); background: var(--card); }
.upload-zone-icon { font-size: 2rem; margin-bottom: 8px; }
.upload-zone p { font-size: 0.875rem; color: var(--text-tertiary); }
.upload-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.textarea-paste {
  width: 100%; min-height: 120px; padding: 14px 16px;
  font-size: 0.8125rem; font-family: var(--font-mono);
  background: var(--card); border: 2px solid transparent;
  border-radius: var(--radius-sm); color: var(--text-primary);
  outline: none; resize: vertical; transition: border-color 0.25s ease;
}
.textarea-paste:focus { border-color: var(--black); }

.textarea-export {
  width: 100%; min-height: 150px; padding: 14px 16px;
  font-size: 0.75rem; font-family: var(--font-mono);
  background: var(--card); border: 2px solid transparent;
  border-radius: var(--radius-sm); color: var(--text-secondary);
  outline: none; resize: vertical;
}

/* --- Toast --- */
.toast {
  position: fixed; top: calc(20px + var(--safe-top)); left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--black); color: var(--white);
  padding: 12px 24px; border-radius: var(--radius-md);
  font-size: 0.875rem; font-weight: 500;
  z-index: 999;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-lg); white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ============================================================
   Passkey — 登录页
   ============================================================ */
.btn-passkey {
  width: 100%;
  padding: 16px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-display);
  background: var(--white);
  color: var(--text-primary);
  border: 2px solid var(--black);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  letter-spacing: -0.01em;
}
.btn-passkey:hover { background: var(--card); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-passkey:active { transform: scale(0.98); }
.btn-passkey:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-passkey svg { flex-shrink: 0; }

.spinner-dark {
  width: 18px; height: 18px;
  border: 2px solid rgba(0,0,0,0.15);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
  color: var(--text-tertiary);
  font-size: 0.8125rem;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============================================================
   Passkey — 设置页
   ============================================================ */
.settings-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

.passkey-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.passkey-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--card);
  border-radius: var(--radius-sm);
  transition: background 0.2s ease;
}
.passkey-item:hover { background: var(--card-hover); }

.passkey-info { flex: 1; min-width: 0; }
.passkey-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.passkey-date {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 2px;
  font-family: var(--font-mono);
}

.passkey-del-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  color: var(--text-tertiary); cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.passkey-del-btn:hover { background: var(--danger-bg); color: var(--danger); }

.passkey-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

.btn-reg-passkey {
  width: 100%;
  padding: 14px;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: var(--font-display);
  background: var(--card);
  color: var(--text-primary);
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-reg-passkey:hover { background: var(--card-hover); border-color: var(--text-tertiary); }
.btn-reg-passkey:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-reg-passkey .spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(0,0,0,0.15);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* --- Responsive --- */
@media (max-width: 420px) {
  .record-item { grid-template-columns: 1fr auto auto auto; gap: 6px; padding: 12px 14px; }
  .record-badge { display: none; }
  .nav-btn span.hide-sm { display: none; }
  .stats-bar { padding: 6px 2px; }
  .stat-val { font-size: 1rem; }
  .stats-nav-btn { width: 24px; height: 24px; min-width: 24px; }
}