/* 당직ON — 모바일 우선, 큰 글씨·큰 버튼, 명도 대비 4.5:1 이상 */
:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #4b5563;
  --line: #d1d5db;
  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --info: #1e40af;
  --info-bg: #dbeafe;
  --todo: #374151;
  --todo-bg: #e5e7eb;
  --warn-bg: #fef3c7;
  --warn: #92400e;
  --radius: 14px;
  --tap: 56px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: #e5e7eb;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 18px;
  line-height: 1.55;
}

/* 발표장 PC에서도 스마트폰 폭으로 보이게 */
.shell {
  max-width: 480px;
  min-height: calc(100vh - 32px);
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--line);
}

.demo-banner {
  position: sticky; top: 0; z-index: 20;
  background: #fde68a; color: #78350f;
  text-align: center; font-size: 15px; font-weight: 700;
  padding: 4px 8px;
}

.appbar {
  position: sticky; top: 31px; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  min-height: 60px; padding: 0 12px;
  background: var(--primary-dark); color: #fff;
}
.appbar-title { font-size: 21px; margin: 0; }
.appbar-back {
  width: 48px; height: 48px; border: 0; border-radius: 10px;
  background: transparent; color: #fff; font-size: 26px; cursor: pointer;
}
.appbar-back[hidden] { display: none; }

main { padding: 16px 16px 40px; outline: none; }
main > * + * { margin-top: 14px; }

