/* 행정관리 — 파스텔(세이지 그린) 디자인 시스템
   목표: 깔끔 + 파스텔 + "AI스럽지 않은" 결. 손으로 짠 CSS 토큰으로 완전 제어. */
:root {
  /* 표면 — 따뜻한 종이빛 */
  --bg:            #F5F4EF;
  --surface:       #FFFFFF;
  --surface-2:     #FAF9F4;

  /* 텍스트 — 순검정 대신 소프트 */
  --text:          #2E2D2A;
  --text-sub:      #57554F;
  --muted:         #928F87;

  /* 경계 */
  --border:        #E9E6DE;
  --border-strong: #DAD6CB;

  /* 액센트 — 뮤트 세이지 */
  --primary:       #7BA890;
  --primary-strong:#5F8F76;
  --primary-tint:  #EAF2EC;

  /* 상태 — 파스텔 틴트 배경 + 진한 글자 */
  --ok:    #4E9A6E;  --ok-bg:    #E8F3EA;
  --warn:  #B4842B;  --warn-bg:  #FAF0D7;
  --danger:#C05F55;  --danger-bg:#F8E9E6;
  --info:  #4F80A6;  --info-bg:  #E7EFF5;

  /* 뱃지/섹션 파스텔 계열 */
  --tint-mint:#E8F3EA; --tint-peach:#F7EADF; --tint-sky:#E5EEF4;
  --tint-lavender:#ECE8F3; --tint-butter:#FAF0D7;

  --radius: 13px;
  --shadow: 0 1px 3px rgba(60,55,45,.06);
  --header-h: 54px;
  --nav-h: 60px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
               "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55;
}
.hidden { display: none !important; }
a { color: inherit; }

/* 헤더 */
#app-header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; justify-content: center; z-index: 50;
  padding-top: env(safe-area-inset-top);
}
.header-inner {
  width: 100%; max-width: 760px;
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
}
#header-title { font-size: 16px; font-weight: 600; margin: 0; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-brand { color: var(--primary-strong); font-weight: 700; }
.header-back { background: none; border: none; color: var(--text-sub); font-size: 26px; line-height: 1;
  padding: 0 6px 3px; margin-left: -4px; cursor: pointer; font-family: inherit; }
.header-back:active { color: var(--primary-strong); }
.header-link { color: var(--text-sub); font-size: 13px; text-decoration: none; padding: 4px 6px; }
.header-logout { background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 8px; cursor: pointer; font-family: inherit; line-height: 1; }
.header-logout:active { background: var(--border); }

/* 메인 */
#view {
  padding: 16px;
  padding-top: calc(var(--header-h) + 16px + env(safe-area-inset-top));
  padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
  max-width: 760px; margin: 0 auto; min-height: 100vh;
}
body.auth-mode #app-header, body.auth-mode #bottom-nav { display: none; }
body.auth-mode #view { padding-top: 24px; }

/* 하단 네비 */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h);
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; justify-content: center; z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-inner {
  width: 100%; max-width: 760px; display: flex;
}
#bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; text-decoration: none; color: var(--muted); font-size: 11px;
}
#bottom-nav a .ico { font-size: 21px; line-height: 1; }
#bottom-nav a.active { color: var(--primary-strong); font-weight: 600; }

/* 카드 */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card.compact { padding: 12px; }        /* 검색/필터/조밀 카드 */
.card h2 { margin: 0 0 12px; font-size: 16px; }
/* 메뉴 섹션 소제목(관리 화면 등) */
.menu-sec { font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .02em;
  padding: 16px 2px 4px; }
.menu-sec:first-child { padding-top: 2px; }

/* 리스트 */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.list-item:last-child { border-bottom: none; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; }
.list-item .li-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.list-item .li-right { display: flex; align-items: center; justify-content: flex-end;
  gap: 6px; white-space: nowrap; }

/* 성도 사진 — 좌: 사진 / 우: 버튼 3줄 */
.photo-card { display: flex; align-items: center; gap: 16px; text-align: left; }
.photo-frame { width: 96px; height: 120px; flex: none; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center; }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }
.photo-empty { font-size: 14px; font-weight: 600; color: var(--muted); }
.photo-actions { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.photo-actions .btn { width: 100%; margin: 0; }
/* 목록 아바타 */
.avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex: none;
  background: var(--surface-2); }
.avatar-empty { display: flex; align-items: center; justify-content: center;
  color: var(--muted); border: 1px solid var(--border); overflow: hidden; }
.avatar-empty svg { width: 78%; height: 78%; opacity: .55; display: block; }

