/* app.css — 전체 화면 공통 (모바일 우선) */
:root {
  --blue: #1e5eff; --blue-dark: #1646c4;
  --ink: #14181f; --muted: #6b7280; --line: #dfe3ea; --bg: #f4f6fa; --card: #fff;
  --ok: #157f3d; --ok-bg: #e7f6ec;
  --warn: #a05500; --warn-bg: #fff3e0;
  --bad: #b3261e; --bad-bg: #fdeceb;
  --info: #1e40af; --info-bg: #e7edff;
  --r: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--blue); }

/* 상단 바 */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; background: #fff; border-bottom: 1px solid var(--line);
}
.topbar .title { font-weight: 700; font-size: 16px; }
.topbar .who { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.topbar .who b { color: var(--ink); font-weight: 600; }
.pw-note {
  display: block; background: var(--warn-bg); color: var(--warn); font-size: 12.5px;
  padding: 7px 14px; text-decoration: none; font-weight: 600; border-bottom: 1px solid #f3e2c8;
}
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #eef1f7; color: #445; }
.badge.admin { background: var(--info-bg); color: var(--info); }
.badge.worker { background: var(--ok-bg); color: var(--ok); }

/* 레이아웃 */
.wrap { max-width: 1180px; margin: 0 auto; padding: 14px; }
.wrap.narrow { max-width: 680px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card h2 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card h2 .hint { font-weight: 400; font-size: 12px; color: var(--muted); }
.card .desc { font-size: 12.5px; color: var(--muted); margin: -4px 0 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* 폼 */
label.f { display: block; margin-bottom: 10px; position: relative; }
label.f > span { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 4px; }
label.f > span .req { color: var(--bad); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=tel], select, textarea {
  width: 100%; padding: 11px 12px; font-size: 16px; border: 1px solid #ccd3dd; border-radius: 10px;
  background: #fff; color: var(--ink); font-family: inherit;
}
input:disabled, select:disabled { background: #f1f3f7; color: #98a1ae; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b9ccff; border-color: var(--blue); }
textarea { min-height: 68px; resize: vertical; }
select {
  appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236b7280' stroke-width='1.6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}

/* 자동완성 목록 */
.combo-list {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 60; margin-top: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 24px rgba(20,24,31,.12); max-height: 260px; overflow: auto;
}
.combo-item { padding: 10px 12px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; border-bottom: 1px solid #f1f4f9; }
.combo-item:last-child { border-bottom: 0; }
.combo-item.on, .combo-item:hover { background: #f2f6ff; }
.combo-item .ci-main { font-weight: 600; font-size: 14.5px; }
.combo-item .ci-sub { font-size: 12px; color: var(--muted); }
.combo-empty { padding: 10px 12px; font-size: 12.5px; color: var(--muted); pointer-events: none; }
.combo-action {
  display: block; width: 100%; text-align: left; padding: 11px 12px; border: 0; border-top: 1px solid #eef1f6;
  background: #f4f8ff; color: var(--blue); font-family: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.combo-action:hover { background: #e9f1ff; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 15px; border-radius: 10px; border: 1px solid #ccd3dd; background: #fff;
  color: var(--ink); font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit;
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:disabled { background: #9db4ff; border-color: #9db4ff; }
.btn.danger { color: var(--bad); border-color: #f0c4c0; }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }

/* 하단 고정 저장 */
.sticky-actions {
  position: sticky; bottom: 0; z-index: 25; margin: 0 -14px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.97); border-top: 1px solid var(--line); display: flex; gap: 8px;
}
.sticky-actions .btn { flex: 1; padding: 13px; }
/* 휴대폰: 버튼이 5개까지 늘어나도 한 번에 보이도록 2열 배치 */
@media (max-width: 560px) {
  .sticky-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .sticky-actions .btn { width: 100%; }
}

/* 탭 */
.tabs { display: flex; gap: 6px; padding: 8px 14px; background: #fff; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; padding: 9px; border-radius: 9px; border: 1px solid transparent; background: #f1f4f9;
  color: #4b5563; font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.tabs button.on { background: var(--blue); color: #fff; }

/* 사진 촬영 */
.shot-row { display: flex; gap: 8px; margin-bottom: 6px; }
.shot-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 78px; border: 1.5px dashed #b9c2d0; border-radius: 10px; background: #fafbfe;
  color: #445; font-size: 13px; font-weight: 600; cursor: pointer;
}
.shot-btn .big { font-size: 21px; line-height: 1; }
.shot-btn input[type=file] { display: none; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 8px; margin: 8px 0 2px; }
.thumbs .ph { position: relative; }
.thumbs img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.thumbs .x {
  position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; border: 1px solid var(--line); color: var(--bad); font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer; font-weight: 700;
}

/* QC */
.qc-box { border: 1px solid #cfdbf7; background: #f7faff; border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.qc-box .qhead { font-size: 13px; font-weight: 700; color: var(--info); margin-bottom: 8px; }
.meas-item { border: 1px solid var(--line); border-radius: 10px; padding: 9px; margin-bottom: 8px; background: #fff; }
.meas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.meas-grid input { font-size: 15px; padding: 9px 10px; }
.meas-item .meas-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; }
.meas-item .meas-head b { font-size: 14.5px; }
.meas-item .meas-tol { font-size: 12px; color: #6b7280; }
.meas-item .line2 { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.meas-item .line2 input { flex: 1; }
.seg { display: flex; border: 1px solid #ccd3dd; border-radius: 9px; overflow: hidden; flex: 0 0 auto; }
.seg button { padding: 9px 11px; border: 0; background: #fff; font-size: 13px; font-weight: 700; font-family: inherit; cursor: pointer; color: #55606f; min-width: 50px; }
.seg button + button { border-left: 1px solid #e3e7ee; }
.seg button.on.good, .seg button.on.pass { background: var(--ok); color: #fff; }
.seg button.on.bad, .seg button.on.fail { background: var(--bad); color: #fff; }
.seg button.on.cond { background: var(--warn); color: #fff; }
.insp-summary { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.insp-summary.pass { background: var(--ok-bg); color: var(--ok); }
.insp-summary.fail { background: var(--bad-bg); color: var(--bad); }
.insp-summary.conditional { background: var(--warn-bg); color: var(--warn); }

/* 목록 */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.toolbar .grow { flex: 1 1 160px; min-width: 130px; }
.toolbar label.f { margin-bottom: 0; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 11px 13px; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 23px; font-weight: 800; letter-spacing: -.5px; margin-top: 2px; }
.stat .v.warn { color: var(--warn); }
.stat .v.bad { color: var(--bad); }
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { padding: 10px 9px; text-align: left; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
table.list th { background: #f7f9fc; font-size: 12.5px; color: #4b5563; font-weight: 700; white-space: nowrap; }
table.list tbody tr.clickable { cursor: pointer; }
table.list tbody tr.clickable:hover { background: #f6f9ff; }
table.list td.num { font-variant-numeric: tabular-nums; }
table.list td.no { font-size: 12.5px; color: var(--muted); }
.thumb-sm { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; background: #f1f4f9; }
.thumb-sm.empty { display: flex; align-items: center; justify-content: center; color: #b6bdca; font-size: 11px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 12px; }
.empty-state { padding: 34px 16px; text-align: center; color: var(--muted); font-size: 14px; }

/* 상태 배지 */
.status-pill { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-pill.none { background: #eef1f7; color: #4b5563; }
.status-pill.passed { background: var(--ok-bg); color: var(--ok); }
.status-pill.failed { background: var(--bad-bg); color: var(--bad); }
.status-pill.conditional { background: var(--warn-bg); color: var(--warn); }

/* 상세 */
.kv { display: grid; grid-template-columns: 116px 1fr; }
.kv > div { padding: 9px 4px; border-bottom: 1px solid #eef1f6; font-size: 14px; }
.kv > .k { color: var(--muted); font-size: 13px; font-weight: 600; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.photo-grid img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }

/* 토스트 */
#toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%) translateY(16px);
  background: #1f2937; color: #fff; padding: 11px 17px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .18s; z-index: 100; max-width: 88vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--bad); }
.err-text { color: var(--bad); font-size: 13px; min-height: 18px; margin: 6px 0 0; }

/* 로그인 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 390px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 24px 20px; box-shadow: 0 8px 28px rgba(20,24,31,.06); }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p.sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.demo-note { margin-top: 16px; padding: 10px 12px; background: #f6f8fc; border-radius: 10px; font-size: 12px; color: #4b5563; line-height: 1.65; }

/* 안내 화면 */
.notice { max-width: 460px; margin: 12vh auto 0; text-align: center; padding: 0 20px; }
.notice .ico { font-size: 40px; }
.notice h1 { font-size: 19px; margin: 12px 0 8px; }
.notice p { color: #4b5563; font-size: 14px; }

/* 인쇄 */
@media print {
  .topbar, .tabs, .sticky-actions, .no-print, #toast, .pw-note { display: none !important; }
  body { background: #fff; }
  .card { border: 1px solid #999; break-inside: avoid; }
}

/* 화면 폭 */
@media (min-width: 768px) {
  .wrap { padding: 22px; }
  .mobile-only { display: none !important; }
}
@media (max-width: 767px) {
  .desktop-only { display: none !important; }
  /* 상단 바: 제목·사용자명이 두 줄로 접히지 않도록 */
  .topbar { padding: 8px 10px; gap: 6px; flex-wrap: nowrap; }
  .topbar .title {
    font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    min-width: 0; flex: 1 1 auto;
  }
  .topbar .build-tag { display: none; }
  .topbar .who {
    margin-left: auto; flex: 0 0 auto; gap: 6px; font-size: 12px; white-space: nowrap;
  }
  .topbar .who .badge { display: none; }
  .topbar .who b {
    max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block;
  }
  .topbar .who .btn.sm { padding: 6px 10px; font-size: 12px; }
  .topnav { padding: 8px 8px; gap: 4px; }
  .topnav a { padding: 7px 9px; font-size: 12.5px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .stat .v { font-size: 20px; }
  .toolbar .grow { flex: 1 1 100%; }
  table.list { font-size: 13px; }
  /* 목록 화면에서만 '규격'(6번째)과 '작성자'(9번째) 열을 숨깁니다.
     QC 측정 표(table.list)는 그대로 보여야 하므로 목록 표에만 적용합니다. */
  table.list-receipts th:nth-child(6), table.list-receipts td:nth-child(6),
  table.list-receipts th:nth-child(9), table.list-receipts td:nth-child(9) { display: none; }
  .kv { grid-template-columns: 94px 1fr; }
  .row2 { grid-template-columns: 1fr 1fr; }
}

/* 자재 관리 — QC 측정 항목 입력 줄 */
.qi-row { display: grid; grid-template-columns: 48px 1fr 1fr 1fr auto; gap: 8px; align-items: end;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px 10px; margin-bottom: 8px; }
.qi-cell { display: block; }
.qi-cell > span { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.qi-cell input { padding: 9px 10px; font-size: 15px; }
.qi-row .qi-del { margin-bottom: 1px; }
.qi-symbol-cell > span { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.qi-sym { width: 100%; height: 38px; font-size: 15px; }
.tol-wrap { display: flex; align-items: center; border: 1px solid #ccd3dd; border-radius: 10px; background: #fff; overflow: hidden; }
.tol-wrap:focus-within { outline: 2px solid #b9ccff; border-color: var(--blue); }
.tol-wrap .tol-sign { padding: 0 8px; color: #6b7280; font-weight: 700; background: #f3f5f9; align-self: stretch; display: flex; align-items: center; }
.tol-wrap input { border: 0; border-radius: 0; padding-left: 8px; }
.tol-wrap input:focus { outline: none; }
@media (max-width: 767px) {
  .qi-row { grid-template-columns: 48px 1fr; }
  .qi-row .qi-cell:not(.qi-symbol-cell) { grid-column: 1 / -1; }
  .qi-row .qi-del { justify-self: end; grid-column: 2; }
}

/* QC 참고 도면/사진 (측정 화면) */
.qc-ref { border: 1px solid #cfdbf7; background: #fff; border-radius: 10px; padding: 8px; margin-bottom: 10px; }
.qc-ref .qc-ref-title { font-size: 12.5px; font-weight: 700; color: #1e40af; margin-bottom: 6px; }
.qc-ref .qc-ref-imgs { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.qc-ref img { height: 168px; width: auto; max-width: 88%; object-fit: contain; background: #f7f9fc;
  border: 1px solid var(--line); border-radius: 8px; display: block; cursor: zoom-in; }
.qc-sym { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 22px;
  padding: 0 6px; border-radius: 6px; background: #e7edff; color: #1e40af; font-weight: 800; font-size: 12.5px; }
/* 도면 확대 보기 */
#zoom { position: fixed; inset: 0; background: rgba(10,14,20,.92); display: none; z-index: 200; align-items: center; justify-content: center; }
#zoom.on { display: flex; }
#zoom img { max-width: 96vw; max-height: 92vh; object-fit: contain; background: #fff; border-radius: 6px; }
#zoom .close { position: absolute; top: 14px; right: 16px; color: #fff; font-size: 30px; line-height: 1; cursor: pointer; }

/* ================= 입력 방식 선택 (2026-11-03 추가) ================= */
.mode-pick { display: grid; gap: 10px; }
.mode-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 16px 14px; background: #fff; border: 2px solid var(--line); border-radius: 14px;
  font-family: inherit; cursor: pointer;
}
.mode-btn:active { transform: translateY(1px); }
.mode-btn .m-ico { font-size: 30px; line-height: 1; flex: 0 0 auto; }
.mode-btn .m-txt { display: block; }
.mode-btn .m-title { display: block; font-size: 16px; font-weight: 800; color: var(--ink); }
.mode-btn .m-desc { display: block; font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.mode-btn.primary { border-color: var(--blue); background: #f5f8ff; }

/* 자동입력 안내/경고 */
.ocr-banner { border: 1px solid #f0c680; background: #fffbeb; color: #92400e; border-radius: 10px;
  padding: 10px 12px; font-size: 13px; line-height: 1.6; margin-bottom: 10px; }
.ocr-banner.ok { border-color: #b9e3c6; background: #f2fbf5; color: #15803d; }
.ocr-banner .b-title { font-weight: 800; display: block; margin-bottom: 2px; }
.warn-box { border: 1px solid #f0c680; background: #fffbeb; border-radius: 8px; padding: 8px 10px;
  font-size: 12.5px; color: #92400e; margin: 8px 0; line-height: 1.55; }
.warn-box ul { margin: 4px 0 0; padding-left: 18px; }
.field-warn input, .field-warn select { border-color: #e0a24a; background: #fffdf5; }

/* 품목 행 */
.item-card { border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 12px;
  padding: 12px; margin-bottom: 10px; background: #fff; }
.item-card .item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.item-card .item-head .no { font-weight: 800; font-size: 14px; color: var(--info); }
.item-card .item-head .nm { font-weight: 700; font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-card .item-head .del { margin-left: auto; }
.item-sub { font-size: 12px; color: var(--muted); margin: -4px 0 8px; }
.item-photos { margin-top: 8px; }
.item-photos .add-row { display: flex; gap: 8px; }
.item-photos .shot-btn { flex: 1; min-height: 56px; flex-direction: row; gap: 6px; font-size: 13px; }
.item-photos .shot-btn .big { font-size: 18px; }

/* 수량 일치 확인 */
.qty-check { border: 1px solid #cfe0ff; background: #f6f9ff; border-radius: 10px; padding: 9px 10px; margin-top: 8px; }
.qty-check .qc-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--info); margin-bottom: 7px; }
.qty-check .qc-head .st { margin-left: auto; font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: #e8eefc; color: #4b5b7a; }
.qty-check .qc-head .st.mm { background: #fff1e0; color: #b45309; }
.qty-check .qc-head .st.ok { background: #e9f7ee; color: #15803d; }
.qty-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
.qty-grid label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.qty-grid label span { display: block; margin-bottom: 3px; }
.qty-grid input { width: 100%; }
.ox { display: flex; gap: 6px; margin-top: 8px; }
.ox button { flex: 1; padding: 10px; border-radius: 9px; border: 1px solid #ccd3dd; background: #fff;
  font-family: inherit; font-weight: 800; font-size: 14px; color: #55606f; cursor: pointer; }
.ox button.on.o { background: var(--ok); border-color: var(--ok); color: #fff; }
.ox button.on.x { background: var(--bad); border-color: var(--bad); color: #fff; }
.mm-reason { margin-top: 8px; }
.badge-mm { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 800;
  background: #fff1e0; color: #b45309; border: 1px solid #f0c680; }
.receipt-auto-note { font-size: 12px; color: var(--muted); }

/* 신규 자재 자동 등록 (현장 사진 자동입력) */
.auto-badge { display: block; border: 1px solid #bcd0ff; background: #eef4ff; color: #1e40af;
  border-radius: 9px; padding: 8px 10px; font-size: 12.5px; font-weight: 700; line-height: 1.55; margin: 8px 0; }
.auto-badge .hint { font-weight: 400; color: #40598f; }
.tag-new { display: inline-block; padding: 1px 6px; border-radius: 999px; font-size: 10.5px; font-weight: 800;
  background: #eef4ff; color: #1e40af; border: 1px solid #bcd0ff; margin-left: 4px; vertical-align: 1px; }
.tag-src { display: inline-block; padding: 1px 6px; border-radius: 999px; font-size: 10.5px; font-weight: 700;
  background: #eef4ff; color: #1e40af; border: 1px solid #bcd0ff; }
.tag-auto { background: #f3e8ff; color: #6b21a8; border-color: #d8b4fe; }

/* 신규 자재 정리 화면 */
.rev-form { background: #f9fbff; border: 1px solid #dbe6fb; border-radius: 10px; padding: 12px; margin: 4px 0 10px; }
.rev-form .f { margin-bottom: 8px; }
.rev-edit > td { background: #f4f8ff; }
.rev-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex;
  align-items: flex-start; justify-content: center; padding: 24px 14px; z-index: 60; overflow: auto; }
.rev-modal-box { background: #fff; border-radius: 14px; padding: 16px; width: 100%; max-width: 520px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .25); }
.rev-modal-box h2 { font-size: 16px; margin: 0 0 8px; }
.rev-merge-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; max-height: 46vh; overflow: auto; }
.rev-merge-list .btn { text-align: left; justify-content: flex-start; }
.rev-merge-list .hint { color: #6b7280; font-weight: 400; font-size: 11.5px; }


/* ---------- 알림 팝업 ---------- */
.notify-popup {
  position: fixed; right: 14px; bottom: 84px; z-index: 60; width: min(320px, calc(100vw - 28px));
  background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--blue);
  border-radius: 12px; box-shadow: 0 10px 30px rgba(15,23,42,.18); padding: 12px 14px;
  display: none;
}
.notify-popup.on { display: block; animation: npIn .18s ease-out; }
.notify-popup.warn { border-left-color: #b3261e; }
.notify-popup.warn .np-head { color: #b3261e; }
@keyframes npIn { from { transform: translateY(8px); opacity: 0 } to { transform: none; opacity: 1 } }
.notify-popup .np-head { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.notify-popup .np-body { font-size: 13.5px; color: #374151; line-height: 1.6; }
.notify-popup .np-btn { margin-top: 8px; }
.notify-popup .np-close {
  position: absolute; top: 6px; right: 8px; border: 0; background: transparent;
  font-size: 18px; line-height: 1; color: #9aa3af; cursor: pointer;
}


/* ---------- 품질 특이사항 (빨간 테두리로 눈에 띄게) ---------- */
.issue-field > span { color: #b3261e; font-weight: 700; }
.issue-input {
  border: 2px solid #e05252 !important;
  background: #fff7f7 !important;
}
.issue-input:focus { outline: none; border-color: #b3261e !important; box-shadow: 0 0 0 3px rgba(179,38,30,.12); }
.issue-input::placeholder { color: #c98a8a; }
.issue-shot { border-color: #e05252 !important; }
.issue-shot span:last-child { color: #b3261e; font-weight: 600; }


/* 상단 홈 버튼 */
.home-btn {
  display: inline-flex; align-items: center; gap: 4px; margin-right: 10px;
  padding: 6px 10px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: #1e40af; font-size: 13px; font-weight: 700;
  text-decoration: none; white-space: nowrap;
}
.home-btn:hover { background: #eef3ff; }


/* 빌드 표시 */
.build-tag { font-size: 11px; color: #9aa3af; margin-left: 8px; font-weight: 400; }


/* QC 항목별 참고 이미지 */
.qi-img { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qi-img img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.qi-img-none { font-size: 12px; color: #9aa3af; }
.qi-img-btn { cursor: pointer; }


/* QC 측정 항목 참고 이미지 (입고 화면) */
.meas-img { display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; }
.meas-img img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.meas-img .hint { font-size: 11.5px; color: #9aa3af; }


/* ---------- 홈 큰 버튼 ---------- */
.home-big { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 6px 0 16px; }
.home-tile.ship { border-color: #cfe9d8; background: linear-gradient(180deg,#f6fdf8,#fff); }
.home-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 28px 14px; border-radius: 16px; text-decoration: none;
  border: 1px solid var(--line); background: #fff; color: #111;
  box-shadow: 0 2px 10px rgba(15,23,42,.05);
}
.home-tile:active { transform: translateY(1px); }
.home-tile.order { border-color: #cfdbf7; background: linear-gradient(180deg,#f7faff,#fff); }
.home-tile.stock { border-color: #cdeeda; background: linear-gradient(180deg,#f4fdf8,#fff); }
.home-tile .t-ico { font-size: 40px; line-height: 1; }
.home-tile .t-title { font-size: 22px; font-weight: 800; }
.home-tile .t-sub { font-size: 12.5px; color: #6b7280; }
.home-tile .t-badge {
  position: absolute; top: 10px; right: 12px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; background: #b3261e; color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
@media (max-width: 640px) {
  /* 모바일: 큰 아이콘 타일을 세로로 3개 */
  .home-big { grid-template-columns: 1fr; gap: 10px; }
  .home-tile { padding: 20px 16px; flex-direction: row; align-items: center; text-align: left; gap: 14px; }
  .home-tile .t-ico { font-size: 38px; line-height: 1; }
  .home-tile .t-title { font-size: 19px; }
  .home-tile .t-sub { font-size: 13px; text-align: left; }
  .home-tile .t-arrow { margin-left: auto; }
}


/* ---------- 발주 ---------- */
.order-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; background: #fff; }
.order-row-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.order-row-head b { font-size: 14px; }
.msg-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.msg { border-radius: 10px; padding: 8px 10px; font-size: 13.5px; max-width: 92%; }
.msg-admin { background: #eef3ff; border: 1px solid #cfdbf7; align-self: flex-start; }
.msg-me { background: #f4f7f4; border: 1px solid #d7e6d7; align-self: flex-end; }
.msg-head { font-size: 11.5px; color: #6b7280; margin-bottom: 2px; }


/* PC 상단 메뉴 */
.topnav {
  display: flex; gap: 6px; padding: 8px 16px; background: #fff;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
  overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch;
}
.topnav a { flex: 0 0 auto; }
.topnav a {
  padding: 8px 14px; border-radius: 9px; text-decoration: none; font-size: 14px;
  font-weight: 700; color: #4b5563; background: #f3f5f9;
}
.topnav a.on { background: var(--blue); color: #fff; }


/* ---------- 발주 상태 색 구분 ---------- */
.order-row.status-requested { border-left: 6px solid #2563eb; background: #eef4ff; }
.order-row.status-held      { border-left: 6px solid #dc2626; background: #fef2f2; }
.order-row.status-ordered   { border-left: 6px solid #16a34a; background: #e9fbf0; }
.order-row.status-canceled  { border-left: 6px solid #9ca3af; background: #fff; }
/* 발주취소는 색 대신 가운데 줄로 표시 */
.order-row.status-canceled .order-row-head b { text-decoration: line-through; color: #9aa3af; }
.order-row.status-canceled .item-sub { text-decoration: line-through; color: #9aa3af; }
.order-row.status-requested .status-pill { background:#dbeafe; color:#1e40af; }
.order-row.status-held .status-pill { background:#fecaca; color:#991b1b; }
.order-row.status-ordered .status-pill { background:#bbf7d0; color:#14532d; }
.order-row.status-canceled .status-pill { background:#e5e7eb; color:#374151; }
.order-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: #4b5563; margin: 0 0 10px; }
.order-legend span { display: inline-flex; align-items: center; gap: 5px; }
.order-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.order-legend i.requested { background: #2563eb; }
.order-legend i.held { background: #dc2626; }
.order-legend i.ordered { background: #16a34a; }
.order-legend i.canceled { background: #9ca3af; }


/* 발주서 작성 박스 */
.po-box { border: 1px solid #cfdbf7; background: #f7faff; border-radius: 12px; padding: 12px; margin-top: 12px; }
.po-box .po-title { font-weight: 800; font-size: 14px; color: #1e40af; margin-bottom: 4px; }


/* PC에서는 상단 메뉴에 홈이 있으므로 제목 옆 홈 버튼은 숨깁니다(중복 제거) */
@media (min-width: 768px) { #btnHome { display: none; } }

/* ---------- 모바일: 상단 바 / 메뉴 (파일 뒤쪽 규칙보다 우선) ---------- */
@media (max-width: 767px) {
  .topnav { padding: 8px 8px; gap: 4px; }
  .topnav a { padding: 7px 9px; font-size: 12.5px; border-radius: 8px; }
}

/* 모바일: 메뉴가 7개라 한 줄에 안 들어감 → 두 줄로 자연스럽게 배치 */
@media (max-width: 767px) {
  .topnav { flex-wrap: wrap; overflow-x: visible; row-gap: 6px; }
}

/* ---------- 브랜드 (홈 상단 CI + 회사명) ---------- */
.topbar .title.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .title.brand .ci { height: 26px; width: auto; display: block; }
.topbar .title.brand span {
  font-weight: 800; font-size: 16px; letter-spacing: -0.2px; color: #111;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 767px) {
  .topbar .title.brand .ci { height: 22px; }
  .topbar .title.brand span { font-size: 15px; }
}

/* 상단 '할 일' 배지 (처리할 일이 있을 때) */
#navTodo.has-todo { background: #fdeceb; color: #b3261e; }
#navTodo.has-todo.on { background: #b3261e; color: #fff; }
.nav-count {
  display: inline-block; margin-left: 5px; padding: 1px 6px; border-radius: 999px;
  vertical-align: middle;
  background: #b3261e; color: #fff; font-size: 11px; font-weight: 800; line-height: 1.5;
}
#navTodo.on .nav-count { background: #fff; color: #b3261e; }

/* 할 일 카드: 카드 전체를 눌러 이동 */
.todo-card { display: block; text-decoration: none; color: inherit; cursor: pointer; transition: transform .08s ease, box-shadow .12s ease; }
.todo-card:hover { box-shadow: 0 3px 14px rgba(20, 24, 31, .08); }
.todo-card:active { transform: scale(.995); }
.todo-card h2 { color: inherit; }
.todo-go { margin-left: auto; font-size: 22px; line-height: 1; color: #9aa3af; font-weight: 700; }

/* 상단 메뉴: 항목이 많아 PC에서도 줄바꿈 허용 */
.topnav { flex-wrap: wrap; row-gap: 6px; }
@media (min-width: 768px) {
  .topnav a { padding: 7px 11px; font-size: 13.5px; }
}

/* ---------- 모바일: 글자 크기·여백 축소 (한 화면에 더 많이 보이게) ---------- */
@media (max-width: 767px) {
  body { font-size: 14px; line-height: 1.45; }
  .card { padding: 12px; }
  .card h2 { font-size: 14.5px; margin-bottom: 8px; }
  .card .desc { font-size: 12px; }
  label.f > span { font-size: 12.5px; }
  input, select, textarea { font-size: 15px; padding: 9px 10px; }
  .btn { padding: 10px 12px; font-size: 14px; }
  .btn.sm { padding: 6px 10px; font-size: 12.5px; }
  .status-pill { font-size: 11px; padding: 2px 7px; }
  .item-sub, .hint { font-size: 12px; }
  table.list th, table.list td { font-size: 12.5px; padding: 7px 6px; }
  .topnav a { font-size: 12.5px; padding: 6px 9px; }
  .wrap { padding-left: 10px; padding-right: 10px; }
  .home-tile .t-title { font-size: 17px; }
  .home-tile .t-sub { font-size: 12px; }
  .login-card h1 { font-size: 20px; }
}
@media (max-width: 380px) {
  body { font-size: 13.5px; }
  .card { padding: 10px; }
  .topnav a { font-size: 12px; padding: 5px 8px; }
}

/* 가로 스크롤 방지 */
html, body { max-width: 100%; overflow-x: hidden; }
img, table, pre { max-width: 100%; }
table.list { table-layout: fixed; }
table.list td input, table.list td select { min-width: 0; }

/* ---------- 모바일: 상단 메뉴 한 줄 스크롤 + 타일 글자 넘침 방지 ---------- */
@media (max-width: 767px) {
  .topnav {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav a { flex: 0 0 auto; }

  .home-tile { align-items: center; }
  .home-tile .t-title { white-space: nowrap; }
  .home-tile .t-sub { white-space: normal; overflow-wrap: anywhere; }

  /* 카드 안의 긴 단어/숫자도 넘치지 않게 */
  .card, .order-row, .arc-row { overflow-wrap: anywhere; }
  .status-pill { white-space: nowrap; }
  .btn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 400px) {
  .home-tile { gap: 10px; padding: 16px 12px; }
  .home-tile .t-ico { font-size: 32px; }
  .home-tile .t-title { font-size: 16px; }
  .home-tile .t-sub { font-size: 11.5px; }
}

/* ---------- 모바일: 품목 입력 표 → 카드형 ---------- */
@media (max-width: 767px) {
  table.list.item-table { display: block; }
  table.list.item-table thead { display: none; }
  table.list.item-table tbody { display: block; }
  table.list.item-table tr {
    display: block; border: 1px solid var(--line); border-radius: 12px;
    padding: 8px 10px; margin-bottom: 8px; background: #fbfcff;
  }
  table.list.item-table td {
    display: flex; align-items: center; gap: 8px; width: auto !important;
    border: 0; padding: 4px 0; font-size: 13px;
  }
  table.list.item-table td::before {
    content: attr(data-label); flex: 0 0 68px; font-size: 12px; color: #6b7280; font-weight: 600;
  }
  table.list.item-table td[data-label=""]::before { content: none; }
  table.list.item-table td input, table.list.item-table td select { flex: 1 1 auto; width: 100%; }
  table.list.item-table td .del { margin-left: auto; }
  .row2 { grid-template-columns: 1fr; }
}

/* ---------- 발주 상세: 제품 사진 크게 ---------- */
.po-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 6px 0 4px; }
.po-photos figure { margin: 0; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: #fff; }
.po-photos img { width: 100%; height: 160px; object-fit: contain; background: #fafafa; border-radius: 6px; display: block; }
.po-photos figcaption { font-size: 12px; color: #6b7280; margin-top: 4px; }
@media (max-width: 767px) {
  .po-photos { grid-template-columns: repeat(2, 1fr); }
  .po-photos img { height: 130px; }
}

/* 발주 상태 배지 — 요청(파랑) / 보류(빨강) 구분 강화 */
.status-pill.pending { background: #dbeafe; color: #1e40af; }
.status-pill.hold, .status-pill.held { background: #fecaca; color: #991b1b; }

/* 클릭 가능한 발주 카드 */
.order-row.clickable { cursor: pointer; transition: box-shadow .12s ease, transform .12s ease; }
.order-row.clickable:hover { box-shadow: 0 3px 14px rgba(15,23,42,.09); }
.order-row.clickable:active { transform: translateY(1px); }
.row-more { margin-top: 8px; font-size: 12.5px; font-weight: 700; color: #1d4ed8; }
