:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1b1f24;
  --muted: #667085;
  --line: #e3e7ee;
  --primary: #1f4e79;
  --primary-soft: #e6eef7;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --ok: #2e7d32;
  --ok-soft: #e8f5e9;
  --radius: 14px;
  --tabbar-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --card: #1b2027; --text: #e8ebef; --muted: #9aa4b2; --line: #2a313b;
    --primary: #6aa7e0; --primary-soft: #1d2b3a; --danger-soft: #3a1f1c; --warn-soft: #3a2c14; --ok-soft: #1b3020;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { min-height: 100vh; font-size: 16px; line-height: 1.45; }
[hidden] { display: none !important; }
a { color: var(--primary); text-decoration: none; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; font-size: 16px; } /* iOS 확대 방지 */

/* 상단바 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 20px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 6px; }
.icon-btn { border: 0; background: none; font-size: 28px; line-height: 1; padding: 0 6px 2px 0; cursor: pointer; color: var(--primary); }

.view { max-width: 760px; margin: 0 auto; padding: 12px 14px calc(var(--tabbar-h) + var(--safe-b) + 90px); outline: none; }

/* 하단 탭 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 12px; }
.tabbar a .ti { font-size: 20px; line-height: 1; }
.tabbar a.active { color: var(--primary); font-weight: 600; }
.badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }

/* PC 화면: 왼쪽 메뉴 */
@media (min-width: 900px) {
  .tabbar { top: 0; bottom: 0; right: auto; width: 96px; height: auto; grid-template-columns: 1fr; grid-auto-rows: 76px; align-content: start; padding-top: 70px; border-top: 0; border-right: 1px solid var(--line); }
  .app { padding-left: 96px; }
  .view { padding-bottom: 60px; }
  .fab { bottom: 28px !important; }
}