h2 { font-size: 20px; margin: 0; }
p { margin: 0; }
.section-title { font-size: 19px; margin-top: 22px; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.block { display: block; }
.center { text-align: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.card > * + * { margin-top: 10px; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 10px 18px;
  border: 2px solid transparent; border-radius: 12px;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  background: var(--card); color: var(--primary);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-secondary { background: var(--card); color: var(--primary); border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--primary); border-color: var(--line); }
.btn-block { display: flex; width: 100%; }
.btn-big { min-height: 64px; font-size: 20px; }
.btn-small { min-height: 44px; padding: 6px 14px; font-size: 16px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.link-btn {
  background: none; border: 0; color: var(--muted); font: inherit; font-size: 15px;
  text-decoration: underline; min-height: 44px; cursor: pointer;
}
.footer-actions { display: flex; justify-content: space-between; flex-wrap: wrap; }

:focus-visible { outline: 3px solid #f59e0b; outline-offset: 2px; }

/* 상태 표시: 색 + 글자 + 기호를 함께 */
.chip {
  display: inline-flex; align-items: center; gap: 2px; white-space: nowrap;
  padding: 3px 10px; border-radius: 999px; font-size: 15px; font-weight: 700;
}
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-bad { background: var(--bad-bg); color: var(--bad); }
.chip-todo { background: var(--todo-bg); color: var(--todo); }
.chip-info { background: var(--info-bg); color: var(--info); }

/* 목록 */
.list { list-style: none; margin: 10px 0 0; padding: 0; }
.list li + li { margin-top: 8px; }
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 68px; padding: 10px 14px;
  background: var(--card); border-radius: 12px; color: inherit; text-decoration: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

/* 홈 */
.hero { text-align: center; padding: 20px 0 6px; }
.hero-logo { font-size: 44px; }
.hero h2 { font-size: 24px; }
.summary .progress-text { font-size: 20px; }
.summary .progress-text strong { font-size: 30px; color: var(--primary); }
progress { width: 100%; height: 14px; accent-color: var(--primary); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  min-height: 110px; padding: 10px; background: var(--card); border-radius: var(--radius);
  color: var(--text); text-decoration: none; font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.tile-num { font-size: 30px; color: var(--ok); }
.tile-num.tile-alert { color: var(--bad); }
.tile-icon { font-size: 28px; color: var(--primary); }

/* 폼 */
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 700; padding: 0; margin-bottom: 6px; }
.field { display: block; }
.field > span { display: block; font-weight: 700; margin-bottom: 6px; }
input[type=password], input[type=text], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 2px solid #6b7280; border-radius: 10px; font: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; }
.option {
  display: flex; align-items: center; gap: 10px; min-height: var(--tap);
  padding: 6px 12px; border: 2px solid var(--line); border-radius: 10px; cursor: pointer;
}
.option + .option { margin-top: 8px; }
.option input { width: 22px; height: 22px; accent-color: var(--primary); }
.error { color: var(--bad); font-weight: 700; min-height: 0; }
.error:empty { display: none; }

/* 정상/이상 선택 버튼 */
.check-item {
  background: var(--card); border-radius: 12px; padding: 12px; margin-top: 10px;
  border: 2px solid transparent;
}
.check-item.missing { border-color: var(--bad); }
.check-item legend { float: left; width: 100%; margin-bottom: 8px; }
.seg { clear: both; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg-3 { grid-template-columns: 1fr 1fr 1fr; }
.seg-1 { grid-template-columns: 1fr; }
.seg label { position: relative; display: block; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span {
  display: flex; align-items: center; justify-content: center; min-height: 52px;
  border: 2px solid #6b7280; border-radius: 10px; font-weight: 700; cursor: pointer; background: #fff;
}
.seg input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.seg-ok input:checked + span { background: var(--ok); border-color: var(--ok); }
.seg-bad input:checked + span { background: var(--bad); border-color: var(--bad); }
.seg input:checked + span::before { content: "✓ "; }
.seg input:focus-visible + span { outline: 3px solid #f59e0b; outline-offset: 2px; }

.issue-box { border: 2px solid var(--bad); }

/* 사진 */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photos:empty { display: none; }
.photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #ddd; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-del {
  position: absolute; top: 4px; right: 4px; width: 40px; height: 40px;
  border: 0; border-radius: 50%; background: rgba(17,24,39,.8); color: #fff; font-size: 18px; cursor: pointer;
}
.file-btn { position: relative; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* 연락처 */
.contact {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card); border-radius: 12px; padding: 12px 14px; margin-top: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.contact { flex-wrap: wrap; }
.contact > div:first-child { flex: 1 1 200px; }
.contact-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* 알림 상자 */
.notice { background: var(--info-bg); color: var(--info); padding: 10px 12px; border-radius: 10px; font-size: 16px; }
.notice.warn, .scan-status.warn { background: var(--warn-bg); color: var(--warn); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.place-name { font-size: 22px; }

/* QR 스캐너 */
.scanner { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 1; }
.scanner[hidden] { display: none; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame {
  position: absolute; inset: 18%; border: 4px solid #fbbf24; border-radius: 16px;
  box-shadow: 0 0 0 999px rgba(0,0,0,.35);
}
.scan-status { padding: 10px 12px; border-radius: 10px; background: var(--card); font-weight: 700; }

/* 처리 이력 */
.timeline { margin: 10px 0 0; padding-left: 22px; }
.timeline li + li { margin-top: 8px; }

/* 빈 상태 */
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.empty > * + * { margin-top: 12px; }
.empty-icon { font-size: 44px; color: var(--ok); }

/* 당직일지 */
.journal { font-size: 16px; line-height: 1.6; min-height: 420px; }
.print-area { display: none; }

/* 토스트 */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  max-width: 440px; width: calc(100% - 32px);
  background: #111827; color: #fff; padding: 14px 16px; border-radius: 12px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* 인쇄: 당직일지 본문만 */
@media print {
  body { background: #fff; }
  .demo-banner, .appbar, .toast, main > *:not(.print-area) { display: none !important; }
  .shell { box-shadow: none; max-width: none; }
  .print-area { display: block !important; margin: 0; }
}

/* ===== 프로토타입 v2 추가 ===== */
.shell { padding-bottom: 76px; }
.appbar-title { flex: 1; }
.ai-badge {
  font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: #dbeafe; color: #1e3a8a; white-space: nowrap;
}
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 30;
  width: 100%; max-width: 480px; display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar[hidden] { display: none; }
.tabbar a {
  flex: 1; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 13px;
}
.tabbar a[aria-current="page"] { color: var(--primary); font-weight: 700; }
.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn .ic { margin-right: 6px; }
.btn-danger { background: #fff; color: var(--bad); border-color: var(--bad); }
.btn-ai { background: #eff6ff; color: #1e3a8a; border-color: #1d4ed8; }
.btn.loading { opacity: .75; cursor: progress; }
.btn:disabled { cursor: progress; }
.big-line { font-size: 22px; }
.accent { color: var(--primary); }
.strong { font-weight: 700; }
.tile-num.tile-plain { color: var(--text); }
.tile .muted { font-weight: 400; }
.list-btn { width: 100%; border: 0; font: inherit; text-align: left; cursor: pointer; }
.muted-card { opacity: .8; }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-ai { background: #1d4ed8; color: #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; }

/* 순찰 지도 */
.map { position: relative; height: 300px; border-radius: var(--radius); background: #e5e7eb; }
.map-loc {
  position: absolute; box-sizing: border-box; padding: 6px 8px; border-radius: 10px; border: 2px solid #6b7280; background: #fff;
  display: flex; flex-direction: column; justify-content: space-between; text-align: left; font: inherit; cursor: pointer; color: var(--text);
}
.map-loc:disabled { cursor: default; }
.map-name { font-size: 14px; font-weight: 700; line-height: 1.3; }
.map-state { font-size: 13px; font-weight: 700; }
.map-ok { border-color: var(--ok); background: var(--ok-bg); } .map-ok .map-state { color: var(--ok); }
.map-bad { border-color: var(--bad); background: var(--bad-bg); } .map-bad .map-state { color: var(--bad); }
.map-now { border: 3px solid var(--primary); background: var(--info-bg); } .map-now .map-state { color: var(--primary); }
.map-todo .map-state { color: var(--muted); }

/* AI 결과 */
.ai-card { border: 2px solid #1d4ed8; background: #eff6ff; }
.ai-note { font-size: 13px; color: #1e3a8a; }
.kv { margin: 0; display: grid; grid-template-columns: 84px 1fr; gap: 6px 10px; font-size: 16px; }
.kv dt { color: var(--muted); font-size: 14px; padding-top: 2px; }
.kv dd { margin: 0; }
.proc { background: #f9fafb; border-radius: 10px; padding: 10px 12px; }
.proc ol, details ol { margin: 6px 0 0; padding-left: 22px; font-size: 16px; }
details summary { cursor: pointer; min-height: 32px; }
.reply { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.reply > * + * { margin-top: 6px; }
.seg-4 { grid-template-columns: repeat(4, 1fr); }
.seg-4 span { font-size: 15px; }
.timeline li.ev-call strong { color: var(--info); }
.timeline li.ev-action strong, .timeline li.ev-answer strong { color: var(--ok); }
.timeline li.ev-status strong { color: var(--warn); }
#evForm > * + *, #newFields > * + * { margin-top: 10px; }
#evForm { margin-top: 12px; }
input[type=file] { width: 100%; font-size: 15px; }
@media print { .tabbar, .ai-badge { display: none !important; } }
.toast { bottom: 88px; }

/* 근무표 */
.link-inline { margin-left: 6px; font-size: 15px; font-weight: 700; color: var(--primary); }
.roster-head h2 { font-size: 20px; }
.btn.is-disabled { opacity: .35; pointer-events: none; }
.roster { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.roster-day { display: flex; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.roster-day:first-child { border-top: 0; }
.roster-date { flex: none; width: 44px; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.roster-date strong { font-size: 20px; }
.roster-date span { font-size: 14px; color: var(--muted); }
.roster-day.is-weekend .roster-date { color: var(--bad); }
.roster-day.is-weekend .roster-date span { color: var(--bad); }
.roster-day.is-today { background: var(--info-bg); box-shadow: inset 4px 0 0 var(--primary); }
.roster-duties { flex: 1; display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.roster-kind { display: inline-block; min-width: 72px; font-size: 15px; color: var(--muted); }
.roster-duty.is-mine strong { color: var(--primary); }

/* 순찰 기록 수정 */
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.visit-list { list-style: none; margin: 0; padding: 0; }
.visit-list > li + li { margin-top: 10px; }
.visit.is-edited { box-shadow: inset 4px 0 0 var(--warn); }
.visit details ol { margin: 6px 0 0; padding-left: 20px; }
.edit-form { border-top: 1px solid var(--line); padding-top: 12px; }
.edit-form > * + * { margin-top: 10px; }
.visit.is-void { opacity: .75; }
.visit.is-void .visit-name { text-decoration: line-through; }
.seg span { text-align: center; padding: 4px 6px; }
.rec-list { list-style: none; margin: 0; padding: 0; }
.rec-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.rec-row:first-child { border-top: 0; }
.rec-row > span:first-child { flex: 1; min-width: 0; }
.seg-3 span { font-size: 16px; white-space: nowrap; }
.rec-calls > * + * { margin-top: 8px; }
.rec-call {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left;
  min-height: 60px; padding: 8px 12px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font: inherit; color: var(--text); cursor: pointer;
}
.rec-call[aria-pressed="true"] { border-color: var(--primary); background: var(--info-bg); }
[hidden] { display: none !important; }
.choice {
  display: flex; align-items: center; gap: 14px; min-height: 84px; padding: 14px 16px;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none;
}
.choice .ic { width: 30px; height: 30px; color: var(--primary); }
.choice > span:nth-child(2) { flex: 1; }
.choice strong { font-size: 20px; }
.journal-prev { white-space: pre-wrap; font: inherit; font-size: 14px; background: var(--bg); border-radius: 8px; padding: 10px; margin: 6px 0 12px; }
.contact-emergency { border: 2px solid var(--bad); background: var(--bad-bg); }
.btn-danger-solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.proc + .contact, .proc + .notice, .contact + .contact, .contact + .notice, .notice + .contact { margin-top: 8px; }

/* 보안점검표: 실별 점검 (실제 서식 칸) */
.ck-rooms { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px; }
.room { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0; background: var(--card); }
.room legend { font-weight: 700; padding: 0 4px; }
.room.missing { border-color: var(--bad); box-shadow: 0 0 0 2px #fecaca; }
.room .seg { margin-top: 4px; }
.room-bad { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; padding: 8px; background: #fff7ed; border-radius: 8px; }
.room-bad[hidden] { display: none; }
.check-line { display: flex; align-items: center; gap: 8px; min-height: 40px; font-size: 16px; }
.check-line input { width: 22px; height: 22px; }
.room-ot { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--muted); }
.room-ot input { width: 64px; min-height: 36px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; }
.room.is-restricted { display: flex; justify-content: space-between; align-items: center; border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; background: #f1f5f9; color: var(--muted); }

/* 서식 인쇄 (당직근무일지 · 보안점검표) */
@page { size: A4; margin: 8mm 10mm; }
@media print { html, body, .shell, main, #app { background: #fff !important; } }
@page land { size: A4 landscape; margin: 10mm; }
.print-area { font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif; color: #000; font-size: 9.5pt; }
.fp-page { break-after: page; }
.fp-page:last-child { break-after: auto; }
.fp-land { page: land; }
.fp-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 4px; }
.fp-head h1 { font-size: 18pt; letter-spacing: .2em; text-decoration: underline; margin: 0 0 4px; }
.fp-head p { margin: 2px 0; }
.fp-sub { font-size: 12pt; text-align: center; margin: 0 0 4px; }
.print-area table { border-collapse: collapse; width: 100%; margin-bottom: 4px; }
.print-area th, .print-area td { border: 1px solid #000; padding: 2px 4px; vertical-align: top; font-weight: normal; }
.print-area th { text-align: center; vertical-align: middle; background: #f3f4f6; }
.print-area td { text-align: center; }
.print-area td.l, .print-area .fp-2 td { text-align: left; }
.print-area th.v { width: 52px; }
.fp-sign { width: auto !important; }
.fp-sign td { height: 32px; min-width: 56px; }
.fp-grid { display: flex; gap: 4px; }
.fp-left { flex: 1.1; }
.fp-right { flex: 1; }
.fp-2 td { height: 92px; }
.fp-pre { white-space: pre-wrap; text-align: left; font-size: 9pt; line-height: 1.35; }
.fp-time { white-space: pre-line; width: 90px; }
.fp-ck th, .fp-ck td { font-size: 8pt; padding: 0 3px; line-height: 1.25; }
.fp-ck td.gray { background: #d1d5db; }
.fp-ck td.bad { font-weight: 700; }
.fp-foot { font-size: 8pt; margin-top: 4px; }
