/* =====================================================================
   5range Tree — 경량 프론트엔드 (Bootstrap/jQuery/FontAwesome/Chart.js 미사용)
   'Relationship Management Web App'(Figma/shadcn) 디자인을 순수 CSS로 구현.
   ===================================================================== */

:root {
  --bg:          #faf7f2;
  --fg:          #1a1208;
  --card:        #ffffff;
  --primary:     #c2540a;
  --accent:      #e8762a;
  --secondary:   #f0ebe0;
  --muted:       #ede8dc;
  --muted-fg:    #7a6e5f;
  --border:      rgba(26, 18, 8, 0.10);
  --border-2:    rgba(26, 18, 8, 0.06);
  --input-bg:    #f0ebe0;
  --sidebar:     #1a1208;
  --sidebar-acc: #2e2010;
  --sidebar-fg:  #faf7f2;
  --sidebar-dim: #8a7d6c;
  --sidebar-bd:  rgba(255, 255, 255, 0.08);
  --amber:   #b45309;  --amber-bg:   #fdf3e7;  --amber-bd:   #f4d9b8;
  --sky:     #0369a1;  --sky-bg:     #e8f3fb;  --sky-bd:     #c2e0f2;
  --violet:  #6d28d9;  --violet-bg:  #f1ecfb;  --violet-bd:  #ddd0f5;
  --emerald: #047857;  --emerald-bg: #e6f4ee;  --emerald-bd: #c2e6d6;
  --rose:    #be123c;
  --radius:  0.75rem;
  --radius-sm: 0.5rem;
  --shadow: 0 1px 2px rgba(26, 18, 8, 0.04);
  --shadow-lg: 0 8px 30px rgba(26, 18, 8, 0.12);
}

* { box-sizing: border-box; }

/* 버튼/링크 기본 리셋 — 모바일(iOS) 기본 버튼 박스·탭 하이라이트 제거 */
button {
  -webkit-appearance: none;
  appearance: none;
  background: none;
  border: none;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}
button, a, .meet-col, [data-modal] {
  -webkit-tap-highlight-color: transparent;
}
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

html { font-size: 15px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; }

.serif { font-family: 'Fraunces', 'Noto Sans KR', serif; letter-spacing: -0.01em; }
.mono  { font-family: 'DM Mono', 'Noto Sans KR', monospace; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--accent); }

.muted { color: var(--muted-fg); }
.text-primary { color: var(--primary); }
.hide { display: none !important; }
.spacer { flex: 1; }

