/* =====================================================================
   Sales CRM · Design System
   ---------------------------------------------------------------------
   모던 B2B SaaS 스타일의 공용 디자인 시스템.
   새로운 페이지(대시보드/거래처 등록/상세 등)를 만들 때 이 파일 하나만
   불러와서(class 이름 그대로) 사용하세요.

     <link rel="stylesheet" href="design-system.css" />

   구성
     1. Design Tokens              — 색/타이포/간격/그림자/반경
     2. Base & Reset
     3. Layout                     — .app-shell / .sidebar / .main / .topbar / .page
     4. Navigation                 — .nav-item / .nav-section-label / .nav-sub
     5. Buttons                    — .btn (.btn-brand / -primary / -default / -ghost / -icon / -danger)
     6. Forms                      — .field / .form-label / .form-input / .form-select / .form-textarea
     7. Status & Chips             — .status.{prospect|first-contact|needs|...} / .chip
     8. Cards & Metrics            — .card / .metric
     9. Tables                     — .table-wrap / .data-table
    10. Modals                     — .modal-backdrop / .modal
    11. Callouts & Code            — .callout / .code-inline
    12. Tabs / Timeline / Pipeline
    13. Toasts & Empty State
    14. Utilities                  — .mono / .tabular / .hidden / .divider / grids
   ===================================================================== */


/* =====================================================================
   1. Design Tokens
   ===================================================================== */
:root {
  /* ---- Neutral (zinc-like) ------------------------------------------
     배경/텍스트 계층. --c-surface 는 카드/모달/사이드바의 기본색,
     --c-bg 는 페이지 배경색. */
  --c-bg:            #fafafa;
  --c-surface:       #ffffff;
  --c-surface-2:     #f7f7f8;   /* 섹션 배경, 테이블 헤더 */
  --c-surface-3:     #f3f3f5;   /* hover/active, pill 배경 */
  --c-border:        #e7e7ea;   /* 기본 1px 경계선 */
  --c-border-strong: #d4d4d8;   /* hover 경계선 */
  --c-divider:       #efeff1;   /* 카드 내부 divider */

  /* ---- Text ---------------------------------------------------------
     --c-text: 본문/제목.   --c-text-2: 서브 텍스트.
     --c-text-3: 라벨/메타. --c-text-4: 플레이스홀더/아이콘. */
  --c-text:   #18181b;
  --c-text-2: #52525b;
  --c-text-3: #71717a;
  --c-text-4: #a1a1aa;
  --c-text-inv: #ffffff;

  /* ---- Brand (indigo accent) ---------------------------------------- */
  --c-brand:      #4f46e5;
  --c-brand-600:  #4338ca;
  --c-brand-700:  #3730a3;
  --c-brand-50:   #eef2ff;
  --c-brand-100:  #e0e7ff;
  --c-focus-ring: rgba(79, 70, 229, 0.18);

  /* ---- Semantic colors ---------------------------------------------- */
  --c-success:    #16a34a;  --c-success-bg: #ecfdf5;
  --c-warning:    #d97706;  --c-warning-bg: #fffbeb;
  --c-danger:     #dc2626;  --c-danger-bg:  #fef2f2;
  --c-info:       #0284c7;  --c-info-bg:    #f0f9ff;

  /* ---- Radii -------------------------------------------------------- */
  --r-xs: 4px;
  --r-sm: 6px;   /* 버튼/인풋 */
  --r-md: 8px;   /* 콜아웃 */
  --r-lg: 10px;  /* 카드 */
  --r-xl: 12px;  /* 모달 */

  /* ---- Shadows (soft, layered) -------------------------------------- */
  --sh-xs: 0 1px 0 rgba(16, 24, 40, 0.04);
  --sh-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.05);
  --sh-md: 0 4px 8px -2px rgba(16, 24, 40, 0.06), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
  --sh-lg: 0 12px 24px -6px rgba(16, 24, 40, 0.08), 0 4px 8px -2px rgba(16, 24, 40, 0.05);
  --sh-xl: 0 24px 48px -12px rgba(16, 24, 40, 0.14);

  /* ---- Typography --------------------------------------------------- */
  --font-sans: "Inter", "Pretendard", -apple-system, BlinkMacSystemFont,
               "Segoe UI", "Noto Sans KR", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;

  /* ---- Layout sizing ----------------------------------------------- */
  --sidebar-w: 240px;
  --topbar-h:  52px;
}


