/* 浏览器专属样式：重置、桌面外壳、底部 tab、toast / 对话框 / 加载遮罩
   注意：从 WXSS 自动转换出来的样式在 app.css 里，本文件只放新增部分。 */

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  background: #F4F4F7;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #F4F4F7;
  color: #26262E;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* PWA 模式（加到主屏后）下拉时不要触发浏览器刷新 */
  overscroll-behavior-y: contain;
}

/* 桌面端：手机壳居中，避免在大屏上被拉伸成一条 */
#app {
  position: relative;
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  margin: 0 auto;
  background: #FFFFFF;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
}

#view {
  display: block;
  min-height: 100vh;
  padding-bottom: 64px; /* 给底部 tab 留位 */
}

#view.no-tabbar { padding-bottom: 0; }

/* ---------- 原生控件的观感对齐（小程序里这些是内置组件） ---------- */

button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

input, textarea {
  font: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
  -webkit-appearance: none;
  appearance: none;
}

textarea { resize: none; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: #F0F0F4;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: #F87060;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

input[type="date"] { min-height: 24px; }

/* 日期选择：透明 input 铺满整块区域，点哪儿都能唤起系统选择器（对应小程序的 <picker>） */
.picker {
  position: relative;
  cursor: pointer;
}

.picker input[type="date"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* 备份/导入之类的行入口（小程序里是 navigator） */
.nav {
  display: flex;
  align-items: center;
  padding: 14px 0;
  cursor: pointer;
}

.nav__body { flex: 1; padding-right: 12px; }
.nav__title { font-size: 15px; font-weight: 500; color: #26262E; }
.nav__desc { margin-top: 4px; font-size: 12px; line-height: 1.6; color: #B4B4BC; }
.nav__arrow { flex: 0 0 auto; font-size: 20px; color: #C9C9D1; }

/* 开关：用 CSS 重做小程序的 <switch> */
.switch {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.switch__track {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: #E9E9EB;
  transition: background 0.2s;
  pointer-events: none;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.switch input:checked + .switch__track { background: #F87060; }
.switch input:checked + .switch__track::after { transform: translateX(20px); }

/* ---------- 底部 tab ---------- */

#tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  display: flex;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid #F0F0F4;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}

#tabbar[hidden] { display: none; }

.tab {
  flex: 1;
  padding: 10px 0 12px;
  color: #B4B4BC;
  font-size: 12px;
  text-align: center;
  transition: color 0.15s;
}

.tab--on { color: #F87060; font-weight: 500; }

.tab__text { display: block; }

/* ---------- 顶部返回栏（非 tab 页用） ---------- */

.navbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 6px;
  height: calc(48px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid #F0F0F4;
  font-size: 15px;
  font-weight: 500;
}

.navbar__back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: #F87060;
  font-size: 15px;
  padding: 6px 8px 6px 0;
}

.navbar__title { color: #26262E; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.94);
  min-width: 120px;
  max-width: 260px;
  padding: 14px 20px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.78);
  color: #FFFFFF;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}

.toast--on { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.toast__icon {
  display: block;
  font-size: 22px;
  margin-bottom: 4px;
}

.toast__text { display: block; }

/* ---------- 加载遮罩 ---------- */

.loading-mask {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 90;
}

.loading-mask--on { opacity: 1; pointer-events: auto; }

.loading-mask__box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 120px;
  padding: 20px 22px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.78);
  color: #FFFFFF;
  font-size: 14px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 对话框 ---------- */

.dialog-mask {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(0, 0, 0, 0.42);
  z-index: 110;
}

.dialog {
  width: 100%;
  max-width: 320px;
  padding: 24px 20px 0;
  border-radius: 16px;
  background: #FFFFFF;
  text-align: center;
  animation: dialog-in 0.18s ease-out;
}

@keyframes dialog-in {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.dialog__title { font-size: 16px; font-weight: 600; color: #26262E; }

.dialog__content {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.65;
  color: #76767F;
  text-align: left;
}

.dialog__actions {
  display: flex;
  margin: 20px -20px 0;
  border-top: 1px solid #F0F0F4;
}

.dialog__btn {
  flex: 1;
  padding: 14px 8px;
  font-size: 16px;
  color: #76767F;
}

.dialog__btn + .dialog__btn { border-left: 1px solid #F0F0F4; }
.dialog__btn--ok { color: #F87060; font-weight: 500; }
.dialog__btn--danger { color: #E24B4A; }

/* ---------- 安装提示条（PWA：可加到主屏幕时显示） ---------- */

.install-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(64px + env(safe-area-inset-bottom));
  width: calc(100% - 32px);
  max-width: 398px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #26262E;
  color: #FFFFFF;
  font-size: 13px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
  z-index: 60;
}

.install-bar__text { flex: 1; line-height: 1.5; }

.install-bar__btn {
  flex: 0 0 auto;
  padding: 6px 14px;
  border-radius: 999px;
  background: #F87060;
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 500;
}

.install-bar__close {
  flex: 0 0 auto;
  padding: 4px 6px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 16px;
  line-height: 1;
}

/* 小屏（比 375 设计稿更窄）时收紧一点留白，避免挤在一起 */
@media (max-width: 360px) {
  .page { padding-left: 12px !important; padding-right: 12px !important; }
}

/* ---------- 测试数据标记（测试模式下产生的记录） ---------- */

.test-banner {
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #FFF6E5;
  border: 1px solid #F3D9A4;
  color: #9C6B1E;
  font-size: 12px;
  line-height: 1.6;
}

/* 测试数据：真实记录是实心圆，测试数据改成灰色虚线圈，一眼能分开 */
.cell--test .num--recorded-period,
.cell--test .num--inferred-period {
  background: transparent;
  border: 1.5px dashed #B0B0BC;
  color: #85858E;
  font-weight: 500;
}

.cell--test .num--predicted-period {
  border-color: #C9C9D3;
  color: #A6A6B0;
}

.test-mark {
  margin-top: 1px;
  font-size: 9px;
  line-height: 1;
  color: #A6A6B0;
}

.grid--mini .test-mark { display: none; }

.sheet__test {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #FFF6E5;
  color: #9C6B1E;
  font-size: 12px;
  line-height: 1.6;
}

/* ---------- 登录页（极简：品牌 + 用户名 + 密码 + 登录） ---------- */

.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 64px); /* 减去 #view 给 tab 栏留的底高 */
  padding: 32px 28px 96px;
}

.login__box {
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.login__logo {
  line-height: 0;
  margin-bottom: 14px;
}

.login__logo svg {
  filter: drop-shadow(0 6px 16px rgba(248, 112, 96, 0.28));
}

.login__title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #26262E;
  margin-bottom: 36px;
}

.login__form {
  text-align: left;
}

.login__field {
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 16px;
  margin-bottom: 12px;
  border-radius: 14px;
  background: #F6F6F9;
  border: 1.5px solid transparent;
  transition: border-color 0.15s, background 0.15s;
  cursor: text;
}

.login__field:focus-within {
  background: #FFFFFF;
  border-color: #F87060;
}

.login__field input {
  flex: 1;
  width: 100%;
  height: 100%;
  /* iOS 上小于 16px 的输入框会触发页面自动缩放，这里必须 ≥16px */
  font-size: 16px;
  color: #26262E;
  background: transparent;
}

.login__field input::placeholder {
  color: #B4B4BC;
}

.login__error {
  min-height: 20px;
  margin: 2px 0 10px;
  font-size: 13px;
  line-height: 20px;
  color: #E24B4A;
}

.login__submit {
  width: 100%;
  height: 52px;
  border-radius: 14px;
  background: #F87060;
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.login__submit:hover { background: #E85C4C; }
.login__submit:active { transform: scale(0.985); }
.login__submit[disabled] { opacity: 0.55; cursor: default; }

.login__hint {
  margin-top: 14px;
  font-size: 12px;
  color: #C98A2E;
  text-align: center;
}
