:root {
  --brown: #5b4636;
  --brown-dark: #3f3025;
  --brown-light: #efe7df;
  --cream: #f7f2ec;
  --accent: #c2884a;
  --gray-200: #e7e0d8;
  --gray-400: #a89b8c;
  --gray-500: #7d7163;
  --gray-700: #4a4036;
  --white: #ffffff;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(60,40,20,.08), 0 4px 16px rgba(60,40,20,.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic",
               "맑은 고딕", "Noto Sans KR", sans-serif;
  background: var(--cream);
  color: var(--brown-dark);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--cream);
  display: flex;
  flex-direction: column;
}

/* ---- 헤더 ---- */
.hero {
  background: linear-gradient(160deg, var(--brown) 0%, var(--brown-dark) 100%);
  color: #fff;
  padding: 30px 22px 26px;
  text-align: center;
  border-bottom-left-radius: 22px;
  border-bottom-right-radius: 22px;
}
.hero .logo {
  width: 70px; height: 70px; border-radius: 50%;
  background: #fff; padding: 6px; object-fit: contain;
  box-shadow: 0 4px 14px rgba(0,0,0,.18); margin-bottom: 10px;
}
.hero h1 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -.3px; }
.hero .sub { font-size: 12.5px; opacity: .82; margin-top: 4px; }

/* ---- 본문 ---- */
.content { flex: 1; padding: 22px 18px 10px; }
.lead {
  text-align: center; font-size: 14px; color: var(--gray-700);
  margin: 4px 4px 20px; white-space: pre-line;
}

/* ---- 메뉴 카드 ---- */
.menu-grid { display: flex; flex-direction: column; gap: 13px; }
.menu-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 18px 18px;
  box-shadow: var(--shadow); cursor: pointer;
  text-decoration: none; color: inherit;
  transition: transform .1s ease, box-shadow .12s ease, border-color .12s ease;
}
.menu-card:hover { border-color: var(--accent); box-shadow: 0 2px 6px rgba(60,40,20,.12), 0 8px 24px rgba(60,40,20,.08); }
.menu-card:active { transform: scale(.985); }
.menu-card .ico {
  flex: 0 0 52px; width: 52px; height: 52px; border-radius: 14px;
  background: var(--brown-light); display: grid; place-items: center; font-size: 26px;
}
.menu-card .txt { flex: 1; min-width: 0; }
.menu-card .t { display: block; font-size: 16px; font-weight: 800; }
.menu-card .d { display: block; font-size: 12.5px; color: var(--gray-500); margin-top: 2px; }
.menu-card .arrow { flex: 0 0 auto; color: var(--gray-400); font-size: 20px; font-weight: 700; }
.menu-card .ext { font-size: 10.5px; color: var(--accent); font-weight: 700; }
.menu-card .soon {
  display: inline-block; background: #fff8ec; color: #92580f;
  border: 1px solid #f0dcae; border-radius: 999px;
  padding: 1px 8px; font-size: 10.5px; font-weight: 700; margin-left: 4px;
}