/* 뱃지 — 파스텔 틴트 */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.primary { background: var(--primary-tint); color: var(--primary-strong); }
.badge.ok      { background: var(--ok-bg);   color: var(--ok); }
.badge.warn    { background: var(--warn-bg); color: var(--warn); }
.badge.danger  { background: var(--danger-bg); color: var(--danger); }
.badge.info    { background: var(--info-bg); color: var(--info); }
.badge.tag     { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-sub); }
.badge.mint{background:var(--tint-mint);color:#3f7d59}
.badge.peach{background:var(--tint-peach);color:#a86a45}
.badge.sky{background:var(--tint-sky);color:#456f92}
.badge.lavender{background:var(--tint-lavender);color:#6a5f95}
.badge.butter{background:var(--tint-butter);color:#8a7220}

/* 통계 */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center; box-shadow: var(--shadow); }
.stat .num { font-size: 26px; font-weight: 700; color: var(--primary-strong); }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* 폼 */
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 5px; color: var(--text-sub); }
input, select, textarea {
  width: 100%; padding: 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  font-size: 16px; background: var(--surface); font-family: inherit; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint); }
input.input-invalid { border-color: var(--danger); background: #fff8f7; }
/* select 처럼 보이는 선택 트리거(레이어 목록 열기) */
.picker-trigger { width: 100%; padding: 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  font-size: 16px; background: var(--surface); font-family: inherit; color: var(--text); cursor: pointer;
  display: flex; align-items: center; gap: 8px; text-align: left; }
.picker-trigger::after { content: ">"; margin-left: auto; color: var(--muted); font-size: 15px;
  font-weight: 700; display: inline-block; transform: rotate(90deg); line-height: 1; }
.picker-trigger.placeholder { color: var(--muted); }
.field-desc { font-size: 12px; color: var(--muted); margin: 4px 0 2px; }
/* 휴대폰 010 접두어 */
.phone-field { display: flex; }
.phone-field input { flex: 1; min-width: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.phone-prefix { display: flex; align-items: center; padding: 0 12px; font-size: 16px;
  color: var(--text-sub); background: var(--surface-2); border: 1px solid var(--border-strong);
  border-right: none; border-radius: 10px 0 0 10px; }

/* 비밀번호 눈표시 토글 */
.pw-field { position: relative; }
.pw-field input { padding-right: 46px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border: none; background: none; cursor: pointer;
  font-size: 17px; line-height: 1; opacity: .5; padding: 0; }
.pw-toggle.on { opacity: 1; }

/* 버튼 */
.btn { display: block; width: 100%; padding: 14px; border: none; border-radius: 12px;
  background: var(--primary); color: #fff; font-size: 16px; font-weight: 600;
  cursor: pointer; margin-top: 18px; text-align: center; text-decoration: none; }
.btn:active { background: var(--primary-strong); }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }
.btn.danger { background: var(--danger); }
.btn.sm { width: auto; display: inline-block; padding: 8px 14px; font-size: 14px; margin: 0; }
/* 교적 상단 액션 버튼 — 조금 더 작게 */
.gj-actions .btn { padding: 6px 11px; font-size: 12px; }
/* 짧은 폼 항목 2개를 한 줄에 */
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-2col > div { min-width: 0; }
/* 가로 버튼 그룹 — 8px 간격, 위 12px */
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .btn { margin-top: 0; }
.btn-row:first-child { margin-top: 0; }   /* 화면 최상단 툴바는 카드처럼 붙임 */
/* 세로 버튼 스택 — 전체폭 버튼을 10px 간격으로 쌓음 */
.btn-stack { margin-top: 18px; }
.btn-stack .btn { margin-top: 0; }
.btn-stack .btn + .btn { margin-top: 10px; }

/* 권한 매트릭스 테이블 */
.perm-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.perm-table th, .perm-table td { border: 1px solid var(--border); padding: 8px 6px; text-align: center; }
.perm-table thead th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.perm-table tbody th { text-align: left; font-weight: 600; white-space: nowrap; }
.perm-table input { width: auto; }

/* 탭 (상세 페이지) */
.tabbar { display: flex; gap: 4px; margin-bottom: 12px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.tabbar .tab { flex: 1; padding: 9px 6px; border: none; background: transparent; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--text-sub); border-radius: 9px; font-family: inherit; }
.tabbar .tab.active { background: var(--surface); color: var(--primary-strong); box-shadow: var(--shadow); }
/* 탭이 많을 때: 내용 크기로 가로 스크롤 */
.tabbar.scroll { overflow-x: auto; }
.tabbar.scroll .tab { flex: 0 0 auto; white-space: nowrap; padding: 9px 14px; }
/* 탭이 많을 때: 여러 줄(2·3단)로 줄바꿈해 전부 노출 */
.tabbar.wrap { flex-wrap: wrap; }
.tabbar.wrap .tab { flex: 0 0 auto; white-space: nowrap; padding: 9px 14px; }
/* 순번 추가(+) 탭: 항상 보이도록 마지막에 유지 + 강조 */
.tabbar .tab.add { color: var(--primary-strong); font-size: 17px; line-height: 1; padding: 9px 13px; }
/* 순번 순서 행: 담당 일자(우측정렬, 공간 확보) */
.rot-duty-date { flex: 0 0 auto; min-width: 90px; text-align: right; margin-left: auto;
  font-size: 12px; color: var(--muted); white-space: nowrap; }

/* 주소 검색 필드 + 모달 */
.addr-row { display: flex; gap: 8px; }
.addr-row input { flex: 1; min-width: 0; }
.addr-row .btn.sm { flex: 0 0 auto; align-self: stretch; margin: 0; }
.addr-modal { position: fixed; inset: 0; z-index: 200; background: rgba(46,45,42,.45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.addr-box { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 440px;
  max-height: calc(100vh - 32px); overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  display: flex; flex-direction: column; }
.addr-head { display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
.addr-close { background: none; border: none; font-size: 18px; color: var(--muted);
  cursor: pointer; padding: 4px 6px; line-height: 1; }
/* 모달 본문 — 균일 패딩 + 첫 요소 상단여백 제거. 내용이 길면 세로 스크롤 */
.modal-body { padding: 16px; overflow-y: auto; }
.modal-body > :first-child { margin-top: 0; }
.addr-embed { height: 470px; }
.addr-embed > div { width: 100% !important; height: 100% !important; }

/* 칩 */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); font-size: 13px; cursor: pointer; color: var(--text-sub); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 자음(초성) 인덱스 바 */
.jamo-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border); }
.jamo { min-width: 30px; text-align: center; padding: 5px 7px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-sub);
  font-size: 14px; line-height: 1; cursor: pointer; user-select: none; }
.jamo.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 명단 카드 그리드 (직분·제직·사역) */
.roster { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.roster-head { text-align: center; border-bottom: 1.5px solid var(--text); padding-bottom: 12px; margin-bottom: 18px; }
.roster-head .title { font-size: 18px; font-weight: 600; }
.roster-head .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.roster-sec { margin-bottom: 18px; }
.roster-sec-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.roster-sec-head .name { font-size: 16px; font-weight: 600; }
.name-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.name-card { border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: var(--surface); }
.name-card.this-week { border: 2px solid var(--primary); }
.name-card .nm { font-size: 15px; font-weight: 600; }
.name-card .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* 인증 화면 */
.auth-wrap { max-width: 380px; margin: 9vh auto 0; padding: 0 8px; }
.auth-logo { text-align: center; font-size: 34px; margin-bottom: 6px; color: var(--primary-strong); }
.auth-wrap h1 { text-align: center; font-size: 22px; margin: 0 0 4px; }
.auth-wrap .sub { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; }
.auth-switch a { color: var(--primary-strong); font-weight: 600; text-decoration: none; }
.form-intro { background: var(--primary-tint); border: 1px solid #d5e6db; color: var(--text-sub);
  font-size: 12.5px; line-height: 1.55; padding: 11px 13px; border-radius: 10px; margin-bottom: 8px; }

/* 기타 */
.muted { color: var(--muted); }
.center { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 44px 0; }
.err-text { color: var(--danger); font-size: 13px; margin-top: 10px; }
.section-title { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em;
  text-transform: uppercase; margin: 22px 0 8px; }

/* 토스트 */
.toast { position: fixed; bottom: calc(var(--nav-h) + 18px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px;
  z-index: 100; max-width: 90%; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.toast.err { background: var(--danger); }
.toast.ok  { background: var(--ok); }

/* 인쇄 (명단·조직도 공통) */
@media print {
  #app-header, #bottom-nav, .toast, .no-print, .addr-modal { display: none !important; }
  body { background: #fff; }
  #view { padding: 0 !important; max-width: none; }
  .roster, .card { border: none; box-shadow: none; }
  .roster-sec, .name-card { break-inside: avoid; page-break-inside: avoid; }
  /* 조직도: 화면 SVG 숨기고 페이지 타일(#oc-print)만 출력. @page 규격은 <style id="oc-page">. */
  #oc-tree { display: none !important; }
  #oc-print { display: block !important; }
  .oc-tile { overflow: hidden; page-break-after: always; break-after: page; }
  .oc-tile:last-child { page-break-after: auto; break-after: auto; }
  .oc-tile svg { display: block; }
}
#oc-print { display: none; }   /* 화면에서는 숨김 */

/* 조직도 컨트롤 툴바 */
.oc-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 9px 12px; margin-bottom: 12px; }
.oc-toolbar .oc-ctl { display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-sub); margin: 0; }
.oc-toolbar select { width: auto; padding: 5px 8px; font-size: 13px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-family: inherit; }
.oc-toolbar .oc-check input { width: auto; margin: 0; }
.oc-toolbar .btn { margin: 0; }

/* 넓은 화면 */
@media (min-width: 800px) {
  .name-grid { grid-template-columns: repeat(4, 1fr); }
}
