:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #f7f9f8;
  --line: #dfe5e2;
  --text: #17211e;
  --muted: #5d6b66;
  --brand: #1f4e46;
  --brand-2: #2c6b60;
  --brand-soft: #e3efec;
  --ok: #1d7a4c;
  --ok-soft: #e1f3e8;
  --bad: #b5362c;
  --bad-soft: #fbe7e4;
  --na: #6b6f78;
  --na-soft: #eceef1;
  --warn: #9a5b00;
  --warn-soft: #fff1d6;
  --radius: 14px;
  --nav-h: 64px;
  --shadow: 0 1px 2px rgba(15, 30, 25, .06), 0 2px 8px rgba(15, 30, 25, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.boot { padding: 40vh 16px 0; text-align: center; color: var(--muted); }

/* ---------- 상단 ---------- */
.testbar {
  background: var(--warn-soft);
  color: var(--warn);
  border-bottom: 1px solid #f1d59a;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  text-align: center;
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--brand);
  color: #fff;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 10px;
}
.topbar h1 { font-size: 17px; margin: 0; flex: 1; font-weight: 700; letter-spacing: -.01em; }
.topbar h1 small { display: block; font-size: 12px; font-weight: 500; opacity: .8; }
.topbar .who { font-size: 13px; text-align: right; opacity: .95; }
.topbar .who b { display: block; font-size: 14px; }
.btn-ghost-light {
  background: rgba(255,255,255,.14); border: 0; color: #fff;
  border-radius: 10px; padding: 7px 10px; font-size: 13px;
}

main {
  max-width: 760px; margin: 0 auto;
  padding: 14px 16px calc(var(--nav-h) + 90px + env(safe-area-inset-bottom));
}

/* ---------- 하단 탭 ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  flex: 1; min-height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600;
}
.nav a svg { width: 24px; height: 24px; }
.nav a.on { color: var(--brand); }
.nav a.on svg { stroke: var(--brand); }

/* ---------- 카드 · 폼 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.card h2 { font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card h2 .num {
  width: 24px; height: 24px; border-radius: 8px; background: var(--brand-soft); color: var(--brand);
  font-size: 13px; display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.card .hint { color: var(--muted); font-size: 13px; margin: -6px 0 12px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 18px 4px 8px; }

label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], input[type=email], select, textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 10px 12px;
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea { min-height: 92px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); background: #fff; box-shadow: 0 0 0 3px var(--brand-soft); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.with-btn { display: flex; gap: 6px; }
.with-btn input { flex: 1; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 15px;
  white-space: nowrap;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-2); }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }

.savebar {
  position: fixed; left: 0; right: 0; z-index: 25;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(243,245,244,0));
  padding: 14px 16px 10px;
}
.savebar .inner { max-width: 760px; margin: 0 auto; display: flex; gap: 8px; align-items: center; }
.savebar .state { font-size: 13px; color: var(--muted); min-width: 64px; text-align: center; }
.savebar .state.dirty { color: var(--warn); font-weight: 700; }
.savebar .btn.primary { flex: 1; }

/* 계산 결과 */
.calc {
  display: flex; align-items: baseline; justify-content: space-between;
  background: var(--brand-soft); color: var(--brand);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 12px;
}
.calc b { font-size: 22px; }
.calc.err { background: var(--bad-soft); color: var(--bad); }
.calc.idle { background: var(--na-soft); color: var(--muted); }

/* 스테퍼 */
.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stepper { border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); padding: 8px 8px 8px 12px; }
.stepper > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.stepper .ctl { display: flex; align-items: center; gap: 4px; }
.stepper .ctl input { border: 0; background: transparent; min-height: 40px; padding: 0; text-align: center; font-size: 20px; font-weight: 700; box-shadow: none; }
.stepper .ctl button {
  width: 40px; height: 40px; flex: none; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); font-size: 20px; line-height: 1; color: var(--brand);
}