/* =====================================================================
   2. Base & Reset
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

/* 숫자/코드엔 mono + 고정폭 숫자 */
.mono, code, kbd {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.tabular { font-variant-numeric: tabular-nums; }


/* =====================================================================
   3. Layout
   ---------------------------------------------------------------------
   기본 구조:
     <div class="app-shell">
       <aside class="sidebar">…</aside>
       <main class="main">
         <header class="topbar">…</header>
         <div class="page">
           <section class="page-header">…</section>
           <div class="page-body">…</div>
         </div>
       </main>
     </div>
   ===================================================================== */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--c-bg);
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  height: var(--topbar-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--c-divider);
}
.brand-mark {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--c-text);
  color: white;
  display: grid; place-items: center;
  font-weight: 700; font-size: 12px;
  letter-spacing: -0.02em;
}
.brand-name { font-weight: 600; font-size: 13px; letter-spacing: -0.01em; }
.brand-kbd {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--c-text-3);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 1px 5px;
}

.sidebar-user { padding: 10px 12px; border-bottom: 1px solid var(--c-divider); }
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.12s;
}
.user-card:hover { background: var(--c-surface-2); }
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--c-brand-100); color: var(--c-brand-700);
  display: grid; place-items: center;
  font-weight: 600; font-size: 11px;
  flex-shrink: 0;
}
.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: 12.5px; font-weight: 600; color: var(--c-text); line-height: 1.2; }
.user-role { font-size: 11px; color: var(--c-text-3); line-height: 1.3; margin-top: 1px; }
.user-switch { color: var(--c-text-4); }
.user-switch:hover { color: var(--c-text-2); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 8px 16px; }
.sidebar-footer { padding: 8px; border-top: 1px solid var(--c-divider); }


/* --- Main / Topbar / Page ------------------------------------------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  height: var(--topbar-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center;
  padding: 0 20px; gap: 16px;
  flex-shrink: 0;
}
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--c-text-3); }
.breadcrumb .sep { color: var(--c-text-4); }
.breadcrumb .current { color: var(--c-text); font-weight: 500; }

.topbar-search { flex: 1; max-width: 420px; position: relative; }
.topbar-search input {
  width: 100%; height: 30px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 0 10px 0 30px;
  font-size: 12.5px; color: var(--c-text);
  outline: none;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.topbar-search input::placeholder { color: var(--c-text-4); }
.topbar-search input:focus {
  background: var(--c-surface);
  border-color: var(--c-brand);
  box-shadow: 0 0 0 3px var(--c-focus-ring);
}
.topbar-search .search-icon {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  color: var(--c-text-4); width: 14px; height: 14px;
}
.topbar-search .kbd {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 11px; color: var(--c-text-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 3px; padding: 1px 4px;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.page { flex: 1; overflow-y: auto; }
.page-header {
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--c-divider);
  display: flex; align-items: flex-start; gap: 16px;
  background: var(--c-surface);
}
.page-title { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; color: var(--c-text); }
.page-subtitle { font-size: 13px; color: var(--c-text-3); margin-top: 2px; }
.page-header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.page-body { padding: 20px 28px 32px; }

/* 섹션 타이틀 (눈금 역할) */
.section-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--c-text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 20px 0 10px;
}


/* =====================================================================
   4. Navigation
   ---------------------------------------------------------------------
   <nav class="sidebar-nav">
     <div class="nav-section-label">Workspace</div>
     <a class="nav-item active">  ← 아이콘 + 텍스트 + (선택)카운트
       <i class="nav-icon"></i>
       <span>대시보드</span>
       <span class="nav-count">12</span>
     </a>
     <div class="nav-sub">…</div>    ← 들여쓴 보조 액션
   </nav>
   ===================================================================== */