/* 카드/목록 */
.section { margin: 18px 0 8px; display: flex; align-items: baseline; justify-content: space-between; }
.section h2 { font-size: 15px; margin: 0; color: var(--muted); font-weight: 600; }
.section .count { font-size: 13px; color: var(--muted); }
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.card + .card { margin-top: 10px; }
.card.pad { padding: 14px 16px; }
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 56px; width: 100%; text-align: left; background: none; border: 0; cursor: pointer; color: inherit; }
.row:active { background: var(--primary-soft); }
.row .main { flex: 1; min-width: 0; }
.row .t1 { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row .t2 { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .side { color: var(--muted); font-size: 13px; text-align: right; white-space: nowrap; }
.row .side.danger { color: var(--danger); font-weight: 600; }
.empty { padding: 18px 14px; color: var(--muted); font-size: 14px; text-align: center; }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.summary .stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px; text-align: center; }
.summary .stat b { display: block; font-size: 22px; }
.summary .stat span { font-size: 12px; color: var(--muted); }
.summary .stat.danger b { color: var(--danger); }
.date-hero { font-size: 14px; color: var(--muted); margin: 2px 2px 10px; }

/* 칩 */
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600; background: var(--primary-soft); color: var(--primary); white-space: nowrap; }
.chip.s-inquiry { background: #e8f1ff; color: #1d5bbf; }
.chip.s-scheduled { background: #fff4e0; color: #a35c00; }
.chip.s-consulting { background: #f1e8ff; color: #6b34b8; }
.chip.s-reviewing { background: #e6f6f4; color: #0c7a6e; }
.chip.s-customer { background: var(--ok-soft); color: var(--ok); }
.chip.s-hold { background: #eceff3; color: #5b6573; }
@media (prefers-color-scheme: dark) { .chip[class*="s-"] { filter: brightness(.9) saturate(.9); } }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.tag { color: var(--muted); font-size: 13px; margin-right: 6px; }

.filters { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.filters::-webkit-scrollbar { display: none; }
.filter { flex: none; height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 14px; cursor: pointer; }
.filter.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.filter small { opacity: .75; margin-left: 3px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--line); border-radius: 10px; padding: 3px; gap: 3px; margin-bottom: 10px; }
.seg button { border: 0; background: none; padding: 8px 4px; border-radius: 8px; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg button .n { margin-left: 3px; font-size: 12px; }
.seg button .n.danger { color: var(--danger); font-weight: 700; }

.search { position: sticky; top: calc(56px + var(--safe-t)); z-index: 10; background: var(--bg); padding: 4px 0 6px; }
.search input { width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 0 14px; color: var(--text); }

/* 체크 */
.check { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #b7c0cc; background: none; cursor: pointer; display: grid; place-items: center; color: transparent; font-size: 16px; }
.check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.done .t1 { text-decoration: line-through; color: var(--muted); }

/* 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-weight: 600; cursor: pointer; font-size: 15px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns .btn { flex: 1; }
.link-btn { border: 0; background: none; color: var(--primary); font-size: 16px; padding: 6px 2px; cursor: pointer; }
.fab { position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); z-index: 25; width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; font-size: 30px; box-shadow: 0 6px 16px rgba(31,78,121,.35); cursor: pointer; }

/* 고객 상세 */
.profile { padding: 16px; }
.profile .name { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile .phone { color: var(--muted); margin-top: 2px; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.quick a, .quick button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-size: 13px; font-weight: 600; border: 0; cursor: pointer; }
.quick .qi { font-size: 20px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 10px; padding: 14px 16px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.dates { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 16px 14px; }
.stage { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 14px; scrollbar-width: none; }
.stage::-webkit-scrollbar { display: none; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; cursor: pointer; }
.timeline .meta { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.timeline .body { margin-top: 6px; white-space: pre-wrap; word-break: break-word; }
.timeline .resp { margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: var(--bg); font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.timeline .resp b { color: var(--muted); font-weight: 600; margin-right: 4px; }

/* 시트(입력 창) */
.sheet-wrap { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10,15,25,.45); }
.sheet { position: relative; width: 100%; max-width: 640px; max-height: 92vh; display: flex; flex-direction: column; background: var(--bg); border-radius: 18px 18px 0 0; animation: up .18s ease-out; }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 18px; max-height: 86vh; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; text-align: center; font-size: 17px; margin: 0; }
.sheet-head-spacer { width: 40px; }
.sheet-body { overflow-y: auto; padding: 14px 16px calc(20px + var(--safe-b)); -webkit-overflow-scrolling: touch; }

.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.form .form-label { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: -6px; }
.form label.inline { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-weight: 500; font-size: 15px; }
.form input:not([type=checkbox]):not([type=radio]), .form select, .form textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.form textarea { min-height: 96px; resize: vertical; }
.form input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--primary); }
.form .req { color: var(--danger); }
.form fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 12px; background: var(--card); }
.form legend { font-size: 14px; font-weight: 600; color: var(--muted); padding: 0 6px; }
.form details summary { cursor: pointer; color: var(--primary); font-weight: 600; padding: 4px 0; }
.form details[open] summary { margin-bottom: 12px; }
.form details > .form { gap: 14px; }
.picks { display: flex; gap: 6px; flex-wrap: wrap; }
.picks button { height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 14px; cursor: pointer; }
.picks button.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 13px; color: var(--muted); font-weight: 400; }
.error { color: var(--danger); font-size: 14px; margin: 0; }

/* 로그인 */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.login-box img { margin: 0 auto; border-radius: 18px; }
.login-box h1 { margin: 0 0 8px; font-size: 22px; }
.login-box label { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 14px; color: var(--muted); font-weight: 600; }
.login-box input { height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); }

.toast { width: max-content; position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px); z-index: 200; background: #222a35; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; display: flex; gap: 14px; align-items: center; max-width: calc(100% - 32px); box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.toast button { white-space: nowrap; border: 0; background: none; color: #8cc4ff; font-weight: 700; cursor: pointer; }

.guide { font-size: 15px; }
.guide ol { padding-left: 20px; margin: 8px 0; }
.guide li { margin: 4px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 12px; }

/* 설치 페이지 */
.setup { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.setup-box { width: 100%; max-width: 420px; }
.setup .notice { background: var(--warn-soft); color: var(--warn); padding: 12px; border-radius: 12px; }
.setup .form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.setup .form input { height: 46px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); }