/* 칩 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 600; color: var(--muted);
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* 날짜 바 */
.datebar { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.datebar input { flex: 1; text-align: center; font-weight: 700; background: var(--surface); }
.datebar .btn { min-width: 48px; padding: 0 10px; }

/* 진행률 */
.progress { margin-bottom: 14px; }
.progress .bar { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .2s; }
.progress .lbl { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.progress .lbl b { color: var(--text); }

/* 체크리스트 */
.slot { font-size: 13px; font-weight: 800; color: var(--brand); margin: 18px 4px 8px; display: flex; align-items: center; gap: 8px; }
.slot::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.task { padding: 14px; }
.task.s-done { border-color: #b9e0c9; background: #fbfefc; }
.task.s-not_done { border-color: #f0c4bd; }
.task .t-head { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.task .t-title { font-weight: 700; font-size: 16px; }
.task .t-detail { color: var(--muted); font-size: 14px; margin: 2px 0 10px; }
.badge { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.badge.kakao { background: #fee500; color: #3a1d1d; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.na { background: var(--na-soft); color: var(--na); }
.badge.none { background: var(--warn-soft); color: var(--warn); }
.seg { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.seg button {
  min-height: 46px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 700; font-size: 15px; color: var(--muted);
}
.seg button.on.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.seg button.on.not_done { background: var(--bad); border-color: var(--bad); color: #fff; }
.seg button.on.na { background: var(--na); border-color: var(--na); color: #fff; }
.task .meta { font-size: 13px; color: var(--muted); margin-top: 8px; }
.task .meta b { color: var(--text); }

/* 목록 */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: block; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.item .i-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.item .i-sub { color: var(--muted); font-size: 14px; margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.item.cur { border-color: var(--brand-2); box-shadow: 0 0 0 2px var(--brand-soft); }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.stat b { font-size: 18px; }

/* 관리자 */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.tabs button {
  flex: none; min-height: 42px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 700; font-size: 14px; color: var(--muted);
}
.tabs button.on { background: var(--text); border-color: var(--text); color: #fff; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table.t { border-collapse: collapse; width: 100%; font-size: 14px; background: var(--surface); }
table.t th, table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
table.t th { background: var(--surface-2); font-size: 12px; color: var(--muted); }
table.t td.wrap { white-space: pre-wrap; min-width: 180px; }
table.t td.n { text-align: right; font-variant-numeric: tabular-nums; }
details.rep { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
details.rep summary { list-style: none; padding: 12px 14px; cursor: pointer; }
details.rep summary::-webkit-details-marker { display: none; }
details.rep .body { padding: 0 14px 12px; font-size: 14px; }
details.rep .body dl { margin: 0; }
details.rep .body dt { font-weight: 700; color: var(--brand); margin-top: 10px; }
details.rep .body dd { margin: 2px 0 0; white-space: pre-wrap; word-break: break-word; }

/* 로그인 */
.login { max-width: 420px; margin: 0 auto; padding: 8vh 16px 40px; }
.login .logo {
  width: 56px; height: 56px; border-radius: 16px; background: var(--brand);
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.login h1 { font-size: 22px; margin: 0 0 4px; }
.login p.sub { color: var(--muted); margin: 0 0 22px; }
.login .err { color: var(--bad); font-size: 14px; margin: 0 0 10px; min-height: 1em; }
.demo { display: grid; gap: 8px; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(var(--nav-h) + 86px + env(safe-area-inset-bottom));
  background: #1d2623; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad); }

/* v2 추가 */
a.who { display: block; text-decoration: none; color: #fff; text-align: right; line-height: 1.3; }
.muted-line { font-size: 13px; color: var(--muted); margin: 0 4px 12px; }
.flabel { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.i-time { color: var(--muted); font-weight: 500; font-size: 13px; }
.acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.person .p-head { display: flex; justify-content: space-between; align-items: center; font-size: 17px; margin-bottom: 8px; }
dl.kv { margin: 0; display: grid; grid-template-columns: 76px 1fr; gap: 8px 10px; font-size: 14px; }
dl.kv dt { color: var(--muted); font-weight: 700; font-size: 13px; padding-top: 1px; }
dl.kv dd { margin: 0; word-break: break-word; }
dl.kv .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
dl.kv .sub.bad { color: var(--bad); }
.handover { background: var(--warn-soft); color: #5b3a00; border-radius: 8px; padding: 6px 8px; }
.hist .i-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.hist .i-sub { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
table.diff td.before { color: var(--bad); }
table.diff td.after { color: var(--ok); }
table.diff i { color: var(--muted); font-style: normal; }
details.rep .i-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
details.rep .i-sub { color: var(--muted); font-size: 14px; }
details.rep .body table.t td { white-space: normal; }

@media (min-width: 720px) {
  .steppers { grid-template-columns: repeat(4, 1fr); }
}