.nav-section-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--c-text-4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--c-text-2);
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
  position: relative;
  cursor: pointer;
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--c-surface-2); color: var(--c-text); }
.nav-item.active { background: var(--c-surface-3); color: var(--c-text); }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--c-brand);
  border-radius: 0 2px 2px 0;
}
.nav-item .nav-icon { width: 16px; height: 16px; color: var(--c-text-3); flex-shrink: 0; }
.nav-item.active .nav-icon { color: var(--c-brand); }
.nav-item .nav-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--c-text-4);
  background: var(--c-surface-3);
  padding: 0 6px;
  height: 18px; line-height: 18px;
  border-radius: 9px;
  min-width: 22px; text-align: center;
}
.nav-sub {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 36px;
  font-size: 12px; color: var(--c-text-3);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.nav-sub:hover { color: var(--c-text); background: var(--c-surface-2); }


/* =====================================================================
   5. Buttons
   ---------------------------------------------------------------------
   주요 CTA       : .btn.btn-brand      (indigo fill)
   보조/확인      : .btn.btn-primary    (검정 fill — 대비가 필요할 때)
   기본(outline)  : .btn.btn-default
   투명(텍스트)   : .btn.btn-ghost
   아이콘 전용    : .btn.btn-icon
   위험(삭제)     : .btn.btn-danger
   작게           : .btn.btn-sm (다른 variant 와 병용)
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  height: 30px; padding: 0 12px;
  font-size: 12.5px; font-weight: 500;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--c-text);
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.btn svg, .btn .icon { width: 14px; height: 14px; flex-shrink: 0; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--c-focus-ring); }

.btn-primary { background: var(--c-text); color: white; border-color: var(--c-text); }
.btn-primary:hover { background: #27272a; border-color: #27272a; }

.btn-brand { background: var(--c-brand); color: white; border-color: var(--c-brand); box-shadow: var(--sh-xs); }
.btn-brand:hover { background: var(--c-brand-600); border-color: var(--c-brand-600); }

.btn-default { background: var(--c-surface); border-color: var(--c-border); color: var(--c-text); box-shadow: var(--sh-xs); }
.btn-default:hover { background: var(--c-surface-2); border-color: var(--c-border-strong); }

.btn-ghost { color: var(--c-text-2); }
.btn-ghost:hover { background: var(--c-surface-2); color: var(--c-text); }

.btn-icon { width: 30px; padding: 0; color: var(--c-text-2); }
.btn-icon:hover { background: var(--c-surface-2); color: var(--c-text); }

.btn-sm { height: 26px; font-size: 12px; padding: 0 10px; }
.btn-sm svg, .btn-sm .icon { width: 13px; height: 13px; }

.btn-danger { background: var(--c-surface); border-color: var(--c-border); color: var(--c-danger); }
.btn-danger:hover { background: var(--c-danger-bg); border-color: #fecaca; }


/* =====================================================================
   6. Forms
   ---------------------------------------------------------------------
   <div class="field">
     <label class="form-label">이름 <span class="req">*</span></label>
     <input class="form-input" />
     <div class="form-hint">도움말 텍스트</div>
   </div>
   2열 배치 : <div class="field field-row">…</div>
   Select   : <select class="form-select">
   Textarea : <textarea class="form-textarea">
   ===================================================================== */
.field { display: block; }
.field + .field { margin-top: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-label {
  display: block;
  font-size: 12px; font-weight: 500;
  color: var(--c-text);
  margin-bottom: 5px;
  letter-spacing: -0.005em;
}
.form-label .req { color: var(--c-danger); margin-left: 2px; }
.form-hint {
  font-size: 11.5px; color: var(--c-text-3);
  margin-top: 4px;
  display: flex; align-items: center; gap: 4px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.form-input::placeholder { color: var(--c-text-4); }
.form-input:hover, .form-select:hover, .form-textarea:hover { border-color: var(--c-border-strong); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--c-brand);
  box-shadow: 0 0 0 3px var(--c-focus-ring);
}
.form-input:read-only, .form-input[readonly] {
  background: var(--c-surface-2);
  color: var(--c-text-2);
}
.form-textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 68px; }
.form-select {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}


/* =====================================================================
   7. Status & Chips
   ---------------------------------------------------------------------
   상태 표시는 "dot + label" 방식 (.status) 이 기본.
   Pill 형태가 꼭 필요할 때만 .chip 을 사용하세요.

     <span class="status won">계약 완료</span>
     <span class="chip brand">IT/SI</span>

   제공되는 상태 키:
     prospect · first-contact · needs · proposal
     negotiation · won · hold · lost
   ===================================================================== */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500;
  color: var(--c-text-2);
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
}
.status.prospect      { color: #71717a; }
.status.first-contact { color: #2563eb; }
.status.needs         { color: #4338ca; }
.status.proposal      { color: #b45309; }
.status.negotiation   { color: #c2410c; }
.status.won           { color: #15803d; }
.status.hold          { color: #475569; }
.status.lost          { color: #b91c1c; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px; padding: 0 7px;
  font-size: 11px; font-weight: 500;
  border-radius: 10px;
  background: var(--c-surface-3);
  color: var(--c-text-2);
  border: 1px solid var(--c-border);
}
.chip.brand   { background: var(--c-brand-50);   color: var(--c-brand-700); border-color: #dbe1ff; }
.chip.success { background: var(--c-success-bg); color: #166534;           border-color: #bbf7d0; }
.chip.warning { background: var(--c-warning-bg); color: #92400e;           border-color: #fde68a; }
.chip.danger  { background: var(--c-danger-bg);  color: #991b1b;           border-color: #fecaca; }


/* =====================================================================
   8. Cards & Metrics
   ---------------------------------------------------------------------
   Card:
     <div class="card">
       <div class="card-header">
         <div>
           <div class="card-title">제목</div>
           <div class="card-subtitle">서브타이틀</div>
         </div>
         <div class="card-actions"><button class="btn btn-default btn-sm">…</button></div>
       </div>
       <div class="card-body">…</div>
     </div>

   Metric (KPI 카드):
     <div class="metric">
       <div class="metric-label"><i>…</i> 레이블</div>
       <div class="metric-value">128<span class="unit">%</span></div>
       <div class="metric-delta up"><i></i> +12.4% <span class="spark">· MoM</span></div>
     </div>
   ===================================================================== */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
}
.card-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--c-divider);
}
.card-title { font-size: 13px; font-weight: 600; color: var(--c-text); letter-spacing: -0.005em; }
.card-subtitle { font-size: 12px; color: var(--c-text-3); }
.card-body { padding: 16px; }
.card-actions { margin-left: auto; display: flex; gap: 6px; }

.metric {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--sh-xs);
  transition: box-shadow .15s, border-color .15s;
}
.metric:hover { box-shadow: var(--sh-sm); border-color: var(--c-border-strong); }
.metric-label { font-size: 12px; color: var(--c-text-3); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.metric-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--c-text);
  margin-top: 8px;
  line-height: 1.1;
}
.metric-value .unit { font-size: 14px; font-weight: 500; color: var(--c-text-3); margin-left: 2px; }
.metric-delta {
  margin-top: 8px;
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
}
.metric-delta.up   { color: var(--c-success); }
.metric-delta.down { color: var(--c-danger); }
.metric-delta .spark { color: var(--c-text-4); }


/* =====================================================================
   9. Tables
   ---------------------------------------------------------------------
   <div class="table-wrap">
     <div class="table-toolbar">…검색/필터…</div>
     <table class="data-table">
       <thead><tr><th>…</th><th class="num">금액</th></tr></thead>
       <tbody>
         <tr>
           <td>
             <div class="row-primary">메인 텍스트</div>
             <div class="row-secondary">부가 정보</div>
           </td>
           <td class="num">1,200,000</td>
         </tr>
       </tbody>
     </table>
   </div>
   ===================================================================== */
.table-wrap {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--sh-xs);
}
.table-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-divider);
  background: var(--c-surface);
}
.table-toolbar .spacer { flex: 1; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table thead th {
  background: var(--c-surface-2);
  padding: 8px 14px;
  text-align: left;
  font-size: 11.5px; font-weight: 500;
  color: var(--c-text-3);
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
  letter-spacing: 0.01em;
  position: sticky; top: 0;
}
.data-table thead th.num { text-align: right; }
.data-table tbody tr { border-bottom: 1px solid var(--c-divider); transition: background .08s; }
.data-table tbody tr:last-child { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--c-surface-2); }
.data-table tbody td { padding: 11px 14px; color: var(--c-text); vertical-align: middle; }
.data-table tbody td.num {
  text-align: right;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  color: var(--c-text);
}
.data-table tbody td.muted { color: var(--c-text-3); }
.data-table .row-primary { font-weight: 500; }
.data-table .row-secondary { color: var(--c-text-3); font-size: 11.5px; margin-top: 1px; }


/* =====================================================================
  10. Modals
   ---------------------------------------------------------------------
   <div class="modal-backdrop">          ← .hidden 으로 닫힘
     <div class="modal lg">              ← .lg 는 max-width 560px
       <div class="modal-header">…</div>
       <div class="modal-body">…</div>
       <div class="modal-footer">…</div>
     </div>
   </div>
   ===================================================================== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(24, 24, 27, 0.45);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--c-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--c-border);
}
.modal.lg { max-width: 560px; }
.modal-header {
  display: flex; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-divider);
  gap: 10px;
}
.modal-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.modal-subtitle { font-size: 12px; color: var(--c-text-3); margin-top: 2px; }
.modal-close {
  margin-left: auto;
  width: 26px; height: 26px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: var(--c-text-3);
  background: transparent; border: none;
}
.modal-close:hover { background: var(--c-surface-2); color: var(--c-text); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--c-divider);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--c-surface-2);
}


/* =====================================================================
  11. Callouts & Code
   ---------------------------------------------------------------------
   <div class="callout info">
     <i class="callout-icon">…</i>
     <div><strong>Title</strong> 본문</div>
   </div>
   variants: default / .warning / .danger / .info
   ===================================================================== */
.callout {
  border: 1px solid var(--c-border);
  background: var(--c-surface-2);
  border-radius: var(--r-md);
  padding: 10px 12px;
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 12.5px; color: var(--c-text-2);
}
.callout .callout-icon { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; color: var(--c-text-3); }
.callout strong { color: var(--c-text); font-weight: 600; }
.callout.warning { background: var(--c-warning-bg); border-color: #fde68a; color: #78350f; }
.callout.warning .callout-icon { color: var(--c-warning); }
.callout.danger  { background: var(--c-danger-bg);  border-color: #fecaca; color: #7f1d1d; }
.callout.danger  .callout-icon { color: var(--c-danger); }
.callout.info    { background: var(--c-info-bg);    border-color: #bae6fd; color: #0c4a6e; }
.callout.info    .callout-icon { color: var(--c-info); }

.code-inline {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xs);
  padding: 2px 6px;
  color: var(--c-brand-700);
}


/* =====================================================================
  12. Tabs / Pipeline / Timeline
   ---------------------------------------------------------------------
   Tabs:       <div class="tabs"><button class="tab active">…</button></div>
   Pipeline:   <div class="pipeline"><div class="seg" style="flex:42;background:#a1a1aa"></div>…</div>
   Timeline:   <div class="timeline"><div class="timeline-item active">…</div></div>
   ===================================================================== */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--c-border);
  padding: 0 12px;
}
.tab {
  padding: 9px 12px;
  font-size: 12.5px; font-weight: 500;
  color: var(--c-text-3);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--c-text); }
.tab.active { color: var(--c-text); border-bottom-color: var(--c-text); }

.pipeline {
  display: flex; gap: 2px;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--c-surface-3);
}
.pipeline .seg { height: 100%; }

.timeline { position: relative; padding-left: 20px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 7px; top: 6px; bottom: 6px;
  width: 1px;
  background: var(--c-divider);
}
.timeline-item { position: relative; padding: 8px 0 14px; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -18px; top: 12px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c-surface);
  border: 2px solid var(--c-border-strong);
}
.timeline-item.active::before { border-color: var(--c-brand); background: var(--c-brand); }
.timeline-meta  { font-size: 11.5px; color: var(--c-text-3); font-family: var(--font-mono); }
.timeline-title { font-size: 13px; font-weight: 500; color: var(--c-text); margin-top: 2px; }
.timeline-body  { font-size: 12.5px; color: var(--c-text-2); margin-top: 2px; line-height: 1.55; }


