/* =========================================================
   에이프레시 카페맵 - 공통 스타일 (영업 앱 / 배송 앱 / 로그인 / 운영자)
   새벽 배송 중 차 안에서 보기 좋도록 글씨와 버튼을 크게 잡음
   ========================================================= */
:root {
  --brand: #18324F;      /* 앱 대표색 (영업: 우유 파랑, 배송 앱에서 바꿈) */
  --ink: #18324F;        /* 기본 글자색 */
  --sub: #5B6B80;        /* 보조 글자색 */
  --bg: #FFFFFF;         /* 카드 배경 */
  --line: #DCE3EC;       /* 구분선 */
  --soft: #F1F5F9;       /* 옅은 배경 */
  --crate: #F2B705;      /* 강조 버튼 (우유 상자 노랑) */
  --crate-ink: #1A1400;
  --danger: #C0392B;
  --s0: #1E9E5A;         /* 거래중 */
  --s1: #2F6FDE;         /* 영업중 */
  --s2: #E07A1F;         /* 미방문 */
  --s3: #9B7FD1;         /* 후보 (공공데이터에서 가져온 미확인 카페) */
  --s4: #A9461F;         /* 거절 */
  --s5: #6B7380;         /* 폐업 */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #E8EEF5; --sub: #9AA9BC; --bg: #13202F; --line: #26384D;
    --soft: #1A2A3C; --danger: #FF7B6B; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  /* 글꼴은 화면에 나오는 글자 조각만 받는 방식 (처음 열 때 LTE에서 빠르게) */
  font-family: "Pretendard Variable", "Pretendard", -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid var(--crate); outline-offset: 2px; }
[hidden] { display: none !important; }

#map { position: fixed !important; inset: 0; width: 100%; height: 100%; }

/* ---------- 상단: 검색 + 내 메뉴 + 필터 ---------- */
.top {
  position: fixed; left: 0; right: 0; top: 0; z-index: 10;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 0;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.top-row { display: flex; gap: 8px; }
.search {
  flex: 1; min-width: 0; height: 48px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg);
  box-shadow: 0 2px 10px rgba(24, 50, 79, .15); font-size: 16px;
}
.me-btn {
  flex: none; width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 2px 10px rgba(24, 50, 79, .25);
}
.menu {
  position: absolute; right: 12px; margin-top: 6px; min-width: 220px; z-index: 15;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 6px 20px rgba(24,50,79,.22); overflow: hidden;
}
.menu .who { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--sub); }
.menu .who b { display: block; color: var(--ink); font-size: 16px; }
.menu a, .menu button {
  display: block; width: 100%; text-align: left; padding: 13px 16px; border: 0; background: none;
  border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 15px;
}
.menu > :last-child { border-bottom: 0; }
.app-tag {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .02em;
  background: var(--brand); color: #fff; padding: 2px 6px; border-radius: 4px; vertical-align: 2px;
}

