:root {
  --bg: #f0f2f8;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-press: #4338ca;
  --primary-soft: #eef2ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --danger: #dc2626;
  --warn: #c2410c;
  --border: #e2e8f0;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 400px at 10% -10%, #c7d2fe 0%, transparent 55%),
    radial-gradient(900px 300px at 100% 0%, #a5f3fc 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
.app {
  max-width: 560px; margin: 0 auto; min-height: 100vh;
  padding: 14px 14px calc(84px + var(--safe-bottom));
}
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin-bottom: 14px;
}
.brand { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.brand-sub { color: var(--muted); font-size: 12px; margin-top: 2px; max-width: 220px; line-height: 1.35; }
.topbar select {
  max-width: 48%; padding: 9px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: rgba(255,255,255,.9);
  box-shadow: var(--shadow);
}
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
  border: 1px solid rgba(226,232,240,.8);
}
.card.accent {
  background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
  border-color: #c7d2fe;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 10px;
}
.card h2 { margin: 0; font-size: 16px; font-weight: 700; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.5; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; min-width: 0; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; margin-bottom: 6px; color: #334155; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: 12px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.field textarea { min-height: 96px; resize: vertical; }
.field.check label {
  display: flex; align-items: center; gap: 8px; font-weight: 500;
  padding: 10px 12px; background: #f8fafc; border-radius: 12px; border: 1px solid var(--border);
}
.btn {
  appearance: none; border: none; border-radius: 12px;
  padding: 12px 14px; background: var(--primary); color: #fff;
  font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 16px rgba(79,70,229,.25);
}
.btn:active { background: var(--primary-press); }
.btn.secondary { background: var(--primary-soft); color: #3730a3; box-shadow: none; }
.btn.ghost { background: #f1f5f9; color: #0f172a; box-shadow: none; }
.btn.danger { background: #fee2e2; color: #b91c1c; box-shadow: none; }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 10px; font-size: 12px; border-radius: 10px; box-shadow: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex; justify-content: center;
  padding-bottom: var(--safe-bottom);
  z-index: 20;
}
.tabs .inner { width: 100%; max-width: 560px; display: flex; }
.tabs button {
  flex: 1; border: 0; background: transparent; padding: 10px 0 8px;
  color: var(--muted); font-size: 11px; cursor: pointer;
}
.tabs button.active { color: var(--primary); font-weight: 800; }
.tabs .ico { display: block; font-size: 18px; line-height: 1.2; }
.pill {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px;
  background: var(--primary-soft); color: #4338ca;
  font-size: 11px; font-weight: 700;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--ok-soft); color: var(--ok); font-size: 12px; font-weight: 700;
}
.list-item {
  border-top: 1px solid var(--border); padding: 12px 0;
}
.list-item:first-child { border-top: 0; padding-top: 4px; }
.wage-total { font-size: 32px; font-weight: 800; color: var(--primary); letter-spacing: -0.03em; }
.stat-hero { text-align: center; padding: 8px 0 16px; border-bottom: 1px dashed var(--border); margin-bottom: 8px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.tiny { font-size: 11px; color: var(--muted); margin-top: 6px; }
.err { color: var(--danger); font-size: 13px; margin-top: 8px; }
.okmsg { color: var(--ok); font-size: 13px; margin-top: 8px; }
.hidden { display: none !important; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #f1f5f9; border-radius: 999px; padding: 4px 10px;
  font-size: 12px; margin: 2px;
}
.live-wage {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px; padding: 12px 14px; border-radius: 12px;
  background: linear-gradient(135deg, #eef2ff, #ecfeff);
  border: 1px solid #c7d2fe;
}
.live-wage strong { font-size: 22px; color: var(--primary); }
.sample-card {
  border: 1px solid var(--border); border-radius: 14px;
  padding: 12px; margin-bottom: 10px; background: #f8fafc;
}
.sample-card h3 { margin: 0 0 6px; font-size: 14px; }
.sample-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px;
  font-size: 12px; margin: 8px 0;
}
.sample-grid .k { color: var(--muted); }
.sample-result {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 8px; border-top: 1px dashed var(--border); font-weight: 700;
}
.rel-card {
  border: 1px solid var(--border); border-radius: 14px;
  padding: 12px; margin-bottom: 10px; background: #fff;
}
.rel-card .title-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.item-row {
  display: flex; gap: 6px; align-items: center; margin-top: 8px;
}
.item-row input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
details summary {
  cursor: pointer; font-weight: 700; color: #4338ca; list-style: none;
}
details summary::-webkit-details-marker { display: none; }
.stat-row {
  display: flex; justify-content: space-between; gap: 10px; align-items: flex-start;
  padding: 12px 0; border-top: 1px solid var(--border);
}
.stat-row:first-child { border-top: 0; }
.stat-sums { font-size: 12px; color: var(--muted); margin-top: 4px; }
@media (min-width: 720px) {
  .app { max-width: 720px; padding-top: 20px; }
}

.overwrite-check {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 12px; padding: 12px 14px;
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: 12px;
  font-size: 13px; font-weight: 600; color: #9a3412; cursor: pointer;
}
.overwrite-check input { margin-top: 2px; width: 16px; height: 16px; flex-shrink: 0; }
.diff-block { margin-bottom: 10px; padding: 10px 12px; border-radius: 12px; background: #f8fafc; border: 1px solid var(--border); }
.diff-block.warn { background: #fff7ed; border-color: #fed7aa; }
.diff-title { font-size: 12px; font-weight: 800; color: #334155; margin-bottom: 6px; }
.diff-block.warn .diff-title { color: #c2410c; }
.diff-row { font-size: 13px; padding: 4px 0; line-height: 1.4; }
.diff-row code { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; font-size: 12px; }