/* =====================================================================
  13. Toasts & Empty State
   ===================================================================== */
.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 60;
  background: var(--c-text); color: white;
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: 12.5px;
  box-shadow: var(--sh-lg);
  display: flex; align-items: center; gap: 10px;
}
.toast.hidden { display: none; }
.toast .toast-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c-success); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--c-text-3); }
.empty-state .empty-icon {
  width: 40px; height: 40px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--c-surface-2);
  display: grid; place-items: center;
  color: var(--c-text-4);
}
.empty-state .empty-title { color: var(--c-text); font-weight: 600; font-size: 13px; margin-bottom: 4px; }


/* =====================================================================
  14. Utilities
   ===================================================================== */
.divider { height: 1px; background: var(--c-divider); margin: 12px 0; }
.hidden  { display: none !important; }

/* 4열 metric 그리드 (반응형) */
.grid-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 960px) {
  .grid-metrics { grid-template-columns: repeat(2, 1fr); }
}

/* 스크롤바 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 5px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
*:hover > ::-webkit-scrollbar-thumb,
*:hover::-webkit-scrollbar-thumb {
  background: #d4d4d8;
  background-clip: padding-box;
  border: 3px solid transparent;
}
::-webkit-scrollbar-thumb:hover {
  background: #a1a1aa;
  background-clip: padding-box;
  border: 3px solid transparent;
}

/* 작은 화면에선 사이드바 아이콘만 */
@media (max-width: 860px) {
  :root { --sidebar-w: 64px; }
  .sidebar .brand-name,
  .sidebar .nav-item span,
  .sidebar .user-meta,
  .sidebar .nav-sub span,
  .sidebar .nav-section-label,
  .sidebar .brand-kbd,
  .sidebar .user-switch,
  .sidebar .nav-count { display: none; }
  .sidebar .nav-item { justify-content: center; padding: 8px; }
}


