:root {
  --blue: #1a73e8;
  --blue-dark: #1558b0;
  --green: #0f9d58;
  --red: #d93025;
  --text: #1f2328;
  --muted: #6b7280;
  --bg: #f2f4f7;
  --card: #ffffff;
  --border: #e5e7eb;
  --radius: 14px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* hidden 属性必须胜过任何 display 值 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  flex: 1;
}

.profile-switch { margin-right: 4px; }

.profile-switch select {
  padding: 7px 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 24px;
  background-image: linear-gradient(45deg, transparent 50%, #fff 50%),
    linear-gradient(135deg, #fff 50%, transparent 50%);
  background-position: calc(100% - 13px) 52%, calc(100% - 8px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.profile-switch select option {
  color: #1f2328;
  background: #fff;
}

.icon-btn {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 8px;
}

.icon-btn:active { background: rgba(255, 255, 255, 0.2); }

/* ---------- 页面容器 ---------- */
main {
  padding: 14px 14px 96px;
  max-width: 560px;
  margin: 0 auto;
}

.page { display: none; }
.page.active { display: block; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.card-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- 表单 ---------- */
.field, .switch-row, .date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.field:last-child, .switch-row:last-child, .date-row:last-child { border-bottom: none; }

.field label, .switch-row .switch-label, .date-row label {
  flex: 1;
  font-size: 16px;
}

.field-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.field-col label { font-size: 16px; }

input[type="number"],
input[type="date"],
select {
  font-size: 17px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  text-align: right;
  min-width: 0;
  font-family: inherit;
}

select { text-align: left; }
input:focus, select:focus { outline: none; border-color: var(--blue); }

/* ---------- 步进器 ---------- */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.stepper button {
  width: 46px;
  height: 46px;
  border: none;
  background: #f3f6fb;
  color: var(--blue);
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
}

.stepper button:active { background: #e2eaf7; }

.stepper input {
  width: 72px;
  border: none;
  border-radius: 0;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  padding: 10px 0;
}

/* ---------- 开关 ---------- */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.switch-label { font-size: 16px; }

.switch {
  position: relative;
  display: inline-block;
  width: 68px;
  height: 32px;
  flex: 0 0 68px;
  cursor: pointer;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.slider {
  position: absolute;
  inset: 0;
  background: #d4d9e0;
  border-radius: 32px;
  transition: background 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 26px;
  width: 26px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  z-index: 2;
}

.switch-text {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  z-index: 1;
  transition: 0.2s;
  pointer-events: none;
}

.switch input:checked ~ .slider { background: var(--green); }
.switch input:checked ~ .slider::before { transform: translateX(36px); }
.switch input:checked ~ .switch-text { right: auto; left: 11px; }

.recorded-badge {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--green);
  text-align: center;
  font-weight: 600;
}

.role-hint {
  text-align: left;
  font-size: 13px;
  line-height: 1.6;
  margin-top: 4px;
}

/* ---------- 法律合规提示 ---------- */
.legal-tip,
.legal-panel {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff8e6;
  border: 1px solid #f0d9a0;
  font-size: 13px;
  line-height: 1.7;
  color: #7a5a12;
}

.legal-tip .legal-line,
.legal-panel .legal-line {
  margin-bottom: 6px;
}

.legal-tip .legal-line:last-child,
.legal-panel .legal-line:last-child,
.legal-panel > div:last-child {
  margin-bottom: 0;
}

.legal-ok {
  color: var(--green);
  font-weight: 600;
}

.legal-warn {
  color: #b45309;
  font-weight: 600;
}

.legal-note {
  margin-top: 6px;
  color: #8a6d3b;
  font-size: 12px;
  line-height: 1.6;
}

.legal-src {
  text-align: left;
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.6;
}

/* ---------- 日期快捷选择 ---------- */
.date-quick {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 4px;
}

.quick-btn {
  flex: 1;
  padding: 9px 0;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #f7f9fc;
  color: var(--blue-dark);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
}

.quick-btn:active,
.quick-btn.on {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.weekday-hint {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  min-width: 64px;
  text-align: right;
}

.weekday-hint.weekend { color: #e8710a; }

/* ---------- 日期性质标签 ---------- */
.day-kind {
  margin: 2px 0 10px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.kind-weekend {
  background: #fff4e5;
  color: #b26a00;
}

.kind-holiday {
  background: #fde8e8;
  color: #c5221f;
}

.kind-makeup {
  background: #eef4fe;
  color: var(--blue-dark);
}

/* ---------- 按钮 ---------- */
.primary-btn {
  width: 100%;
  padding: 16px;
  margin-top: 16px;
  border: none;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-size: 19px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.primary-btn:active { background: var(--blue-dark); }

.danger-btn {
  width: 100%;
  padding: 14px;
  border: 1.5px solid var(--red);
  border-radius: 12px;
  background: #fff;
  color: var(--red);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.ghost-btn {
  display: block;
  width: 100%;
  padding: 13px;
  margin-bottom: 10px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #f7f9fc;
  color: var(--blue-dark);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
}

.ghost-btn:active { background: #e8eef8; }

.file-label { box-sizing: border-box; }

.backup-hint {
  text-align: left;
  margin: 0 0 12px;
}

.hint {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}

/* ---------- 今日预览 ---------- */
.today-result {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: #eef4fe;
  color: var(--blue-dark);
  font-size: 20px;
  font-weight: 700;
  text-align: center;
}

/* ---------- 账本 ---------- */
.month-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.month-head strong { font-size: 17px; }
.month-head .icon-btn { color: var(--blue); font-size: 26px; }

/* ---------- 结算周期切换 ---------- */
.period-switch {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.period-btn {
  flex: 1;
  padding: 8px 0;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: #f7f9fc;
  color: var(--muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.period-btn.on {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 600;
}

.period-legal {
  margin: -6px 0 14px;
  font-size: 12px;
  line-height: 1.6;
  color: #8a6d3b;
}

.stat-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  flex: 1;
  background: #f7f9fc;
  border-radius: 12px;
  padding: 12px 6px;
  text-align: center;
}

.stat span {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--blue);
}

.stat small {
  font-size: 12px;
  color: var(--muted);
}

.breakdown {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

.breakdown td {
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
}

.breakdown td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.breakdown tr.total td {
  font-size: 18px;
  font-weight: 700;
  color: var(--blue-dark);
  border-bottom: 2px solid var(--blue);
  background: #f7fafe;
}

.breakdown tr.warn-row td {
  color: #c77700;
  background: #fff8ec;
}

.breakdown .sub {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.compare {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.compare label { font-size: 15px; color: var(--muted); }

.diff {
  padding: 14px;
  border-radius: 12px;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  display: none;
}

.diff.show { display: block; }
.diff.ok { background: #e6f4ea; color: var(--green); }
.diff.warn { background: #fce8e6; color: var(--red); }

/* ---------- 每天记录列表 ---------- */
.day-list { list-style: none; margin: 0; padding: 0; }

.day-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}

.day-list li:last-child { border-bottom: none; }

.day-list .day-date { font-weight: 600; min-width: 88px; }
.day-list .day-detail { flex: 1; color: var(--muted); font-size: 13px; }
.day-list .day-money { font-weight: 700; color: var(--blue-dark); }
.day-list .day-del {
  border: none;
  background: transparent;
  color: #c0c4cc;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}

.empty-tip {
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  padding: 24px 0;
}

/* ---------- 底部标签栏 ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.tab span { font-size: 21px; line-height: 1; }
.tab.active { color: var(--blue); font-weight: 600; }

/* ============================================================
 *  首屏模板选择
 * ============================================================ */
.wizard {
  padding: 32px 20px;
  max-width: 560px;
  margin: 0 auto;
}
.wizard-title {
  font-size: 22px;
  margin: 0 0 6px;
  text-align: center;
}
.wizard-sub {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  margin: 0 0 22px;
}
.wizard-foot {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 24px;
}
.template-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tmpl-card {
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 14px;
  padding: 16px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.tmpl-card:active { background: #f0f5ff; border-color: var(--blue); }
.tmpl-icon { grid-row: 1 / 3; font-size: 30px; text-align: center; }
.tmpl-name { font-size: 17px; font-weight: 600; color: var(--text); }
.tmpl-desc { font-size: 13px; color: var(--muted); }

/* ============================================================
 *  账套管理弹层
 * ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  max-height: 84vh;
  overflow-y: auto;
}
.modal-box h3 { margin: 0 0 14px; font-size: 17px; }
.profile-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.profile-name { flex: 1; font-size: 15px; font-weight: 600; }
.profile-tmpl { color: var(--muted); font-size: 12px; }
.row-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f9fc;
  color: var(--blue-dark);
  font-size: 13px;
  padding: 5px 10px;
  font-family: inherit;
  cursor: pointer;
}
.row-btn.danger { color: var(--red); }

/* ============================================================
 *  计件单价编辑
 * ============================================================ */
.rate-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.rate-row .rate-name { flex: 1; min-width: 0; font-size: 15px; padding: 8px 10px; border: 1.5px solid var(--border); border-radius: 8px; font-family: inherit; }
.rate-row .rate-val { width: 84px; font-size: 15px; padding: 8px 10px; border: 1.5px solid var(--border); border-radius: 8px; font-family: inherit; }
.rate-row .rate-del {
  width: 38px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: #9aa3ad;
  cursor: pointer;
  font-family: inherit;
}
.ghost-btn.small { padding: 9px; font-size: 14px; }
.calc-hint { text-align: left; }

/* ============================================================
 *  最低工资速查
 * ============================================================ */
.mini-btn {
  flex: none;
  padding: 8px 12px;
  border: 1.5px solid var(--blue);
  border-radius: 9px;
  background: #eef4fe;
  color: var(--blue);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  margin-left: 8px;
}
.mw-tip { text-align: left; margin: 0 0 10px; }
.mw-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 11px 4px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.mw-row:active { background: #f0f5ff; }
.mw-row b { color: var(--blue-dark); font-weight: 600; }
