:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #7a8194;
  --accent: #4e79a7;
  --border: #e5e7ee;
  --green: #2e9e5b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* 布局 */
#app {
  max-width: 620px;
  margin: 0 auto;
  padding-bottom: 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
}
.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

main { padding: 16px; }
.card-block {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.card-block h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

/* 卡片 */
.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}
.card:last-child { margin-bottom: 0; }
.card-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.card-status {
  color: var(--muted);
  font-size: 14px;
  margin: 6px 0 10px;
}
.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* 按钮（大点击区域） */
.btn {
  display: inline-block;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: #fff;
  color: var(--accent);
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  line-height: 1.4;
}
.btn.big { width: 100%; font-weight: 600; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.square { min-width: 44px; padding: 6px 0; font-size: 20px; }
.btn.ghost {
  border-color: #c9cedb;
  color: var(--muted);
  background: #f7f8fa;
}
.btn.on { background: var(--accent); color: #fff; }
.btn.save { background: var(--accent); color: #fff; }

/* 登录 */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card {
  background: var(--card);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}
.login-card h1 {
  margin: 0 0 20px;
  font-size: 22px;
  text-align: center;
}
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  color: var(--muted);
}
.login-card label.remember {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
  user-select: none;
}
.login-card label.remember input {
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  flex: none;
}
.login-card input {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
}
.error { color: #c0392b; font-size: 14px; margin: 12px 0 0; text-align: center; }

/* 日历 */
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cal-head h2 { margin: 0; font-size: 17px; }
.cal-block {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 14px;
}
.cal-block:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 4px;
}
.cal-helper-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 6px;
}
.cal-helper-name { flex: 1; min-width: 0; }
.cal-block.batch-active {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 10px;
  padding: 10px 8px 8px;
  margin-left: -8px;
  margin-right: -8px;
  background: #f7f9fc;
}
.batch-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  font-weight: 400;
}
.batch-hint {
  font-size: 13px;
  color: var(--muted);
}
.batch-choices {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.batch-other-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}
.batch-other-input {
  width: 88px;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
}
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}
.cal-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-wd {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 0;
}
.cal-cell {
  position: relative;
  min-height: 46px;
  border-radius: 8px;
  background: #fafbfc;
  padding: 4px 2px;
  cursor: pointer;
  text-align: center;
}
.cal-cell.blank { background: transparent; cursor: default; }
.cal-cell.today { outline: 2px solid var(--accent); }
.cal-cell.out-of-period {
  opacity: 0.35;
  cursor: default;
  background: #eef0f4;
}
.cal-cell.settle-day {
  outline: 2px solid #2e9e5b;
}
.cal-sub {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 400;
}
.cal-empty {
  grid-column: 1 / -1;
  padding: 16px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.cal-num { font-size: 14px; line-height: 1.2; }
.cal-mark {
  display: flex;
  justify-content: center;
  margin-top: 4px;
  min-height: 8px;
}
.cal-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
}
.cal-dot.h2 { background: #4e79a7; }
.cal-dot.h25 { background: #f28e2b; }
.cal-dot.d1 { background: #2e9e5b; }
.cal-dot.d05 { background: #76b7b2; }
.cal-dot.hother { background: #b07aa1; }
.cal-dot.livein { background: #2e9e5b; }
.batch-other-swatch { flex-shrink: 0; }

/* 汇总表 */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}
th, td {
  text-align: left;
  padding: 8px 6px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
th { color: var(--muted); font-weight: 500; }
td .dot { margin-right: 6px; vertical-align: middle; }
.summary-row { cursor: pointer; }
.summary-row:hover td { background: #f0f3f8; }
.summary-row.open td { background: #eef3f9; }
.summary-detail td {
  padding: 0 6px 12px;
  border-bottom: 1px solid var(--border);
  background: #f8f9fc;
}
.calc-box {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
}

/* 设置 */
.collapsible {
  width: 100%;
  min-height: 48px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  padding: 4px 0;
}
.setting-item {
  border-top: 1px solid var(--border);
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.setting-item:first-child { border-top: none; }
.setting-name { font-weight: 600; }
.setting-item label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}
.setting-item input {
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  flex: 1;
}
.daily-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  min-height: 40px;
  padding: 0 2px;
}
.daily-out {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* 底部弹层 */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}
.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 85vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sheet-head h3 { margin: 0; font-size: 18px; }
.sheet-helper {
  border-top: 1px solid var(--border);
  padding: 14px 0;
}
.sheet-helper:first-child { border-top: none; padding-top: 0; }
.sheet-helper-name { font-weight: 600; margin-bottom: 8px; }
.sheet-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 16px;
}
.sheet-check input { width: 22px; height: 22px; }
.sheet-hours { display: flex; gap: 8px; margin-bottom: 8px; }
.sheet-hours input {
  flex: 1;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
}
.sheet-helper > input[type="text"] {
  width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  margin-bottom: 8px;
}

/* 工时输入弹窗 */
.hours-dialog {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.hours-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}
.hours-dialog-card {
  position: relative;
  width: 100%;
  max-width: 340px;
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}
.hours-dialog-card h3 {
  margin: 0 0 12px;
  font-size: 18px;
}
.hours-dialog-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}
.hours-dialog-card input {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
}
.hours-dialog-card .btn-row { margin-top: 14px; }
.hours-dialog-card .btn { flex: 1; }

footer {
  text-align: center;
  padding: 16px;
}
footer a {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}
