/* 원우회 연락처 명부 — 모바일 우선 */
:root {
  --bg: #f4f6f8; --surface: #ffffff; --text: #1d2733; --muted: #5b6876; --line: #d8dee5;
  --primary: #1f5fa8; --primary-text: #ffffff; --primary-soft: #e6f0fb;
  --danger: #b3261e; --danger-soft: #fdecea; --ok: #1b6e3c; --ok-soft: #e7f5ec; --info-soft: #e6f0fb;
  --shadow: 0 1px 3px rgba(20, 30, 45, .08);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171d; --surface: #1c242d; --text: #e8edf2; --muted: #a2afbc; --line: #34404c;
    --primary: #6aa8ee; --primary-text: #0c1722; --primary-soft: #1d3248;
    --danger: #ff8a80; --danger-soft: #3a1f1e; --ok: #7fd49c; --ok-soft: #173325; --info-soft: #1d3248;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.6; color: var(--text); background: var(--bg);
  overflow-wrap: anywhere; word-break: keep-all; min-height: 100vh;
}
body.modal-open { overflow: hidden; }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .5em; }
p { margin: 0 0 .8em; }

.container { width: 100%; max-width: 640px; margin: 0 auto; padding: 16px; }
.container.wide { max-width: 1200px; }
.narrow { max-width: 480px; }
main.container { padding-bottom: 96px; }