/* =====================================================================
   Sales CRM — App-specific extensions
   ===================================================================== */

/* nav-item as button (overrides browser default) */
.nav-item {
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item i { width: 16px; color: var(--c-text-3); flex-shrink: 0; text-align: center; }
.nav-item.active i { color: var(--c-brand); }

/* Page content area */
.page-content {
  flex: 1;
  overflow-y: auto;
  background: var(--c-bg);
}

/* Topbar title */
.topbar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--c-text);
}

/* Pagination buttons */
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text-2);
  font-size: 12px;
  cursor: pointer;
  transition: all .1s;
}
.page-btn:hover { background: var(--c-surface-2); color: var(--c-text); }
.page-btn.active { background: var(--c-brand); color: white; border-color: var(--c-brand); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Tab button (detail tab) */
.tab-btn {
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--c-text-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  cursor: pointer;
  transition: color .1s, border-color .1s;
}
.tab-btn:hover { color: var(--c-text); }
.tab-btn.active { color: var(--c-text); border-bottom-color: var(--c-brand); }

/* Status variants for this app */
.status.prospect-visit    { color: #71717a; }   /* 예상거래처-방문전 */
.status.prospect-visited  { color: #4f46e5; }   /* 예상거래처-방문완료 */
.status.existing          { color: #15803d; }   /* 기존거래처 */

/* Activity icon (colored square) */
.activity-icon {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--c-surface-2);
  color: var(--c-text-3);
  font-size: 12px;
}
.activity-icon.전화      { background: #dbeafe; color: #1d4ed8; }
.activity-icon.방문      { background: #dcfce7; color: #15803d; }
.activity-icon.이메일    { background: #fce7f3; color: #be185d; }
.activity-icon.미팅      { background: #ede9fe; color: #7c3aed; }
.activity-icon.제안서\ 발송 { background: #fef9c3; color: #a16207; }
.activity-icon.후속\ 협의  { background: #ffedd5; color: #c2410c; }
.activity-icon.기타      { background: var(--c-surface-2); color: var(--c-text-3); }

/* Map info window */
.map-info-window {
  padding: 10px 12px;
  min-width: 180px;
  max-width: 240px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  line-height: 1.5;
}
.map-info-window .info-title {
  font-weight: 600; font-size: 13px; color: var(--c-text);
  margin-bottom: 6px; border-bottom: 1px solid var(--c-divider); padding-bottom: 6px;
}
.map-info-window .info-row {
  display: flex; align-items: flex-start; gap: 6px;
  color: var(--c-text-2); margin-bottom: 3px; font-size: 12px;
}
.map-info-window .info-detail-btn {
  display: block; width: 100%; margin-top: 8px;
  padding: 5px 10px; background: var(--c-brand); color: white;
  border: none; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 500; cursor: pointer; text-align: center;
}
.map-info-window .info-detail-btn:hover { background: var(--c-brand-600); }

/* Timeline helpers */
.timeline-meta  { font-size: 11.5px; color: var(--c-text-3); font-family: var(--font-mono); }
.timeline-title { font-size: 13px; font-weight: 500; color: var(--c-text); margin-top: 2px; }
.timeline-body  { font-size: 12.5px; color: var(--c-text-2); margin-top: 2px; line-height: 1.55; }

/* Loading spinner */
.loading-spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--c-border);
  border-top-color: var(--c-brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state { text-align: center; padding: 48px 20px; color: var(--c-text-3); }
.empty-state i { font-size: 28px; margin-bottom: 10px; display: block; color: var(--c-text-4); }
.empty-state p { font-size: 13px; margin: 0; }

/* Card simple (without header/body) */
.card-simple {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
  padding: 16px;
}

/* Utility: hidden */
.hidden { display: none !important; }

/* Grid helpers */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* Divider */
.divider { height: 1px; background: var(--c-divider); margin: 12px 0; }

/* Table wrap */
.table-wrap {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--sh-xs);
}

/* Scrollbar slim */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
*:hover > ::-webkit-scrollbar-thumb,
*:hover::-webkit-scrollbar-thumb { background: #d4d4d8; }
::-webkit-scrollbar-thumb:hover { background: #a1a1aa; }

/* Toast with icon */
.toast-icon { width: 16px; height: 16px; flex-shrink: 0; }


/* =====================================================================
   15. Mobile Responsive  (≤ 768px)
   ===================================================================== */

/* 모바일 하단 네비게이션 탭 바 */
.mobile-nav {
  display: none;
}

@media (max-width: 768px) {
  /* ── 레이아웃 ── */
  :root {
    --topbar-h: 48px;
    --mobile-nav-h: 60px;
  }

  .app-shell {
    flex-direction: column;
  }

  /* ── 사이드바 숨김 ── */
  .sidebar {
    display: none;
  }

  /* ── 메인 영역 ── */
  .main {
    flex: 1;
    min-height: 0;
    padding-bottom: var(--mobile-nav-h);
  }

  /* ── 탑바 ── */
  .topbar {
    padding: 0 14px;
    height: var(--topbar-h);
  }
  .topbar-title { font-size: 14px; }

  /* ── 페이지 콘텐츠 ── */
  .page-content {
    height: calc(100vh - var(--topbar-h) - var(--mobile-nav-h));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── 하단 네비게이션 탭 바 ── */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--mobile-nav-h);
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    z-index: 40;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: transparent;
    color: var(--c-text-4);
    font-size: 10px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: color .15s;
    padding: 6px 0;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav-item i { font-size: 18px; transition: color .15s; }
  .mobile-nav-item.active { color: var(--c-brand); }
  .mobile-nav-item.active i { color: var(--c-brand); }

  /* ── 모달 ── */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal, .modal.lg {
    max-width: 100%;
    width: 100%;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-height: 92vh;
  }
  /* 상단 드래그 핸들 */
  .modal::before {
    content: "";
    display: block;
    width: 36px; height: 4px;
    background: var(--c-border-strong);
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }

  /* ── 폼 2열 → 1열 ── */
  .field-row {
    grid-template-columns: 1fr;
  }

  /* ── 폼 입력 크기 ── */
  .form-input, .form-select, .form-textarea {
    height: 40px;
    font-size: 16px; /* iOS 줌 방지 */
  }
  .form-textarea { height: auto; }

  /* ── 버튼 ── */
  .btn { height: 36px; font-size: 13px; }
  .btn-sm { height: 30px; font-size: 12px; }

  /* ── 토스트 ── */
  .toast {
    bottom: calc(var(--mobile-nav-h) + 12px);
    right: 12px;
    left: 12px;
    font-size: 13px;
  }

  /* ── 지도 페이지 ── */
  #map-left-panel {
    position: fixed !important;
    bottom: var(--mobile-nav-h) !important;
    left: 0 !important; right: 0 !important;
    width: 100% !important;
    height: 52% !important;
    border-right: none !important;
    border-top: 1px solid var(--c-border) !important;
    z-index: 30;
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.32,.72,0,1);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,.10);
  }
  #map-left-panel.panel-open {
    transform: translateY(0);
  }
  #map-left-panel::before {
    content: "";
    display: block;
    width: 36px; height: 4px;
    background: var(--c-border-strong);
    border-radius: 2px;
    margin: 10px auto 4px;
    flex-shrink: 0;
  }

  /* 지도 영역 전체 화면 */
  #kakao-map {
    position: absolute;
    inset: 0;
  }

  /* 지도 페이지 컨테이너 */
  #page-content[data-page="map"] {
    overflow: hidden;
  }

  /* 지도 FAB: 위치 조정 */
  #map-register-fab {
    bottom: calc(var(--mobile-nav-h) + 16px) !important;
  }

  /* 지도 패널 토글 버튼 */
  #map-panel-toggle {
    display: flex !important;
  }

  /* 지도 컨트롤 버튼 위치 */
  #kakao-map + div { /* fitMapBounds 버튼 */
    bottom: calc(var(--mobile-nav-h) + 60px);
    top: auto !important;
  }

  /* ── 모바일 유저 아바타 버튼 ── */
  .mobile-user-btn { display: flex !important; align-items: center; justify-content: center; }

  /* ── 대시보드 메트릭 ── */
  .grid-metrics {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* ── 거래처 목록 ── */
  .page-body { padding: 12px 14px 24px; }

  /* ── 거래처 상세 헤더 ── */
  .page-header { padding: 16px 14px 14px; }

  /* ── 테이블 wrap ── */
  .table-wrap { border-radius: var(--r-md); }
  .data-table tbody td { padding: 10px 10px; }

  /* ── 카드 ── */
  .card-body { padding: 12px; }
  .card-header { padding: 12px; }
}

/* 아이폰 노치/홈바 safe area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 768px) {
    .mobile-nav {
      padding-bottom: env(safe-area-inset-bottom);
      height: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom));
    }
    .main {
      padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom));
    }
    .page-content {
      height: calc(100vh - var(--topbar-h) - var(--mobile-nav-h) - env(safe-area-inset-bottom));
    }
  }
}
