/* 기계설비 유지관리점검 — 모바일 우선 화면 스타일 (v1) */
:root {
  --bg: #f4f0fb; --card: #fff; --line: #e3dbf3; --text: #241c38; --sub: #6f6787;
  --main: #6d3fd1; --main-dark: #5a31b3; --soft: #ece4fb;
  --ok: #1f9d55; --bad: #d93025; --na: #7a7f8a;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; font-size: 16px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; padding-bottom: 96px; }

/* 상단 바 */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px;
  background: var(--main); color: #fff; padding: 8px; min-height: 56px; }
.bar h1 { flex: 1; margin: 0 6px; font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib { min-width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: #fff; font-size: 20px; padding: 0 8px; }
.ib:active { background: rgba(255,255,255,.2); }
.ib:disabled { opacity: .35; }

.pad { padding: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.sub { color: var(--sub); font-size: 14px; }
.sec { margin: 18px 4px 8px; font-size: 15px; font-weight: 700; color: var(--main-dark); }
.notice { background: #fff7e0; border: 1px solid #f0d98a; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }

/* 입력 */
label.f { display: block; margin-bottom: 12px; font-size: 14px; color: var(--sub); }
label.f input, label.f textarea, label.f select, .in {
  display: block; width: 100%; margin-top: 4px; padding: 12px; min-height: 48px; font-size: 16px; color: var(--text);
  background: #fff; border: 1px solid var(--line); border-radius: 10px; }
textarea { resize: vertical; min-height: 72px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--main); outline-offset: 0; }
/* 아직 저장되지 않은 입력 */
input.unsaved, textarea.unsaved { border-color: var(--bad) !important; background: #fff5f4 !important; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 6px; margin-bottom: 6px; }
.row3 .in { min-width: 0; margin-top: 0; padding: 10px 8px; }
.row2 input { min-width: 0; padding-left: 8px; padding-right: 6px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; font-weight: 600; }
.btn.main { background: var(--main); border-color: var(--main); color: #fff; }
.btn.main:active { background: var(--main-dark); }
.btn.danger { color: var(--bad); border-color: #f2c4c0; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.fixed-bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%); }
.fixed-bottom .btn { max-width: 692px; margin: 0 auto; display: flex; min-height: 56px; font-size: 17px; }

/* 로그인 */
.login { padding: 48px 24px; }
.logo { width: 96px; height: 96px; margin: 0 auto 12px; border-radius: 26px; background: var(--main); display: grid; place-items: center; }
.login h2 { text-align: center; margin: 0 0 4px; font-size: 22px; }
.login .sub { text-align: center; margin-bottom: 28px; }
.pw { position: relative; }
.pw button { position: absolute; right: 4px; bottom: 2px; height: 44px; border: 0; background: none; color: var(--main); font-size: 14px; padding: 0 10px; }
.chk { display: flex; align-items: center; gap: 8px; margin: 4px 0 18px; font-size: 15px; }
.chk input { width: 22px; height: 22px; accent-color: var(--main); }

/* 프로젝트 카드 */
.pcard { display: block; width: 100%; text-align: left; }
.pcard b { font-size: 17px; }
.pcard .tag { float: right; background: var(--soft); color: var(--main-dark); border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 600; }
.pcard dl { margin: 8px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 14px; }
.pcard dt { color: var(--sub); } .pcard dd { margin: 0; }
.empty { text-align: center; color: var(--sub); padding: 48px 16px; }

/* 설비 현황 카드 */
.ecard { padding: 12px 14px; }
.ecard .nm { font-weight: 700; margin-bottom: 8px; }
.ecard .cnt { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; text-align: center; }
.ecard .cnt span { display: block; font-size: 13px; color: var(--sub); margin-bottom: 4px; }
.ecard .cnt input { width: 100%; height: 46px; text-align: center; font-size: 18px; font-weight: 700; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.ecard .cnt .doc { width: 100%; height: 46px; font-size: 17px; font-weight: 700; color: var(--main-dark); background: var(--soft); border: 1px solid var(--line); border-radius: 10px; }
.ecard.zero { opacity: .72; }
.bphoto { width: 100%; max-height: 200px; object-fit: cover; border-radius: 12px; margin-bottom: 12px; display: block; }

/* 점검표 목록 */
.grp { background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; overflow: hidden; }
.grp-h { background: var(--soft); padding: 10px 12px; }
.grp-h .t { font-weight: 700; margin-bottom: 8px; }
.grp-h .tools { display: flex; gap: 8px; }
.grp-h select, .grp-h .btn { min-height: 42px; border-radius: 10px; font-size: 14px; flex: 1; }
.grp-h select { border: 1px solid var(--line); background: #fff; padding: 0 8px; font-weight: 600; }
.grp-h .plus { flex: 0 0 48px; font-size: 22px; background: var(--main); color: #fff; border-color: var(--main); }
.unit { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-top: 1px solid var(--line); min-height: 60px; }
.unit a { flex: 1; text-decoration: none; color: inherit; padding: 8px 0; }
.unit a b { display: block; }
.badge { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 700; margin-right: 4px; }
.badge.done { background: #dff5e7; color: var(--ok); } .badge.todo { background: #eee; color: #555; } .badge.x { background: #fde3e1; color: var(--bad); }
.has-photo { color: var(--ok); }

/* 개별 장비: 탭 */
.tabs { position: sticky; top: 56px; z-index: 4; display: grid; grid-template-columns: repeat(3, 1fr); background: #fff; border-bottom: 1px solid var(--line); }
.tabs button { height: 50px; border: 0; background: none; font-weight: 700; color: var(--sub); border-bottom: 3px solid transparent; }
.tabs button.on { color: var(--main); border-bottom-color: var(--main); }
.stat { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 14px; }

/* 점검항목 */
.item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.item-top { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; }
.item-top .nm { flex: 1; font-weight: 600; line-height: 1.4; }
.item-top select { height: 40px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 0 6px; font-size: 14px; }
.oxs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ox { height: 60px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-size: 26px; font-weight: 800; color: #b9b3c9; }
.ox.o.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.ox.x.on { background: var(--bad); border-color: var(--bad); color: #fff; }
.ox.n.on { background: var(--na); border-color: var(--na); color: #fff; }
/* 자동으로 채워진 O (아직 현장에서 확인하지 않음) */
.ox.o.pend { border-color: var(--ok); border-style: dashed; color: var(--ok); background: #f3fbf6; }
.pend-note { font-size: 12px; color: var(--sub); margin-top: 6px; }
.defect { margin-top: 12px; padding: 12px; background: #fff5f4; border: 1px solid #f2c4c0; border-radius: 12px; }
.defect label.f { color: var(--bad); font-weight: 600; }
.defect img { width: 100%; max-height: 240px; object-fit: contain; background: #000; border-radius: 10px; margin-bottom: 8px; display: block; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns .btn { flex: 1; }

/* 사진대지 */
.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ph { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.ph img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; display: block; background: #ddd; }
.ph input { width: 100%; margin: 6px 0; padding: 8px; height: 42px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.ph .btns .btn { min-height: 38px; padding: 0 4px; font-size: 13px; flex: 1 1 40%; }

/* 아래에서 올라오는 창 */
.sheet-bg { position: fixed; inset: 0; z-index: 20; background: rgba(20,10,40,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 720px; max-height: 90vh; overflow: auto; background: #fff; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet h3 { margin: 0 0 12px; font-size: 18px; }
.sheet img.big { width: 100%; max-height: 50vh; object-fit: contain; background: #000; border-radius: 12px; margin-bottom: 12px; }
.sheet .stack { display: grid; gap: 8px; }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 30; background: #241c38; color: #fff;
  padding: 8px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
#toast.on { opacity: .95; } #toast.err { background: var(--bad); }

/* 좁은 휴대폰: 날짜 칸은 휴대폰마다 최소 폭이 넓어 나란히 두면 화면 밖으로 밀린다 → 한 줄에 하나씩 */
input[type=date] { -webkit-appearance: none; appearance: none; min-width: 0; max-width: 100%; text-align: left; line-height: 22px; }
input[type=date]::-webkit-date-and-time-value { text-align: left; }
@media (max-width: 520px) {
  .row2:has(input[type=date]) { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .bar h1 { font-size: 16px; }
  .row3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr); }
}
.pad { overflow-wrap: anywhere; }
label.f select { -webkit-appearance: menulist; appearance: auto; }

/* PC 등 넓은 화면 */
@media (min-width: 760px) {
  #app { box-shadow: 0 0 0 1px var(--line); background: var(--bg); }
  .ecards { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
  .pgrid { grid-template-columns: repeat(3, 1fr); }
}

/* 연속 촬영 카메라 */
.cam { position: fixed; inset: 0; z-index: 40; background: #000; display: flex; flex-direction: column; }
.cam video { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.cam.flash video { opacity: .3; }
.cam-strip { display: flex; gap: 6px; padding: 6px; overflow-x: auto; min-height: 68px; }
.cam-strip img { height: 56px; border-radius: 6px; flex: none; pointer-events: none; }
.cam-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
.cam-bar .btn { min-width: 96px; }
.cam-save { display: flex; align-items: center; gap: 8px; color: #fff; font-size: 14px; padding: 0 16px; }
.cam-save input { width: 20px; height: 20px; accent-color: var(--main); }
.shutter { width: 76px; height: 76px; border-radius: 50%; border: 5px solid #fff; background: #fff; box-shadow: inset 0 0 0 4px #000; flex: none; }
.shutter:active { background: #ccc; }

/* ================= PC 전용 화면 (폭 1000px 이상) =================
   휴대폰 화면을 그대로 늘리지 않고, 넓은 화면에 맞게 따로 배치한다 */
@media (min-width: 1000px) {
  #app { max-width: none; padding-bottom: 48px; box-shadow: none; }
  #app:has(.split) { padding-bottom: 0; }
  .bar { padding: 8px max(16px, calc((100vw - 1320px) / 2)); }
  .bar h1 { font-size: 19px; }
  .pad { max-width: 1320px; margin: 0 auto; padding: 22px 28px; }
  form.pad { max-width: 760px; }
  .ib:hover { background: rgba(255,255,255,.18); }
  .btn:hover { border-color: var(--main); }
  .btn.main:hover { background: var(--main-dark); }
  /* 로그인: 가운데 카드 */
  .login { max-width: 420px; margin: 7vh auto 0; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 36px 32px; }
  /* 프로젝트 목록: 카드를 여러 칸으로 */
  .plist { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; align-content: start; }
  .plist > .in, .plist > .empty { grid-column: 1 / -1; }
  .plist .pcard { margin: 0; cursor: pointer; }
  .pcard:hover { border-color: var(--main); box-shadow: 0 2px 10px rgba(109,63,209,.12); }
  /* 프로젝트 정보: 왼쪽 기본정보, 오른쪽 설비 현황 */
  .pinfo { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 28px; align-items: start; }
  .pleft { position: sticky; top: 76px; }
  .pright .sec:first-child, .pleft .sec:first-child { margin-top: 0; }
  .ecards { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 12px; }
  .fixed-bottom { left: auto; right: 28px; bottom: 18px; padding: 0; background: none; }
  .fixed-bottom .btn { min-width: 340px; box-shadow: 0 6px 18px rgba(60,30,120,.28); }
  /* 점검표 작성: 왼쪽 장비 목록 + 오른쪽 점검 화면 */
  .split { display: grid; grid-template-columns: 410px minmax(0, 1fr); height: calc(100vh - 60px); }
  #side { overflow: auto; padding: 14px; border-right: 1px solid var(--line); background: #faf8fe; }
  #main { overflow: auto; }
  #main .pad { max-width: 1000px; margin: 0; padding: 18px 28px 60px; }
  .unit a:hover b { color: var(--main); }
  .unit.on { background: var(--soft); box-shadow: inset 4px 0 0 var(--main); }
  .sub-bar { position: static; background: #fff; color: var(--text); border-bottom: 1px solid var(--line); padding: 6px 20px; }
  .sub-bar h1 { font-size: 20px; }
  .sub-bar .ib { color: var(--main); }
  .sub-bar .ib:hover { background: var(--soft); }
  .sub-bar .back { display: none; }
  .split .tabs { top: 0; max-width: 520px; background: transparent; border-bottom: 0; margin: 4px 0 0 16px; }
  .split .tabs button { height: 44px; }
  /* 점검항목: 한 줄에 항목 이름 · 주기 · O X / */
  .item { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 4px 18px; align-items: center; padding: 8px 14px; margin-bottom: 6px; border-radius: 10px; }
  .item-top { grid-column: 1; margin-bottom: 0; align-items: center; }
  .oxs { grid-column: 2; grid-row: 1; }
  .ox { height: 42px; font-size: 20px; border-radius: 9px; }
  .ox:hover { border-color: var(--main); }
  .pend-note { grid-column: 1 / -1; margin-top: 0; }
  .defect { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; margin-top: 4px; }
  .defect > :not(label) { grid-column: 1 / -1; }
  .defect img { max-width: 360px; }
  .defect .btns .btn { flex: 0 0 auto; }
  .pgrid { grid-template-columns: repeat(4, 1fr); }
  /* 보고서 정보: 2단으로 나눠 한눈에 */
  .pad.wide { column-count: 2; column-gap: 28px; }
  .pad.wide > .card:first-child { column-span: all; }
  .pad.wide > .sec { break-after: avoid; margin-top: 4px; }
  .pad.wide > .card { break-inside: avoid; }
  /* 아래에서 올라오던 창은 가운데 창으로 */
  .sheet-bg { align-items: center; }
  .sheet { max-width: 520px; border-radius: 18px; padding: 24px; }
  #toast { bottom: 32px; }
}