.results {
  margin-top: 6px; background: var(--bg); border-radius: 12px;
  border: 1px solid var(--line); max-height: 45vh; overflow-y: auto;
}
.results button {
  display: flex; width: 100%; gap: 10px; align-items: center; text-align: left;
  padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line); background: none;
}
.results small { color: var(--sub); display: block; }
.chips { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; }
.chip {
  flex: none; height: 34px; padding: 0 12px; border-radius: 17px;
  border: 1px solid var(--line); background: var(--bg); font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip[aria-pressed="false"] { opacity: .45; }

/* 상태별 동그라미 */
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.s0 .dot, .dot.s0 { background: var(--s0); }
.s1 .dot, .dot.s1 { background: var(--s1); }
.s2 .dot, .dot.s2 { background: var(--s2); }
.s3 .dot, .dot.s3 { background: var(--s3); }
.s4 .dot, .dot.s4 { background: var(--s4); }
.s5 .dot, .dot.s5 { background: var(--s5); }
.new-tag { background: #E5322D; color: #fff; font-size: 10px; font-weight: 800; padding: 2px 5px; border-radius: 4px; }

/* ---------- 지도 위 핀 ---------- */
.pin {
  display: flex; align-items: center; gap: 4px; white-space: nowrap;
  font: 600 12px/1 "Pretendard Variable", "Pretendard", sans-serif; color: #18324F;
}
.pin .dot { width: 18px; height: 18px; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.pin .lbl { background: #fff; padding: 3px 6px; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.far .pin .lbl { display: none; }   /* 지도를 멀리 보면 이름 숨김 */
.pin.s3 .dot, .pin.s5 .dot { width: 14px; height: 14px; border-width: 2px; }
.pin.s5 { opacity: .6; }
.pin.warn .dot { background: var(--s2); }  /* 배송 앱: 배송 정보가 아직 없는 곳 */

/* ---------- 지역 / 새로 오픈 ---------- */
.filters { display: flex; gap: 6px; margin-top: 8px; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); opacity: 1; }
.panel {
  margin-top: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; box-shadow: 0 4px 16px rgba(24,50,79,.18); max-height: 60vh; overflow-y: auto;
}
.panel label.chk {
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 9px 0;
  font-size: 16px; font-weight: 500; color: var(--ink); border-bottom: 1px solid var(--line);
}
.panel label.chk:last-of-type { border-bottom: 0; }
.panel input[type=checkbox] { width: 20px; height: 20px; accent-color: #18324F; }
.panel .cnt { margin-left: auto; color: var(--sub); font-size: 14px; }
.sync { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--sub); }
.sync button { margin-top: 8px; width: 100%; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--soft); font-weight: 600; }
.hint-bar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 9;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  background: rgba(24,50,79,.88); color: #fff; font-size: 13px; padding: 7px 12px; border-radius: 16px; display: none;
}
.hint-bar.show { display: block; }

/* ---------- 오른쪽 아래 버튼 ---------- */
.fabs {
  position: fixed; right: 14px; z-index: 10;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}
.fab-loc {
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg); font-size: 20px; box-shadow: 0 2px 10px rgba(24,50,79,.2);
}
.fab-add {
  height: 56px; padding: 0 22px; border-radius: 28px; border: 0;
  background: var(--crate); color: var(--crate-ink); font-weight: 700; font-size: 17px;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

/* ---------- 아래에서 올라오는 상세 카드 ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-height: 78vh; overflow-y: auto; background: var(--bg);
  border-radius: 18px 18px 0 0; box-shadow: 0 -4px 20px rgba(0,0,0,.2);
  padding: 8px 18px calc(env(safe-area-inset-bottom, 0px) + 18px);
  transform: translateY(calc(100% + 40px)); transition: transform .22s ease-out;
}
.sheet.open { transform: none; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet h2 { margin: 0; font-size: 22px; }
.meta { color: var(--sub); margin: 4px 0 0; font-size: 15px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.block { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.block h3 { margin: 0 0 6px; font-size: 15px; color: var(--sub); font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.block p { margin: 0; font-size: 17px; line-height: 1.5; white-space: pre-wrap; }
.block .empty { color: var(--sub); font-size: 15px; }
.photo { display: block; width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; margin-top: 8px; border: 0; padding: 0; background: none; }
.photo img { width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; display: block; }
.caution p { color: var(--danger); font-weight: 600; }
.row { display: flex; gap: 8px; margin-top: 18px; }
.btn {
  flex: 1; height: 50px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--soft); font-weight: 600; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--crate); color: var(--crate-ink); border-color: var(--crate); }
.btn.dark { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.danger { color: var(--danger); }
.btn.small { flex: none; height: 34px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.owner { font-size: 13px; color: var(--sub); margin-top: 10px; }
.lock { font-size: 14px; color: var(--sub); background: var(--soft); border-radius: 10px; padding: 10px 12px; margin-top: 12px; }

/* ---------- 영업 내역 ---------- */
.visits { list-style: none; margin: 8px 0 0; padding: 0; }
.visits li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.visits li:last-child { border-bottom: 0; }
.visits .vh { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.visits .vh b { font-size: 16px; }
.visits .vh .who { color: var(--sub); font-size: 14px; }
.visits .vh .act { margin-left: auto; display: flex; gap: 4px; }
.visits .vh .act button { border: 1px solid var(--line); background: var(--soft); border-radius: 8px; height: 30px; padding: 0 10px; font-size: 13px; }
.visits .memo { margin: 4px 0 0; font-size: 15px; line-height: 1.5; white-space: pre-wrap; }
.result-tag { display: inline-block; font-size: 13px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--soft); border: 1px solid var(--line); }
.result-tag.r-계약 { background: #E3F5EA; color: #146B3A; border-color: #BFE6CD; }
.result-tag.r-거절 { background: #FBE9E4; color: #8C3418; border-color: #F2CBBE; }
.recent { font-size: 14px; margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: #FFF6D6; color: #5C4A00; }
@media (prefers-color-scheme: dark) { .recent { background: #3A3214; color: #F5E6A8; } }

/* ---------- 입력 화면 (전체 화면) ---------- */
.form {
  position: fixed; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 18px calc(env(safe-area-inset-bottom, 0px) + 24px);
  display: none;
}
.form.open { display: block; }
.form header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.form header h2 { margin: 0; font-size: 20px; }
.x { border: 0; background: none; font-size: 26px; width: 44px; height: 44px; }
label { display: block; margin-top: 14px; font-size: 14px; font-weight: 600; color: var(--sub); }
input[type=text], input[type=tel], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--soft); font-size: 16px;
}
textarea { min-height: 70px; resize: vertical; }
fieldset { border: 0; padding: 0; margin: 22px 0 0; }
legend { font-weight: 700; font-size: 17px; padding: 0; }
.hint { font-size: 13px; color: var(--sub); margin: 4px 0 0; }
.pickstate { margin-top: 8px; font-size: 14px; }
.preview { max-width: 100%; max-height: 180px; border-radius: 10px; margin-top: 8px; display: none; }
input[type=file] { margin-top: 8px; font-size: 15px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: inline-flex; align-items: center; height: 40px; padding: 0 14px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--soft); color: var(--ink); font-size: 15px; font-weight: 600;
}
.seg input:checked + span { background: var(--brand); color: #fff; border-color: var(--brand); }
.seg input:focus-visible + span { outline: 3px solid var(--crate); outline-offset: 2px; }

/* ---------- 네이버 상호 검색 (입력 화면) ---------- */
.lsearch { display: flex; gap: 8px; margin-top: 6px; }
.lsearch input { flex: 1; margin-top: 0 !important; }
.lsearch button { flex: none; width: 76px; border-radius: 10px; border: 0; background: var(--brand); color: #fff; font-weight: 700; }
.lresults button {
  display: block; width: 100%; text-align: left; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.lresults b { font-size: 16px; }
.lresults small { display: block; color: var(--sub); font-size: 13px; margin-top: 2px; }
.import { margin-top: 8px; }
.import input { font-size: 13px; margin-top: 6px; width: 100%; }

/* ---------- 지도에서 위치 찍기 안내 ---------- */
.pickbar {
  position: fixed; left: 12px; right: 12px; z-index: 25; display: none;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  background: var(--crate); color: var(--crate-ink); border-radius: 12px;
  padding: 12px 14px; font-weight: 700; align-items: center; justify-content: space-between; gap: 10px;
}
.pickbar.open { display: flex; }
.pickbar button { border: 0; background: rgba(0,0,0,.12); border-radius: 8px; height: 36px; padding: 0 12px; font-weight: 700; }

/* ---------- 사진 크게 보기 / 알림 ---------- */
.viewer { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.92); display: none; align-items: center; justify-content: center; }
.viewer.open { display: flex; }
.viewer img { max-width: 100%; max-height: 100%; }
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 90px); z-index: 50;
  transform: translateX(-50%); background: #18324F; color: #fff; padding: 12px 18px;
  border-radius: 10px; font-size: 15px; max-width: 90vw; display: none;
}
.toast.show { display: block; }
.setup { position: fixed; inset: 0; display: none; place-content: center; padding: 24px; text-align: center; line-height: 1.6; }
.setup.open { display: grid; }

/* ---------- 지도 없는 화면 (로그인, 운영자, 처음 화면) ---------- */
.page {
  max-width: 520px; margin: 0 auto; min-height: 100%;
  padding: calc(env(safe-area-inset-top, 0px) + 28px) 18px calc(env(safe-area-inset-bottom, 0px) + 32px);
}
.page h1 { font-size: 24px; margin: 0 0 4px; }
.page .lead { color: var(--sub); margin: 0 0 20px; }
.card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-top: 12px; background: var(--bg); }
.err { color: var(--danger); font-size: 14px; margin-top: 10px; min-height: 1em; }

@media (prefers-reduced-motion: reduce) { .sheet { transition: none; } }
@media (min-width: 720px) {
  .top { right: auto; width: 440px; }
  .menu { right: 12px; }
  .sheet { left: 12px; right: auto; width: 440px; bottom: 12px; border-radius: 18px; }
}
