/* 세이프데일리 공통 스타일. 스마트폰 우선, 버튼 최소 44px, 시스템 글자 크기 반영 */
:root {
  --green: #1b5e3f; --green-dark: #144a31; --green-light: #e6f1ec;
  --ink: #1d1f1c; --ink-2: #4b4f4a; --ink-3: #7b807a;
  --bg: #f6f7f5; --card: #ffffff; --line: #dfe3dd;
  --danger: #b3261e; --warn: #a15c00; --warn-bg: #fff4e0;
  --radius: .875rem; --pad: 1rem;
  font-size: 100%;   /* 시스템 글자 크기 존중. 모든 크기는 rem 기반 */
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.5; font-size: 1.125rem;   /* 기본 18px, 50대 이상 기준 */
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
}
.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; padding: 0 var(--pad) calc(var(--pad) + env(safe-area-inset-bottom)); }
header.top { padding: calc(.875rem + env(safe-area-inset-top)) 0 .625rem; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
header.top h1 { font-size: 1.375rem; margin: 0; }
header.top .sub { color: var(--ink-3); font-size: .95rem; }
main { flex: 1; }
h1, h2, h3 { line-height: 1.25; }
h2 { font-size: 1.5rem; margin: 1.25rem 0 .5rem; }
p { margin: 8px 0; }
.muted { color: var(--ink-3); }
.small { font-size: .95rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--pad); margin: .75rem 0; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.center { text-align: center; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 3.5rem; padding: .75rem 1.125rem; border-radius: .75rem; border: 1px solid transparent;   /* 56px 이상 */
  font: inherit; font-weight: 700; font-size: 1.125rem; cursor: pointer; text-decoration: none;
  background: var(--green); color: #fff; transition: background .15s, opacity .15s;
}
.btn:active { background: var(--green-dark); }
.btn[disabled], .btn.disabled { opacity: .45; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--green); border-color: var(--green); }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn.kakao { background: #fee500; color: #191919; }
.btn.sm { min-height: 3.5rem; width: auto; padding: .5rem 1rem; font-size: 1rem; }
.btn.danger { background: var(--danger); }

/* 입력 */
label.field { display: block; margin: 12px 0; }
label.field span { display: block; font-size: 1rem; color: var(--ink-2); margin-bottom: .375rem; }
input[type=text], input[type=tel], input[type=number], input[type=password], select, textarea {
  width: 100%; min-height: 3.5rem; padding: .625rem .875rem; border: 1px solid var(--line); border-radius: .625rem;
  font: inherit; font-size: 1.125rem; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: var(--green); }
input.code { letter-spacing: .4em; text-align: center; font-size: 1.75rem; }
.check { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; cursor: pointer; }
.check input { width: 1.75rem; height: 1.75rem; margin: .125rem 0 0; accent-color: var(--green); flex: none; }

/* 체크리스트 항목 */
.items { list-style: none; margin: 0; padding: 0; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .875rem; margin: .625rem 0; }
.item .text { font-size: 1.25rem; line-height: 1.45; margin: 0 0 .75rem; }   /* 체크 항목 20px */
.item.done { border-color: var(--green); background: var(--green-light); }
.item.na { border-color: var(--line); background: #f1f2f0; color: var(--ink-3); }
.item .choices { display: flex; gap: .5rem; }
.choice {
  flex: 1; min-height: 3.5rem; border-radius: .75rem; border: 1px solid var(--line); background: #fff;
  font: inherit; font-size: 1.125rem; font-weight: 700; color: var(--ink-2); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.choice.on { background: var(--green); color: #fff; border-color: var(--green); }
.choice.na.on { background: var(--ink-3); border-color: var(--ink-3); }
.progress { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: .5rem 0; }
.bar { height: .5rem; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--green); transition: width .2s; }

/* 하단 고정 */
.footer-fixed {
  position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, transparent);
  padding: 12px 0 calc(8px + env(safe-area-inset-bottom)); margin-top: 8px;
}

/* 바텀 시트 */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 10; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; background: #fff; border-radius: 18px 18px 0 0;
  max-width: 560px; margin: 0 auto; padding: 14px var(--pad) calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,.15);
}
.sheet h3 { margin: 4px 0 10px; font-size: 1.15rem; }
canvas.sig { width: 100%; height: 12rem; border: 1px dashed var(--ink-3); border-radius: 12px; background: #fff; touch-action: none; display: block; }

/* 상태 */
.badge { display: inline-block; padding: .25rem .75rem; border-radius: 999px; font-size: .95rem; font-weight: 700; background: var(--green-light); color: var(--green); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.gray { background: #eceeea; color: var(--ink-2); }
.notice { border-left: .25rem solid var(--warn); background: var(--warn-bg); padding: .75rem; border-radius: .5rem; font-size: 1rem; }
.error { color: var(--danger); font-size: 1rem; margin: .5rem 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #222; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 20; font-size: .95rem; max-width: 90vw;
}
.big { font-size: 2.5rem; font-weight: 800; margin: .375rem 0; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.preview-tag { position: fixed; top: calc(4px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 30; background: #7c3aed; color: #fff; font-size: .75rem; padding: 3px 8px; border-radius: 999px; }
[hidden] { display: none !important; }

/* 작업 태그 선택 (오늘 작업 확인 화면) */
.tags { display: grid; grid-template-columns: 1fr 1fr; gap: .625rem; margin: .75rem 0; }
.tag {
  min-height: 4rem; padding: .625rem .75rem; border-radius: .875rem; border: 2px solid var(--line); background: #fff;
  font: inherit; font-size: 1.125rem; font-weight: 700; color: var(--ink-2); cursor: pointer; text-align: center; line-height: 1.3;
}
.tag.on { background: var(--green); border-color: var(--green); color: #fff; }
.tag.none { grid-column: 1 / -1; min-height: 3.5rem; }
.tag.none.on { background: var(--ink-2); border-color: var(--ink-2); }
.section-title { font-size: 1rem; font-weight: 700; color: var(--ink-2); margin: 1.25rem 0 .25rem; display: flex; align-items: center; gap: .5rem; }
.section-title .badge { font-size: .85rem; }
.linkish { background: none; border: 0; padding: .5rem 0; color: var(--green); font: inherit; font-size: 1rem; font-weight: 700; text-decoration: underline; cursor: pointer; min-height: 2.75rem; }

/* ---------- 관리자 화면 ---------- */
.app.wide { max-width: 1040px; padding-bottom: calc(5rem + env(safe-area-inset-bottom)); }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a { flex: 1; text-align: center; padding: .75rem .25rem; min-height: 3.5rem; font-size: .95rem; font-weight: 700; color: var(--ink-3); text-decoration: none; display: flex; align-items: center; justify-content: center; }
.nav a.on { color: var(--green); box-shadow: inset 0 3px 0 var(--green); }
@media (min-width: 760px) {
  .nav { position: sticky; top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); margin: 0 -1rem; }
  .nav a { flex: 0 0 auto; padding: .75rem 1.25rem; }
  .app.wide { padding-bottom: 2rem; }
}
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .75rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .875rem; }
.stat .label { font-size: .9rem; color: var(--ink-3); }
.stat .value { font-size: 1.75rem; font-weight: 800; line-height: 1.2; }
.stat .value.warn { color: var(--warn); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.tbl { border-collapse: collapse; width: 100%; font-size: .95rem; }
table.tbl th, table.tbl td { padding: .5rem .625rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: middle; }
table.tbl th { background: #f2f4f1; font-weight: 700; color: var(--ink-2); position: sticky; top: 0; }
table.tbl th.sticky, table.tbl td.sticky { position: sticky; left: 0; background: #fff; z-index: 1; }
table.tbl th.sticky { background: #f2f4f1; z-index: 2; }
table.tbl td.c { text-align: center; }
table.tbl tr.clickable { cursor: pointer; }
table.tbl tr.clickable:hover { background: var(--green-light); }
.dot { display: inline-block; width: 1.5rem; height: 1.5rem; line-height: 1.5rem; border-radius: 50%; text-align: center; font-size: .8rem; font-weight: 700; cursor: pointer; }
.dot.inside { background: var(--green); color: #fff; }
.dot.outside { background: var(--warn); color: #fff; }
.dot.denied, .dot.unavailable { background: var(--ink-3); color: #fff; }
.dot.miss { background: #fde2e0; color: var(--danger); }
.dot.off { background: transparent; color: var(--line); cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { min-height: 2.75rem; padding: .375rem .875rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; font: inherit; font-size: .95rem; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.chip.on { background: var(--green); border-color: var(--green); color: #fff; }
.chip.locked { opacity: .7; cursor: default; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; align-items: center; gap: .75rem; padding: .75rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.list .name { font-weight: 700; }
.qr { background: #fff; padding: .5rem; border-radius: .75rem; border: 1px solid var(--line); display: inline-block; }
.qr svg { display: block; width: 11rem; height: 11rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; word-break: break-all; }
.item-row { display: flex; gap: .75rem; align-items: flex-start; padding: .625rem 0; border-bottom: 1px solid var(--line); }
.item-row input[type=checkbox] { width: 1.5rem; height: 1.5rem; margin-top: .25rem; accent-color: var(--green); flex: none; }
.item-row .txt { flex: 1; }
.item-row .meta { font-size: .85rem; color: var(--ink-3); }
.item-row.off .txt { color: var(--ink-3); text-decoration: line-through; }
.detail dl { display: grid; grid-template-columns: 7rem 1fr; gap: .375rem .75rem; margin: 0; font-size: .95rem; }
.detail dt { color: var(--ink-3); }
.detail dd { margin: 0; }
.sig-img { max-width: 100%; height: 6rem; border: 1px solid var(--line); border-radius: .5rem; background: #fff; }
.sheet.tall { max-height: 85dvh; overflow-y: auto; }
.inline-form { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form label.field { flex: 1; min-width: 10rem; margin: 0; }
.weekdays { display: flex; gap: .375rem; }
.weekdays .chip { flex: 1; text-align: center; padding: .375rem 0; }

.req { color: var(--danger); font-weight: 800; }
.req-note { font-size: .95rem; color: var(--ink-3); }
.qr-side { min-width: 16rem; }   /* 좁은 화면에서는 QR 아래로 내려간다 */

/* 조치 사다리 */
.step { display: inline-block; min-width: 4.5rem; text-align: center; padding: .25rem .625rem; border-radius: 999px; font-size: .9rem; font-weight: 800; }
.step.s0 { background: var(--green-light); color: var(--green); }
.step.s1 { background: #eceeea; color: var(--ink-2); }
.step.s2 { background: var(--warn-bg); color: var(--warn); }
.step.s3 { background: #fde2e0; color: var(--danger); }
.step.s4 { background: var(--danger); color: #fff; }
.act-btns { display: flex; flex-wrap: wrap; gap: .375rem; }
.act-btns .btn.sm { min-height: 2.75rem; padding: .375rem .75rem; font-size: .95rem; }
.notice-body { white-space: pre-wrap; line-height: 1.6; font-size: 1.0625rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }

.nav a[title='도움말'] { flex: 0 0 2.75rem; }
.help { max-width: 760px; margin: 0 auto; padding: 1rem; font-size: 1.0625rem; line-height: 1.6; }
.help h2 { margin-top: 2rem; }
.help h3 { margin-top: 1.25rem; font-size: 1.125rem; }
.help ol, .help ul { padding-left: 1.25rem; }
.help .q { font-weight: 700; margin-top: 1rem; }
.help nav a { margin-right: .75rem; }
.help img { border: 1px solid var(--line); border-radius: .5rem; }
