/* Mobile-first — 모바일 세로 모드 최우선 */
:root {
  --brand: #f5821f;        /* IGM 로고 오렌지 */
  --brand-dark: #d96b0c;
  --brand-light: #fdf0e3;
  --ink: #3c3c3b;          /* 로고 진회색 */
  --border: #d8d3cd;
}
* { box-sizing: border-box; }
html { overscroll-behavior-y: contain; } /* 당겨서 새로고침·바운스로 화면이 흔들리는 것 방지 */
body {
  margin: 0;
  font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
  background: #f6f4f2;
  color: #1a1a1a;
  font-size: 16px;
  overscroll-behavior-y: contain;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--ink);
  border-bottom: 3px solid var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand {
  color: var(--brand);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-logo { height: 22px; background: #fff; padding: 2px 4px; border-radius: 3px; }
.topbar nav { display: flex; gap: 10px; align-items: center; }
.topbar nav a { color: #e8e4e0; text-decoration: none; font-size: 14px; }
.btn-link { background: none; border: none; color: #e8e4e0; font-size: 14px; cursor: pointer; padding: 0; }
.inline { display: inline; }

.container { max-width: 720px; margin: 0 auto; padding: 12px; }

.card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 0 0 10px; color: var(--brand-dark); }
h3 { font-size: 14px; margin: 12px 0 6px; }
.muted { color: #777; }
.small { font-size: 13px; }

label { display: block; margin-bottom: 12px; font-weight: 600; font-size: 14px; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"],
select, textarea {
  width: 100%;
  padding: 12px;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px; /* iOS 자동 확대 방지 */
  font-family: inherit;
}
textarea { resize: vertical; }
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus,
input[type="date"]:focus, input[type="datetime-local"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-light);
}
fieldset { border: none; padding: 0; margin: 0 0 12px; }
legend { font-weight: 600; font-size: 14px; margin-bottom: 6px; }

.btn {
  display: inline-block;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: #1a1a1a;
  font-size: 15px;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.btn-primary:active { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { border-color: #b3261e; color: #b3261e; }
.btn-block { display: block; width: 100%; margin-bottom: 10px; }
.btn-lg { padding: 16px; font-size: 17px; }
.btn-sm { padding: 6px 10px; font-size: 13px; }

.alert { padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.alert-error { background: #fdecea; color: #b3261e; }
.alert-ok { background: #e6f4ea; color: #137333; }

.login-card { max-width: 400px; margin: 40px auto; }

.report-list { list-style: none; margin: 0; padding: 0; }
.report-list li a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 4px;
  border-bottom: 1px solid #eee;
  text-decoration: none;
  color: inherit;
}
.report-list li:last-child a { border-bottom: none; }
.report-row { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid #eee; }
.report-row:last-child { border-bottom: none; }
.report-row > a:first-child { flex: 1; border-bottom: none; }
.nowrap { white-space: nowrap; }

.radio-card {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  font-weight: 400;
}
.radio-card:has(input:checked) { border-color: var(--brand); background: var(--brand-light); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--brand-light);
  color: var(--brand-dark);
  font-size: 12px;
}
.badge-ok { background: #e6f4ea; color: #137333; }

.check-group { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.check-pill { margin: 0; font-weight: 400; }
.check-pill input { position: absolute; opacity: 0; }
.check-pill span {
  display: inline-block;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
}
.check-pill input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }

.part-row { display: grid; grid-template-columns: 1fr 64px 1fr 36px; gap: 6px; margin-bottom: 6px; }
.part-row input { margin-top: 0; }
.btn-remove-part, .btn-remove-photo {
  border: none; background: #fdecea; color: #b3261e;
  border-radius: 8px; font-size: 18px; cursor: pointer;
}

.survey-row { margin-bottom: 12px; }
.survey-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.survey-options { display: flex; gap: 6px; flex-wrap: wrap; }
.survey-options label { margin: 0; font-weight: 400; }
.survey-options input { position: absolute; opacity: 0; }
.survey-options span {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
}
.survey-options input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.photo-item { position: relative; margin: 0; }
.photo-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.photo-item .btn-remove-photo {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px;
}

.sign-block { margin-bottom: 16px; }
.survey-block {
  margin: 16px 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--brand-light);
}
/* 서명 패드 — 가이드(성/이/름)를 캔버스 뒤에 깔아 서명 이미지에는 포함되지 않게 한다 */
.sign-pad-wrap {
  position: relative;
  height: 160px;
  border: 1px dashed #b3a99e;
  border-radius: 8px;
  background: #fdfcfb;
  margin-bottom: 6px;
  overflow: hidden;
}
.sign-guide {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  pointer-events: none;
}
.sign-guide span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 700;
  color: #ece5dd;
  border-right: 1px dashed #e0d8cf;
  user-select: none;
}
.sign-guide span:last-child { border-right: none; }
canvas.sign-pad {
  position: relative;
  width: 100%;
  height: 100%;
  background: transparent; /* 투명이어야 뒤 가이드가 보이고, PDF에는 서명만 남는다 */
  touch-action: none;      /* 서명 중 스크롤 충돌 방지 */
  display: block;
}

/* 서명하는 동안 터치 스크롤을 잠근다.
   overflow:hidden 은 쓰지 않는다 — 데스크톱에서 스크롤바가 사라지며 패드가 옆으로 밀린다.
   touch-action 은 터치에만 적용되고 레이아웃을 바꾸지 않으며, 마우스 드래그는 원래 스크롤을 일으키지 않는다. */
body.signing { touch-action: none; }

.submit-bar { margin: 16px 0 40px; }
.report-head { position: sticky; top: 48px; z-index: 5; }

.detail-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.detail-table th, .detail-table td { padding: 8px; border-bottom: 1px solid #eee; text-align: left; font-size: 14px; }
.detail-table th { width: 100px; color: #777; font-weight: 600; }

/* 점검 스케줄 대시보드 */
.month-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.month-nav h1 { font-size: 18px; }
.sched-list { list-style: none; margin: 0; padding: 0; }
.sched-list .card { padding: 12px 14px; }
.sched-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sched-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sched-done { opacity: .7; }
.sched-late { border-left: 4px solid #b3261e; }
.sched-due { border-left: 4px solid var(--brand); }
.type-rows { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.type-row { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 8px; background: #f6f4f2; border-radius: 6px; font-size: 14px; }
.badge-late { background: #fdecea; color: #b3261e; }
.text-ng { color: #b3261e; font-weight: 700; }
.text-ok { color: #137333; }

/* 점검 입력: 항목별 정상/비정상 토글 + 특이사항 */
.chk-list { display: flex; flex-direction: column; gap: 8px; }
.chk-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.chk-item.is-ng { border-color: #b3261e; background: #fdf4f3; }
.chk-item-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.chk-item-label { font-weight: 600; font-size: 14px; flex: 1; min-width: 150px; }
.chk-toggle { display: flex; gap: 6px; flex-shrink: 0; }
.chk-pill { margin: 0; font-weight: 400; }
.chk-pill input { position: absolute; opacity: 0; }
.chk-pill span { display: inline-block; padding: 8px 16px; border: 1px solid var(--border); border-radius: 20px; font-size: 14px; }
.chk-pill.ok input:checked + span { background: #137333; border-color: #137333; color: #fff; }
.chk-pill.ng input:checked + span { background: #b3261e; border-color: #b3261e; color: #fff; }
.chk-note-input { margin-top: 8px; display: block; }
/* 비정상 항목은 특이사항 입력칸을 더 눈에 띄게 */
.chk-item.is-ng .chk-note-input { border-color: #b3261e; }

/* 장비 점검 이력 타임라인 */
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 8px 0 8px 12px; }
.timeline li::before {
  content: ''; position: absolute; left: -19px; top: 16px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--brand);
}
.timeline li.timeline-ng::before { background: #b3261e; }
.timeline li a { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; }

/* 관리자 테이블 */
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { padding: 8px 6px; border-bottom: 1px solid #eee; text-align: left; }
.admin-table th { background: var(--brand-light); color: var(--ink); }
.filter-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.filter-form label { flex: 1 1 140px; margin-bottom: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

@media (min-width: 760px) {
  .container { padding: 20px; }
  .photo-grid { grid-template-columns: repeat(5, 1fr); }
}
