/* 농어촌 빈집 실태조사 PWA — 모바일 우선 */
:root {
  --green: #1a5c3a;
  --green-light: #e7f3ec;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --blue: #1d4ed8;
  --gray: #6b7280;
  --border: #d1d5db;
  --bg: #f4f5f4;
  --card: #ffffff;
  --text: #1f2937;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg); color: var(--text);
  padding-bottom: 2rem;
}
.topbar {
  background: var(--green); color: #fff;
  padding: 0.9rem 1rem; position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 1.15rem; }
.topbar-sub { font-size: 0.75rem; opacity: 0.85; }

.view { max-width: 640px; margin: 0 auto; padding: 0.8rem; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 0.9rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.card h2 { font-size: 1.05rem; color: var(--green); margin-bottom: 0.7rem; }
.sub-h { font-size: 0.95rem; margin: 0.8rem 0 0.4rem; }
.sub-h small { color: var(--gray); font-weight: normal; }
.hint { font-size: 0.8rem; color: var(--gray); margin-bottom: 0.6rem; line-height: 1.4; }
.empty { text-align: center; color: var(--gray); padding: 2.5rem 0; line-height: 1.7; }
.req { color: var(--red); font-size: 0.75rem; }
.auto-tag { font-size: 0.7rem; background: var(--green-light); color: var(--green); padding: 0.1rem 0.4rem; border-radius: 6px; }

/* 필드 */
.field { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.7rem; flex: 1; }
.field input, .field select, textarea {
  display: block; width: 100%; margin-top: 0.25rem;
  padding: 0.7rem 0.75rem; font-size: 1rem; font-weight: normal;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.field input:focus, textarea:focus { outline: 2px solid var(--green); border-color: var(--green); }
.field input[readonly] { background: #f3f4f6; color: var(--gray); }
.field-row { display: flex; gap: 0.6rem; }
textarea { resize: vertical; }

/* 버튼 — 큰 터치 타깃 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0.55rem 1rem;
  font-size: 0.95rem; font-weight: 700;
  border: none; border-radius: 10px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn-big { width: 100%; min-height: 54px; font-size: 1.1rem; }
.btn-sm { min-height: 36px; padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.btn-primary { background: var(--green); color: #fff; }
.btn-outline { background: #fff; color: var(--green); border: 2px solid var(--green); }
.btn-danger { background: var(--red-bg); color: var(--red); border: 2px solid var(--red); }
.btn-gps { background: var(--blue); color: #fff; margin-bottom: 0.6rem; }

.list-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.8rem; }
.list-actions .btn-big { flex-basis: 100%; }
.list-actions .btn-outline { flex: 1; }

.form-nav { display: flex; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.8rem; }
.form-nav.bottom { margin-top: 0.4rem; }
.form-nav .btn-big { flex: 1; width: auto; }

/* 목록 */
.survey-list { list-style: none; }
.survey-item {
  background: var(--card); border-radius: var(--radius);
  padding: 0.85rem 1rem; margin-bottom: 0.55rem;
  display: flex; align-items: center; gap: 0.7rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07); cursor: pointer;
}
.survey-item .si-main { flex: 1; min-width: 0; }
.survey-item .si-id { font-weight: 800; font-size: 1.05rem; }
.survey-item .si-meta { font-size: 0.78rem; color: var(--gray); margin-top: 0.15rem; }
.badge {
  display: inline-block; padding: 0.2rem 0.55rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700; white-space: nowrap;
}
.badge-g1 { background: var(--green-light); color: var(--green); }
.badge-g2 { background: var(--amber-bg); color: var(--amber); }
.badge-g3 { background: var(--red-bg); color: var(--red); }
.badge-gray { background: #e5e7eb; color: var(--gray); }
.badge-vacant { background: var(--red-bg); color: var(--red); }
.badge-notvacant { background: #e0e7ff; color: var(--blue); }

/* GPS */
.gps-status { font-size: 0.85rem; margin-bottom: 0.5rem; min-height: 1.1em; color: var(--gray); }
.warn-box {
  background: var(--amber-bg); color: var(--amber);
  border-radius: 8px; padding: 0.7rem; font-size: 0.85rem;
  margin-top: 0.6rem; line-height: 1.5;
}
.warn-box .btn { margin-top: 0.4rem; border-color: var(--amber); color: var(--amber); }

/* 사진 */
.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.photo-slot {
  border: 2px dashed var(--border); border-radius: 10px;
  min-height: 120px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.3rem;
  position: relative; overflow: hidden; cursor: pointer; background: #fafafa;
}
.photo-slot.has-photo { border-style: solid; border-color: var(--green); }
.photo-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-slot .ps-label {
  position: relative; z-index: 1; font-weight: 800; font-size: 1rem;
}
.photo-slot.has-photo .ps-label {
  background: rgba(0,0,0,0.55); color: #fff; padding: 0.15rem 0.6rem; border-radius: 6px;
}
.photo-slot .ps-hint { font-size: 0.72rem; color: var(--gray); }
.photo-slot input { display: none; }
.photo-del {
  position: absolute; top: 4px; right: 4px; z-index: 2;
  background: rgba(0,0,0,0.6); color: #fff; border: none;
  width: 30px; height: 30px; border-radius: 50%; font-size: 0.9rem; cursor: pointer;
}

/* 판정 체크리스트 */
.check-list { display: flex; flex-direction: column; gap: 0.4rem; }
.check-item {
  display: flex; gap: 0.6rem; align-items: flex-start;
  background: #fafafa; border: 1px solid var(--border);
  border-radius: 8px; padding: 0.6rem 0.7rem; cursor: pointer;
}
.check-item input { width: 22px; height: 22px; margin-top: 0.1rem; flex-shrink: 0; accent-color: var(--green); }
.check-item .ci-title { font-weight: 700; font-size: 0.88rem; }
.check-item .ci-desc { font-size: 0.76rem; color: var(--gray); margin-top: 0.1rem; line-height: 1.4; }
.check-item:has(input:checked) { background: var(--green-light); border-color: var(--green); }

.verdict-box {
  margin-top: 0.8rem; padding: 0.9rem; border-radius: 10px;
  text-align: center; font-size: 1.05rem; font-weight: 800;
}
.verdict-vacant { background: var(--red-bg); color: var(--red); }
.verdict-not { background: #e0e7ff; color: var(--blue); }
.verdict-box small { display: block; font-size: 0.78rem; font-weight: 400; margin-top: 0.25rem; }

/* 등급 산정 */
.area-block { margin-bottom: 1rem; }
.area-head {
  display: flex; justify-content: space-between; align-items: baseline;
  background: var(--green-light); padding: 0.5rem 0.7rem; border-radius: 8px 8px 0 0;
  font-weight: 800; font-size: 0.9rem; color: var(--green);
}
.area-items { border: 1px solid var(--border); border-top: none; border-radius: 0 0 8px 8px; }
.grade-item { padding: 0.6rem 0.7rem; border-bottom: 1px solid #eee; }
.grade-item:last-child { border-bottom: none; }
.gi-top { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.85rem; font-weight: 700; }
.gi-score { color: var(--green); white-space: nowrap; }
.gi-crit { font-size: 0.73rem; color: var(--gray); margin: 0.15rem 0 0.35rem; }
.gi-levels { display: flex; gap: 0.3rem; }
.gi-levels button {
  flex: 1; min-height: 40px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; font-size: 0.72rem; cursor: pointer; padding: 0.2rem 0.1rem; line-height: 1.25;
}
.gi-levels button.sel-0 { background: var(--green-light); border-color: var(--green); font-weight: 700; }
.gi-levels button.sel-mid { background: var(--amber-bg); border-color: var(--amber); font-weight: 700; }
.gi-levels button.sel-max { background: var(--red-bg); border-color: var(--red); font-weight: 700; }

.score-summary {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.3rem;
  text-align: center; margin: 0.8rem 0 0.4rem;
}
.score-summary .ss-cell { background: #fafafa; border: 1px solid var(--border); border-radius: 8px; padding: 0.4rem 0.15rem; }
.score-summary .ss-name { font-size: 0.68rem; color: var(--gray); }
.score-summary .ss-val { font-size: 0.95rem; font-weight: 800; }
.score-summary .ss-total { background: var(--green-light); border-color: var(--green); }
.score-summary .ss-total .ss-val { color: var(--green); }

.grade-badge { text-align: center; margin-top: 0.7rem; }
.grade-badge .gb {
  display: inline-block; padding: 0.8rem 1.6rem; border-radius: 14px;
  font-size: 1.5rem; font-weight: 900;
}
.grade-badge .gb small { display: block; font-size: 0.8rem; font-weight: 600; margin-top: 0.15rem; }
.gb-1 { background: var(--green-light); color: var(--green); }
.gb-2 { background: var(--amber-bg); color: var(--amber); }
.gb-3 { background: var(--red-bg); color: var(--red); }
.gb-none { background: #e5e7eb; color: var(--gray); font-size: 1rem !important; }

/* 부속사 (동 단위) */
.annex-card {
  background: #fafafa; border: 1px solid var(--border);
  border-radius: 10px; padding: 0.7rem; margin-bottom: 0.7rem;
}
.annex-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.annex-no { font-weight: 800; font-size: 0.95rem; color: var(--green); }
.annex-del { position: static; }
.ax-manure-row { margin-bottom: 0.6rem; }
.annex-tools { display: flex; gap: 0.6rem; align-items: stretch; }
.annex-photo { width: 110px; min-height: 90px; flex-shrink: 0; background: #fff; }
.annex-gps { flex: 1; display: flex; flex-direction: column; gap: 0.35rem; }
.annex-gps .btn { align-self: flex-start; }
.ax-gps-status { font-size: 0.75rem; margin-bottom: 0; }

.toast {
  position: fixed; left: 50%; bottom: 2rem; transform: translateX(-50%);
  background: rgba(0,0,0,0.82); color: #fff;
  padding: 0.7rem 1.3rem; border-radius: 999px; font-size: 0.9rem;
  z-index: 100; white-space: nowrap;
}

@media (min-width: 480px) {
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
}