/* ---- 대메뉴(시스템) 그룹 아코디언 ---- */
.mgroup {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.mgroup > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 16px;
  padding: 16px 18px; user-select: none;
}
.mgroup > summary::-webkit-details-marker { display: none; }
.mgroup > summary:hover { background: var(--cream); }
.mgroup .ico {
  flex: 0 0 52px; width: 52px; height: 52px; border-radius: 14px;
  background: var(--brown-light); display: grid; place-items: center; font-size: 26px;
}
.mgroup .gtxt { flex: 1; min-width: 0; }
.mgroup .gt { display: block; font-size: 16px; font-weight: 800; }
.mgroup .gd {
  display: block; font-size: 12px; color: var(--gray-500); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mgroup .chev {
  flex: 0 0 auto; color: var(--gray-400); font-size: 22px; font-weight: 700;
  transition: transform .2s ease;
}
.mgroup[open] .chev { transform: rotate(180deg); }
.mgroup[open] > summary { border-bottom: 1px solid var(--gray-200); background: var(--cream); }
.gpanel { display: flex; flex-direction: column; gap: 7px; padding: 10px 10px 12px 22px; background: #faf6f1; }
.gpanel .menu-card { padding: 9px 11px; gap: 11px; box-shadow: none; border-radius: 11px;
  border-color: #ece4d8; background: #fffdfa; position: relative; }
.gpanel .menu-card::before { content: "└"; position: absolute; left: -14px; color: var(--gray-400); font-size: 13px; top: 50%; transform: translateY(-50%); }
.gpanel .menu-card .ico { flex-basis: 34px; width: 34px; height: 34px; font-size: 17px; border-radius: 10px; }
.gpanel .menu-card .t { font-size: 13.5px; font-weight: 700; }
.gpanel .menu-card .d { font-size: 11px; margin-top: 1px; }
.gpanel .menu-card .arrow { font-size: 16px; }

/* ---- 푸터 ---- */
.foot {
  text-align: center; font-size: 11.5px; color: var(--gray-400);
  padding: 22px 18px 30px; line-height: 1.7;
}
.foot .badge {
  display: inline-block; background: #fff8ec; color: #92580f;
  border: 1px solid #f0dcae; border-radius: 999px;
  padding: 3px 12px; font-size: 11px; font-weight: 700; margin-bottom: 10px;
}

/* ---- 내부 페이지 공통 ---- */
.page-top {
  position: sticky; top: 0; z-index: 10;
  background: var(--brown); color: #fff;
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px;
  padding: 13px 16px;
}
.page-top .back {
  color: #fff; text-decoration: none; font-size: 24px; font-weight: 700;
  line-height: 1; padding: 2px 8px; flex-shrink: 0;
}
.page-top h2 { margin: 0; font-size: 17px; font-weight: 800;
  flex: 1 1 55%; min-width: 0; word-break: keep-all; line-height: 1.25; }

/* ---- 준비중(빈 상태) ---- */
.empty {
  text-align: center; background: #fff;
  border: 1px solid var(--gray-200); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 46px 24px; margin-top: 8px;
}
.empty-ico {
  width: 78px; height: 78px; border-radius: 20px; margin: 0 auto 16px;
  background: var(--brown-light); display: grid; place-items: center; font-size: 38px;
}
.empty h3 { margin: 0 0 8px; font-size: 18px; font-weight: 800; }
.empty p { margin: 0 0 22px; font-size: 13.5px; color: var(--gray-500); }
.btn {
  display: inline-block; background: var(--brown); color: #fff;
  text-decoration: none; font-weight: 700; font-size: 14px;
  padding: 11px 20px; border-radius: 12px;
}
.btn:active { transform: scale(.98); }
.btn-block { display: block; width: 100%; text-align: center; padding: 14px; font-size: 15px; border: 0; cursor: pointer; margin-top: 8px; }

/* ---- 폼 ---- */
.form-intro { font-size: 13.5px; color: var(--gray-700); margin: 4px 2px 18px; }
.form-intro .muted { color: var(--gray-500); font-size: 12.5px; }
.card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 18px;
}
.form .field { display: block; margin-bottom: 15px; }
.form .lbl { display: block; font-size: 13px; font-weight: 700; color: var(--gray-700); margin-bottom: 6px; }
.form .lbl em { color: #c0392b; font-style: normal; }
.form input {
  width: 100%; box-sizing: border-box;
  border: 1px solid var(--gray-200); border-radius: 11px;
  padding: 12px 13px; font-size: 15px; background: var(--cream);
  color: var(--brown-dark); font-family: inherit;
}
.form input:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(194,136,74,.15); }
.form input::placeholder { color: var(--gray-400); }
/* 체크박스는 위 input 박스 스타일에서 제외하고 기본(네이티브) 모양으로 — 안 보이던 문제 해결 */
.form input[type="checkbox"] {
  width: 18px; height: 18px; flex: 0 0 18px; padding: 0; margin: 0;
  background: none; border: 0; border-radius: 0; box-shadow: none;
  appearance: auto; -webkit-appearance: auto; accent-color: var(--accent);
}
.form input[type="checkbox"]:focus { box-shadow: none; }

.alert {
  background: #fdecea; border: 1px solid #f5c6c0; color: #a23b30;
  border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-size: 13px;
}
.alert strong { display: block; margin-bottom: 4px; }
.alert ul { margin: 0; padding-left: 18px; }
.alert li { margin: 2px 0; }

/* select / hint */
.form select {
  width: 100%; box-sizing: border-box;
  border: 1px solid var(--gray-200); border-radius: 11px;
  padding: 12px 13px; font-size: 15px; background: var(--cream);
  color: var(--brown-dark); font-family: inherit;
}
.form select:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(194,136,74,.15); }
.form input[readonly] { background: var(--brown-light); color: var(--gray-700); font-weight: 700; }
.form input[type="file"] { padding: 10px 12px; background: #fff; }
.hint { display: block; font-size: 11.5px; color: var(--gray-500); margin-top: 6px; }

/* 분류 선택 (세그먼트) */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg-opt { position: relative; cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt > span {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 1.5px solid var(--gray-200); border-radius: 13px;
  padding: 14px 8px; text-align: center; font-weight: 700; font-size: 14px;
  background: var(--cream); transition: border-color .12s, background .12s;
}
.seg-opt > span small { font-weight: 500; font-size: 10.5px; color: var(--gray-500); }
.seg-opt input:checked + span { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(194,136,74,.12); }

/* 어디서나 홈으로 (플로팅 버튼) */
.home-fab {
  position: fixed; right: 16px; bottom: 16px; z-index: 50;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--brown); color: #fff; text-decoration: none;
  display: grid; place-items: center; font-size: 24px;
  box-shadow: 0 4px 14px rgba(60,40,20,.28);
}
.home-fab:active { transform: scale(.94); }
/* 상단 헤더 홈 버튼 */
.page-top .top-home {
  margin-left: auto; color: #fff; text-decoration: none;
  font-size: 22px; line-height: 1; padding: 2px 6px; flex-shrink: 0;
}
/* 접근 등급 배지 — 페이지 우측 상단 */
.page-top .access-badge {
  margin-left: 8px; font-size: 10.5px; font-weight: 700; white-space: nowrap; flex-shrink: 0;
  color: #fff; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.4);
  padding: 3px 9px; border-radius: 999px;
}
.page-top .top-home + .access-badge { margin-left: 8px; }
/* 모바일: 긴 권한배지가 제목을 누르지 않도록 둘째 줄 오른쪽으로 내림 */
@media (max-width: 520px) {
  .page-top .access-badge,
  .page-top .top-home + .access-badge {
    flex-basis: 100%; margin-left: 0; text-align: right;
    background: none; border: none; padding: 2px 0 0; opacity: .9;
  }
}
.access-badge.fixed {
  position: fixed; top: 8px; right: 8px; z-index: 60; white-space: nowrap;
  font-size: 10.5px; font-weight: 700; color: #fff; background: rgba(22,35,63,.92);
  padding: 4px 10px; border-radius: 999px; box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.page-top .top-home:active { transform: scale(.92); }

/* 인사카드 프로필 사진 */
.hr-photo {
  display: block; width: 120px; height: 120px; margin: 8px auto 0;
  border-radius: 50%; object-fit: cover; border: 3px solid var(--brown-light);
  background: var(--cream);
}
.hr-photo-empty { display: grid; place-items: center; color: var(--gray-400); font-size: 12px; }
.hr-avatar {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%;
  object-fit: cover; border: 1px solid var(--gray-200);
}

/* 파일 업로드 드래그앤드롭 자동 영역 (dragdrop.js) */
.dz-auto { border: 2px dashed var(--gray-200); border-radius: 12px; padding: 18px 14px;
  text-align: center; background: var(--cream); cursor: pointer; transition: .15s; }
.dz-auto.over { border-color: var(--accent); background: #f3ece1; }
.dz-auto.has { border-color: #9cc7a8; }
.dz-auto .dz-ic { font-size: 26px; line-height: 1; margin-bottom: 4px; }
.dz-auto .dz-t { font-weight: 700; color: #5b4636; font-size: 13.5px; }
.dz-auto .dz-f { font-size: 12px; color: #2f6d2f; font-weight: 700; margin-top: 5px; }

/* 보호개체 리스트 대표사진 썸네일 (업로드한 사진을 축소 표시) */
.animal-thumb {
  flex: 0 0 52px; width: 52px; height: 52px; border-radius: 12px;
  object-fit: cover; border: 1px solid var(--gray-200);
}

/* 보호개체 사진 그리드 */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-cell { position: relative; aspect-ratio: 1/1; overflow: hidden; border-radius: 10px; }
/* 어떤 원본 크기든 셀(정사각)에 맞춰 축소 — 컨테이너를 절대 넘지 않음 */
.photo-cell img, .photo-cell video {
  display: block; width: 100%; height: 100%; max-width: 100%;
  aspect-ratio: 1/1; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--gray-200);
}
.photo-cell .rep-badge {
  position: absolute; left: 4px; top: 4px; background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px;
}
.photo-cell .photo-del {
  position: absolute; right: 3px; top: 3px; width: 22px; height: 22px; border: 0;
  border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 15px;
  line-height: 1; cursor: pointer;
}
.photo-cell form { margin: 0; }
.substack { border-top: 1px dashed var(--gray-200); padding-top: 12px; margin-bottom: 6px; }

/* 2열 그리드 / 근무형태 요일 */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .field { margin-bottom: 0; }
.days { display: flex; flex-direction: column; gap: 6px; }
.day { display: flex; align-items: center; gap: 10px; }
.day-lbl { flex: 0 0 22px; text-align: center; font-weight: 800; font-size: 13px; color: var(--brown-dark); }
.day input { flex: 1; }

/* 보조 버튼 */
.btn-ghost {
  display: inline-block; margin-left: 10px; color: var(--gray-700);
  text-decoration: none; font-weight: 700; font-size: 14px; padding: 11px 16px;
  background: none; border: 1px solid var(--gray-200); border-radius: 11px; cursor: pointer;
}
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* 로그인 바 (헤더 우상단) */
.userbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
  gap: 4px 10px; font-size: 12px; margin-bottom: 6px; min-height: 16px; word-break: keep-all; }
.userbar .hi { opacity: .9; white-space: nowrap; }
.userbar a { color: #fff; text-decoration: none; font-weight: 700; opacity: .92; white-space: nowrap; }
.userbar a:hover { text-decoration: underline; }

/* 플래시 메시지 */
.flash {
  background: #eef6ec; color: #2f6d2f; border: 1px solid #cfe6cd;
  border-radius: 10px; padding: 10px 14px; margin: 12px 14px 0; font-size: 13px; font-weight: 700;
}

/* 섹션 제목 */
.sec-title { font-size: 15px; font-weight: 800; margin: 8px 2px 12px; color: var(--brown-dark); }

/* 직원 카드 (관리자 승인) */
.emp { display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 11px; }
.emp-info { flex: 1; min-width: 0; }
.emp-name { font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.emp-id { font-size: 12px; color: var(--gray-500); font-weight: 600; }
.emp-meta { font-size: 12px; color: var(--gray-500); margin-top: 3px; line-height: 1.5; }
.emp-actions { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.emp-actions form { margin: 0; }
.st-active { background: #eef6ec; color: #2f6d2f; border-color: #cfe6cd; }
.st-off { background: #fdecea; color: #a23b30; border-color: #f5c6c0; }