/* ── 레이아웃 ───────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 13rem; flex-shrink: 0;
  background: var(--sidebar); color: var(--sidebar-fg);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 50;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 1.15rem 1rem; border-bottom: 1px solid var(--sidebar-bd);
  color: var(--sidebar-fg);
}
.sidebar-brand .logo { font-size: 1.5rem; line-height: 1; }
.sidebar-brand .name { font-size: 1.05rem; font-weight: 600; }
.sidebar-nav { flex: 1; padding: 0.6rem; display: flex; flex-direction: column; gap: 2px; }
.sidebar-section { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: rgba(250,247,242,0.32); padding: 0.9rem 0.75rem 0.35rem; }
.nav-link {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0.75rem; border-radius: var(--radius);
  color: var(--sidebar-dim); font-size: 0.9rem; font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-link:hover { background: var(--sidebar-acc); color: var(--sidebar-fg); }
.nav-link.active { background: var(--sidebar-acc); color: var(--sidebar-fg); }
.nav-link.active svg { color: var(--accent); }
.sidebar-foot { padding: 0.9rem 1rem; border-top: 1px solid var(--sidebar-bd);
  font-size: 0.75rem; color: rgba(250,247,242,0.4); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0 1.25rem; height: 3.6rem;
  background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 1.15rem; }
.topbar .hamburger { display: none; }

.page { padding: 1.5rem; }
.page-narrow { max-width: 860px; margin: 0 auto; }

/* ── 버튼 ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border-radius: var(--radius);
  border: 1px solid transparent; background: var(--secondary); color: var(--fg);
  font-family: inherit; font-size: 0.875rem; font-weight: 500; cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  text-decoration: none;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: var(--muted); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted-fg); }
.btn-ghost:hover { background: var(--muted); color: var(--fg); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--fg); }
.btn-outline:hover { background: var(--secondary); }
.btn-danger { background: transparent; border-color: var(--amber-bd); color: var(--rose); }
.btn-danger:hover { background: #fbeae8; }
.btn-success { background: var(--emerald); color: #fff; }
.btn-success:hover { background: #03684c; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; border-radius: var(--radius-sm); }
.btn-icon { display: inline-flex; align-items: center; justify-content: center;
  width: 2.1rem; height: 2.1rem; padding: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted-fg); transition: background 0.12s, color 0.12s; }
.btn-icon:hover { background: var(--muted); color: var(--fg); }
.btn-icon svg { width: 19px; height: 19px; display: block; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── 카드 ──────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 1.25rem; }
.card-title {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.9rem; font-weight: 600; margin-bottom: 1rem; color: var(--fg);
}
.card-title svg { width: 15px; height: 15px; color: var(--primary); }

/* ── 그리드 ────────────────────────────────────────────────── */
.grid { display: grid; gap: 0.85rem; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.stack { display: flex; flex-direction: column; gap: 1.1rem; }
.row { display: flex; align-items: center; gap: 0.6rem; }
.wrap { flex-wrap: wrap; }

/* ── KPI ───────────────────────────────────────────────────── */
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.15rem; display: flex; flex-direction: column; gap: 0.5rem; }
/* 대시보드 KPI: 항상 3칸 (모바일에서도 한 줄) */
.kpi-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 820px) {
  .kpi-grid { gap: 0.5rem; }
  .kpi-grid .kpi { padding: 0.7rem 0.55rem; gap: 0.3rem; }
  .kpi-grid .kpi-head { font-size: 0.66rem; gap: 0.25rem; line-height: 1.25; }
  .kpi-grid .kpi-head svg { width: 13px; height: 13px; }
  .kpi-grid .kpi-val { font-size: 1.4rem; }
  .kpi-grid .kpi-more { display: none; }   /* 모바일: 폭 좁아 배지 숨김(카드 전체 탭 가능) */
}
.kpi-head { display: flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; color: var(--muted-fg); word-break: keep-all; }
.kpi-head svg { width: 15px; height: 15px; }
.kpi-val { font-family: 'Fraunces', serif; font-size: 1.9rem; font-weight: 600; line-height: 1; }
.kpi { position: relative; }
.kpi.clickable { cursor: pointer; transition: border-color 0.12s, box-shadow 0.12s; }
.kpi.clickable:hover { border-color: rgba(194,84,10,0.45); box-shadow: var(--shadow); }
.kpi.clickable:hover .kpi-more { background: var(--primary); color: #fff; }
.kpi-more { position: absolute; top: 0.7rem; right: 0.7rem; width: 1.4rem; height: 1.4rem;
  border-radius: 999px; background: rgba(194,84,10,0.12); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center; transition: background 0.12s, color 0.12s; }
.kpi-more svg { width: 13px; height: 13px; }
.c-rose { color: var(--rose); } .c-sky { color: var(--sky); }
.c-emerald { color: var(--emerald); } .c-amber { color: var(--amber); }
.c-primary { color: var(--primary); }

/* ── 뱃지 (단계/상태) ──────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-family: 'DM Mono', monospace; font-size: 0.72rem; font-weight: 500;
  padding: 0.2rem 0.55rem; border-radius: 999px; border: 1px solid transparent;
  white-space: nowrap;
}
.badge.stage-D { color: var(--amber); background: var(--amber-bg); border-color: var(--amber-bd); }
.badge.stage-C { color: var(--sky); background: var(--sky-bg); border-color: var(--sky-bd); }
.badge.stage-B { color: var(--violet); background: var(--violet-bg); border-color: var(--violet-bd); }
.badge.stage-A { color: var(--emerald); background: var(--emerald-bg); border-color: var(--emerald-bd); }
/* S(최상단): 다른 단계 뱃지와 동일 형태, 색만 은은한 회색(활성 등급색보다 한 발 물러난 톤) */
.badge.stage-S { color: var(--muted-fg); background: var(--secondary); border-color: var(--border); }
.badge.ok { color: var(--emerald); background: var(--emerald-bg); border-color: var(--emerald-bd); }
.badge.off { color: var(--rose); background: #fbeae8; border-color: #f3cfca; }
.badge.soft { color: var(--muted-fg); background: var(--secondary); border-color: var(--border); }
.badge.tag { font-family: inherit; color: var(--fg); background: var(--secondary); border-color: var(--border); }

.dot { width: 8px; height: 8px; border-radius: 999px; flex-shrink: 0; display: inline-block; }
.dot.on { background: #34d399; } .dot.gone { background: #fca5a5; }

/* ── 폼 ────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0; }
.field label { font-size: 0.78rem; font-weight: 500; color: var(--muted-fg); }
.input, select.input, textarea.input {
  width: 100%; padding: 0.5rem 0.7rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--input-bg); color: var(--fg);
  font-family: inherit; font-size: 0.875rem; outline: none; transition: border-color 0.12s, box-shadow 0.12s;
}
textarea.input { resize: vertical; }
.input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(194,84,10,0.15); }
select.input { cursor: pointer; }
.search-input { width: auto; max-width: 9rem; padding: 0.35rem 0.6rem; font-size: 0.82rem; }
.form-grid { display: grid; gap: 0.85rem; }
.fg-3 { grid-template-columns: repeat(3, 1fr); }
.fg-2 { grid-template-columns: repeat(2, 1fr); }
.field-err { color: var(--rose); font-size: 0.75rem; }
.section-title { font-family: 'Fraunces', serif; font-size: 0.95rem; font-weight: 600; color: var(--primary);
  margin: 0.4rem 0 0.2rem; }
.divider { height: 1px; background: var(--border); border: 0; margin: 1.2rem 0; }

/* ── 표 ────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.5rem 0.6rem; text-align: center; vertical-align: middle; }
.table thead th { font-size: 0.75rem; color: var(--muted-fg); font-weight: 500;
  border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tbody tr { border-bottom: 1px solid var(--border-2); }
.table tbody tr:last-child { border-bottom: 0; }
.table-rows tbody tr { cursor: pointer; transition: background 0.1s; }
.table-rows tbody tr:hover { background: rgba(232,118,42,0.05); }
.table .sort-link { color: var(--fg); display: inline-flex; align-items: center; gap: 0.2rem; }
.table .sort-link .caret { color: #d9cfbe; font-size: 0.7rem; }
.table .sort-link.active .caret { color: var(--primary); }
.table .left { text-align: left; }
.row-gone td:not(.keep) { color: var(--muted-fg); opacity: 0.6; text-decoration: line-through; text-decoration-thickness: 1px; }
.row-gone .badge { filter: grayscale(0.6); opacity: 0.65; }
/* S(최상단): 멀어짐과 달리 취소선 없이 톤만 낮춤 — 뱃지(★)는 그대로 읽히게 둔다 */
.row-grad td:not(.keep) { color: var(--muted-fg); opacity: 0.7; }

/* 인연 리스트 카드: 와이드 화면에서 표가 과하게 퍼지지 않도록 폭 제한 + 가운데 정렬 */
.list-card { max-width: 1100px; margin-left: auto; margin-right: auto; }

/* 인연 리스트 툴바 (order로 재배치)
   데스크톱 = [필터][총N명][검색] … [새인연](오른쪽 끝) 한 줄
   모바일   = [필터][총N명][새인연] 한 줄 + [검색바 풀폭] 아랫줄 */
.list-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.6rem; margin-bottom: 1rem; }
.list-filters { order: 1; gap: 0.4rem; flex-wrap: wrap; }
.list-count { order: 2; white-space: nowrap; margin-left: 0.1rem; }
.search-form { order: 3; gap: 0.3rem; margin-left: 0.5rem; }   /* 데스크톱: 총N명 옆에 살짝만 띄움 */
.new-contact-btn { order: 4; margin-left: auto; white-space: nowrap; flex-shrink: 0; }
@media (max-width: 820px) {
  .new-contact-btn { order: 3; }                        /* margin-left:auto 유지 → 첫 줄 오른쪽 끝 */
  .search-form { order: 4; flex-basis: 100%; margin-left: 0; }   /* 검색바만 아래 줄 풀폭 */
  .search-form .search-input { flex: 1; max-width: none; }
}

/* 인연 리스트 표: 페이지마다 폭이 흔들리지 않도록 컬럼 폭 고정 */
#contactsTable table { table-layout: fixed; }
#contactsTable th, #contactsTable td { word-break: break-word; overflow: hidden; }
#contactsTable td.mono { white-space: nowrap; }   /* 날짜(MM/dd)가 아래로 밀리지 않게 줄바꿈 금지 */
/* 데스크톱: 진행/첫날/친밀도/계기/이름/단짝/약속/현상황 (합계 100%) — 현상황 넓게 */
#contactsTable th:nth-child(1) { width: 8%; }
#contactsTable th:nth-child(2) { width: 10%; }
#contactsTable th:nth-child(3) { width: 10%; }
#contactsTable th:nth-child(4) { width: 9%; }
#contactsTable th:nth-child(5) { width: 12%; }
#contactsTable th:nth-child(6) { width: 9%; }
#contactsTable th:nth-child(7) { width: 11%; }
#contactsTable th:nth-child(8) { width: 31%; }
/* 모바일: 계기(4)·단짝(6)·현상황(8) 숨김 → 보이는 5칸 폭 재배분 (합계 100%) + 여백 축소로 날짜 공간 확보 */
@media (max-width: 820px) {
  #contactsTable th, #contactsTable td { padding: 0.5rem 0.3rem; }
  #contactsTable th:nth-child(1) { width: 12%; }   /* 진행 */
  #contactsTable th:nth-child(2) { width: 21%; }   /* 첫날 */
  #contactsTable th:nth-child(3) { width: 19%; }   /* 친밀도 */
  #contactsTable th:nth-child(5) { width: 26%; }   /* 이름 */
  #contactsTable th:nth-child(7) { width: 22%; }   /* 만남 */
}

/* 진행 토글 동그라미 */
.toggle-o, .toggle-x, .toggle-s {
  width: 1.6rem; height: 1.6rem; border-radius: 999px; padding: 0;
  font-family: 'DM Mono', monospace; font-size: 0.75rem; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; cursor: pointer;
}
.toggle-o { background: var(--emerald); color: #fff; }
.toggle-o:hover { background: #03684c; }
.toggle-x { background: transparent; color: var(--muted-fg); border-color: var(--border); }
.toggle-x:hover { background: var(--muted); }
/* S(최상단): 진행 칸에 O 대신 ★ — 활성 O(초록)보다 조용하게, 채도 낮춘 톤다운 갈색 */
.toggle-s { background: #8d7f6b; color: #fff; }
.toggle-s:hover { background: #7c6f5d; }

/* 검색 / 필터 */
.searchbar { display: flex; align-items: center; gap: 0.5rem; background: var(--input-bg);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0.55rem 0.85rem; }
.searchbar svg { width: 15px; height: 15px; color: var(--muted-fg); flex-shrink: 0; }
.searchbar input { flex: 1; border: 0; background: transparent; outline: none; font-family: inherit;
  font-size: 0.875rem; color: var(--fg); }
.chip { font-size: 0.78rem; padding: 0.35rem 0.8rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); color: var(--muted-fg); cursor: pointer; transition: all 0.12s; }
.chip:hover { color: var(--fg); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.active-soft { background: var(--secondary); border-color: rgba(194,84,10,0.3); color: var(--fg); font-weight: 500; }

/* 페이지네이션 */
.pagination { display: flex; justify-content: center; gap: 0.3rem; margin-top: 1.1rem; }
.pagination a, .pagination span { min-width: 2rem; padding: 0.35rem 0.6rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-size: 0.85rem; color: var(--primary); text-align: center;
  font-family: 'DM Mono', monospace; }
.pagination a:hover { background: var(--secondary); }
.pagination .active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .disabled { color: #cdc3b2; pointer-events: none; }

/* 진행률 막대 (단계 도달 향상률) */
.progress-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.7rem; }
.progress-row .lbl { font-family: 'DM Mono', monospace; font-size: 0.75rem; color: var(--muted-fg);
  width: 5rem; flex-shrink: 0; }
/* 배경을 단색 대신 같은 색 그라디언트(=이미지)로 주면 브라우저 자동 다크(force-dark)가
   막대 너비에 따라 색을 다르게 눌러버리는 현상을 막아, 폰 다크모드에서도 모든 막대가 동일하게 렌더됨 */
.progress-track {
  flex: 1; height: 0.55rem;
  background-image: linear-gradient(rgba(232,118,42,0.22), rgba(232,118,42,0.22));
  border-radius: 999px; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(194,84,10,0.16);
  color-scheme: only light;
  forced-color-adjust: none;
}
.progress-fill {
  height: 100%;
  background-image: linear-gradient(var(--accent), var(--accent));
  border-radius: 999px; transition: width 0.3s;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.22), 0 0 10px rgba(232,118,42,0.30);
  color-scheme: only light;
  forced-color-adjust: none;
}
.progress-row .val { font-size: 0.78rem; font-weight: 500; width: 5.5rem; text-align: right; }

/* 만남 예정 3분할 */
.meet-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; text-align: center; }
.meet-col { padding: 0.6rem 0.4rem; border-radius: var(--radius-sm); border: 1px solid transparent; }
.meet-col.clickable { cursor: pointer; border-color: var(--border); background: var(--secondary); transition: background 0.12s, border-color 0.12s; }
.meet-col.clickable:hover { border-color: rgba(194,84,10,0.4); background: rgba(232,118,42,0.08); }
.meet-col.clickable .num { color: var(--primary); }
.meet-3 .lbl { font-size: 0.75rem; color: var(--muted-fg); margin-bottom: 0.2rem; }
.meet-3 .num { font-family: 'Fraunces', serif; font-size: 1.6rem; font-weight: 600; }
.meet-pill { font-size: 0.72rem; color: var(--primary); background: rgba(194,84,10,0.1);
  border-radius: var(--radius-sm); padding: 0.1rem 0.4rem; margin-top: 0.25rem; display: inline-block; }

/* 멀어짐 사유 줄 */
.reason-flow { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; align-items: center; }
.reason-flow .r { font-size: 0.85rem; }
.reason-flow .r strong { color: var(--amber); margin-left: 0.25rem; }
.reason-flow.tags .r strong { color: var(--primary); }

/* ── 상세/폼 슬라이드 패널 ─────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(26,18,8,0.4); backdrop-filter: blur(2px);
  z-index: 1060; opacity: 0; transition: opacity 0.22s; display: none; }
.overlay.show { display: block; opacity: 1; }
.slide-panel {
  position: fixed; top: 0; right: 0; height: 100%; width: 440px; max-width: 92%;
  background: var(--bg); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform 0.28s cubic-bezier(.4,0,.2,1);
  z-index: 1065; overflow-y: auto;
}
.slide-panel.show { transform: translateX(0); }
.panel-head { position: sticky; top: 0; background: var(--bg); border-bottom: 1px solid var(--border);
  padding: 0.9rem 1.15rem; display: flex; align-items: center; justify-content: space-between; z-index: 2; }
.panel-head h2 { font-family: 'Fraunces', serif; font-size: 1.1rem; }
.panel-body { padding: 1.15rem; display: flex; flex-direction: column; gap: 1.1rem; }
.info-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.25rem 1rem; }
.info-row { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.55rem 0; border-bottom: 1px solid var(--border-2); }
.info-row:last-child { border-bottom: 0; }
.info-row .k { font-size: 0.78rem; color: var(--muted-fg); width: 5.5rem; flex-shrink: 0; }
.info-row .v { font-size: 0.875rem; flex: 1; white-space: pre-wrap; }
.memo-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.memo-card .memo-label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--muted-fg); margin-bottom: 0.5rem; }

/* ── 모달 ──────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 1100; display: none; align-items: center; justify-content: center; padding: 1rem; }
.modal.show { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(26,18,8,0.4); backdrop-filter: blur(2px); }
.modal-box { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto; }
.modal-box.sm { max-width: 340px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.15rem; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-family: 'Fraunces', serif; font-size: 1.05rem; }
.modal-body { padding: 1.15rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.9rem 1.15rem; border-top: 1px solid var(--border); }
.modal .close-x { background: none; border: 0; cursor: pointer; color: var(--muted-fg); font-size: 1.3rem; line-height: 1; padding: 0; }

/* ── 알림 ──────────────────────────────────────────────────── */
.alert { padding: 0.65rem 0.9rem; border-radius: var(--radius-sm); font-size: 0.875rem; border: 1px solid transparent; }
.alert-success { background: var(--emerald-bg); border-color: var(--emerald-bd); color: var(--emerald); }
.alert-danger { background: #fbeae8; border-color: #f3cfca; color: var(--rose); }
.alert-info { background: var(--secondary); border-color: var(--border); }

/* ── 로그인 ────────────────────────────────────────────────── */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #2e2010 0%, #1a1208 55%); }
/* 모바일: 가운데 정렬이 너무 아래로 느껴져 위쪽으로 올림 */
@media (max-width: 820px) {
  .login-shell { align-items: flex-start; padding-top: 12vh; }
}
.login-card { width: 100%; max-width: 23rem; padding: 2.5rem 2rem; display: flex; flex-direction: column; gap: 2rem; align-items: center; }
.login-card .logo { font-size: 3rem; }
.login-card .brand { font-family: 'Fraunces', serif; font-size: 1.8rem; font-weight: 600; color: var(--sidebar-fg); }
.login-card .sub { color: var(--sidebar-dim); font-size: 0.875rem; margin-top: 0.2rem; }
.login-field { display: flex; align-items: center; gap: 0.5rem; background: #2e2010;
  border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius-sm); padding: 0.75rem 1rem; width: 100%; }
.login-field svg { width: 16px; height: 16px; color: var(--sidebar-dim); flex-shrink: 0; }
.login-field input { flex: 1; background: transparent; border: 0; outline: none; color: var(--sidebar-fg);
  font-family: inherit; font-size: 0.875rem; }
.login-field input::placeholder { color: #4a3f30; }
.login-btn { width: 100%; }

/* ── 가이드 ────────────────────────────────────────────────── */
.guide-step { display: flex; align-items: flex-start; gap: 0.6rem; margin-bottom: 0.6rem; }
.step-num { width: 1.5rem; height: 1.5rem; border-radius: 999px; background: var(--primary); color: #fff;
  font-size: 0.8rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.guide-note { background: var(--secondary); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem; font-size: 0.85rem; margin-top: 0.6rem; }
.guide-note ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }

/* htmx 로딩 바 (상단) + 토스트 */
#topbar-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--primary);
  z-index: 2000; opacity: 0; transition: width 0.25s ease, opacity 0.3s ease; pointer-events: none; }
#topbar-progress.active { width: 75%; opacity: 1; }
#topbar-progress.done { width: 100%; opacity: 0; }
#toast { position: fixed; bottom: 1.3rem; left: 50%; transform: translateX(-50%) translateY(1.5rem);
  background: var(--sidebar); color: var(--sidebar-fg); padding: 0.7rem 1.1rem; border-radius: var(--radius-sm);
  font-size: 0.85rem; z-index: 2100; opacity: 0; max-width: 90%; text-align: center;
  box-shadow: var(--shadow-lg); transition: opacity 0.25s, transform 0.25s; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 작은 유틸 */
.text-sm { font-size: 0.875rem; } .text-xs { font-size: 0.78rem; }
.fw-600 { font-weight: 600; } .mt-0 { margin-top: 0; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted-fg); font-size: 0.9rem; }
/* 대시보드 통계 카드용 컴팩트 빈 상태: 세로 여백만 줄임 */
.empty.empty-sm { padding: 0.6rem 1rem; font-size: 0.82rem; }

/* ── 모바일 ────────────────────────────────────────────────── */
.backdrop-mobile { display: none; }
@media (max-width: 820px) {
  .sidebar { position: fixed; left: 0; top: 0; height: 100%; transform: translateX(-100%);
    transition: transform 0.25s; box-shadow: var(--shadow-lg); width: 14rem; }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .backdrop-mobile { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 40; }
  .topbar .hamburger { display: inline-flex; }
  .page { padding: 1rem; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .fg-3, .fg-2 { grid-template-columns: 1fr; }
  .form-grid.keep-2 { grid-template-columns: 1fr 1fr; }
  .slide-panel { max-width: 88%; }
  .hide-sm { display: none !important; }
}