/* 상단 */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; padding-bottom: 8px; }
.container.wide.topbar-inner { max-width: 1200px; }
.brand { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.brand-org { font-size: 12px; color: var(--muted); }
.brand-title { font-weight: 700; font-size: 17px; }
.topbar-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* 카드 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-title { font-size: 18px; }
.hero-title { font-size: 24px; }
.lead { font-size: 17px; color: var(--muted); }
.sub-title { font-size: 16px; margin-top: 8px; }
.plain-list { padding-left: 20px; margin: 0 0 12px; }
.plain-list li { margin-bottom: 4px; }
.hint { font-size: 14px; color: var(--muted); display: block; }
.muted { color: var(--muted); }
.center { text-align: center; }
.break { overflow-wrap: anywhere; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; text-align: center; touch-action: manipulation;
}
.btn:hover { border-color: var(--primary); }
.btn:focus-visible, .input:focus-visible, .tab:focus-visible, .table-wrap:focus-visible, summary:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn-block { display: flex; width: 100%; }
.btn-small { min-height: 44px; padding: 6px 12px; font-size: 14px; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger-outline { color: var(--danger); border-color: var(--danger); }
.btn-link { border: none; background: none; color: var(--primary); text-decoration: underline; font-weight: 500; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.is-busy { position: relative; cursor: progress; }
.btn.is-busy::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* 폼 */
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-weight: 600; font-size: 15px; }
.input {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
.err-slot:empty { display: none; }
.check { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 8px 0; cursor: pointer; }
.check input[type=checkbox], .dir-row input[type=checkbox] { width: 24px; height: 24px; flex-shrink: 0; margin: 2px 0 0; accent-color: var(--primary); }
.check-all { font-weight: 700; background: var(--primary-soft); border-radius: 10px; padding: 8px 12px; align-items: center; }
.tag { font-size: 12px; padding: 1px 6px; border-radius: 6px; }
.tag-req { background: var(--danger-soft); color: var(--danger); }
.tag-opt { background: var(--primary-soft); color: var(--primary); }
.info { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; font-weight: 600; }

/* 알림 */
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.alert-info { background: var(--info-soft); color: var(--text); border-color: var(--primary); }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: 90px; max-width: 480px; margin: 0 auto; z-index: 60; padding: 12px 16px; border-radius: 10px;
  background: #1d2733; color: #fff; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--danger); }
.loading { display: flex; align-items: center; gap: 10px; padding: 16px; color: var(--muted); }
.spinner { width: 20px; height: 20px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner, .btn.is-busy::after { animation-duration: 3s; } }
.login-box { display: flex; flex-direction: column; gap: 10px; align-items: center; min-height: 52px; }
.gsi-holder { min-height: 44px; display: flex; justify-content: center; width: 100%; }

/* 탭 */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.tab { flex: 1; min-height: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.tab.active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }

/* 명부 */
.remain { font-weight: 700; color: var(--primary); }
.remain-zero { color: var(--danger); }
.dir-head { display: flex; flex-direction: column; gap: 4px; margin: 12px 0 4px; }
.count { font-size: 14px; color: var(--muted); }
.dir-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.dir-item { border-bottom: 1px solid var(--line); }
.dir-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 4px; cursor: pointer; }
div.dir-row { cursor: default; }
.dir-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.dir-name { font-weight: 700; }
.dir-sub { font-size: 14px; color: var(--muted); }
.dir-phone { font-size: 14px; color: var(--muted); white-space: nowrap; }
.empty { padding: 16px; text-align: center; color: var(--muted); }
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.actionbar .btn { max-width: 608px; margin: 0 auto; }
.howto details { border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; margin-bottom: 8px; }
.howto summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.steps { padding-left: 20px; margin: 0 0 8px; }

/* 동의서 */
.consent-text { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--bg); font-size: 15px; }
.consent-doc { font-size: 15px; }
.consent-lead { font-weight: 600; }
.consent-section { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.consent-section h3 { font-size: 16px; }
.consent-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin-bottom: 8px; font-size: 14px; }
.consent-table th, .consent-table td { border: 1px solid var(--line); padding: 6px 8px; vertical-align: top; text-align: left; overflow-wrap: anywhere; }
.consent-table th { width: 32%; background: var(--primary-soft); font-weight: 600; }
.consent-note { font-size: 14px; background: var(--primary-soft); border-radius: 8px; padding: 8px 10px; }
.consent-refuse { font-size: 14px; color: var(--muted); }
.consent-foot { font-size: 14px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }
.consent-check { margin-top: 8px; padding: 4px 10px; border: 2px solid var(--primary); border-radius: 10px; background: var(--surface); }
@media (max-width: 400px) {
  .consent-table th, .consent-table td { display: block; width: 100%; }
  .consent-table th { border-bottom: 0; }
  .consent-table td { border-top: 0; }
}

/* 확인창 */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(10, 16, 24, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dlg { background: var(--surface); color: var(--text); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; }
.dlg-title { font-size: 19px; }
.dlg-text { margin-bottom: 10px; }
.dlg-actions { display: flex; gap: 8px; margin-top: 16px; }
.dlg-actions .btn { flex: 1; }

/* 푸터 */
.footer { text-align: center; font-size: 14px; padding-top: 0; padding-bottom: 32px; }
.footer p { margin: 0 0 4px; }

/* 테스트 모드 */
.mock-tools { margin-top: 16px; padding: 8px 12px; border: 1px dashed var(--muted); border-radius: 10px; font-size: 14px; }
.mock-tools summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }

/* 관리자 */
.toolbar { display: grid; grid-template-columns: 1fr; gap: 12px; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); max-width: 100%; }
.table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 14px; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.table th { background: var(--primary-soft); position: sticky; top: 0; font-weight: 700; }
.table tr.row-flag td { background: var(--danger-soft); }
.flag-note { flex-basis: 100%; font-size: 13px; color: var(--danger); white-space: normal; max-width: 280px; }
.notice { font-weight: 600; }
.table td.empty { white-space: normal; }
.actions-cell { white-space: normal !important; min-width: 180px; }
@media (min-width: 700px) {
  .toolbar { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
}

/* 결과 시트 */
.overlay-sheet { align-items: flex-end; padding: 0; }
.sheet { border-bottom-left-radius: 0; border-bottom-right-radius: 0; max-width: 640px; max-height: 88vh; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.sheet:focus { outline: none; }
.sheet .btn-block { margin-bottom: 8px; }
