/* 음성자이 상담 접수 관리 — 데스크톱은 한 화면(목록만 안에서 스크롤), 휴대폰은 카드 목록 */
:root {
  --ink: #101828; --sub: #475467; --muted: #667085; --line: #e4e7ec; --bg: #f4f6f9; --card: #fff;
  --navy: #142238; --pri: #2457c5; --pri-d: #1b449c; --warn: #c2410c; --warn-bg: #fff4ed;
  --r: 12px; --ease-out: cubic-bezier(.2,.8,.2,1); --ease-in: cubic-bezier(.4,0,1,1);
  /* 상태 색 — 바탕 · 글자 */
  --s-new: #e8efff; --s-new-t: #1d4ed8;
  --s-absent: #f2f4f7; --s-absent-t: #475467;
  --s-talking: #fff6db; --s-talking-t: #a15c07;
  --s-visit: #e6f6f3; --s-visit-t: #0f766e;
  --s-visited: #def7ec; --s-visited-t: #047857;
  --s-contract: #142238; --s-contract-t: #fff;
  --s-hold: #f3eefe; --s-hold-t: #6d28d9;
  --s-lost: #fdecec; --s-lost-t: #b42318;
  --s-invalid: #f2f4f7; --s-invalid-t: #98a2b3;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { font-family: "Pretendard Variable", Pretendard, system-ui, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; letter-spacing: -0.01em; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.xi { width: 40px; height: auto; color: var(--navy); flex: none; }
.bar { width: 1px; height: 16px; background: var(--line); margin: 0 2px; }
:root { --ui-ink: #101828; --ui-accent: #2457c5; --ui-line: #e4e7ec; --ui-h: 42px; --ui-fs: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 10px; font-weight: 700; white-space: nowrap; transition: background .15s; }
.btn--pri { background: var(--ink); color: #fff; }
.btn--pri:hover { background: #000; }
.btn--block { width: 100%; height: 46px; }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--bg); }
.iconbtn svg circle { fill: currentColor; stroke: none; }
.err { min-height: 18px; color: var(--warn); font-size: 13px; font-weight: 600; }
.note { color: var(--muted); font-size: 13px; }
.sub { color: var(--muted); margin-top: -6px; }
.lbl { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.f { display: flex; flex-direction: column; gap: 6px; }
.f span { font-size: 12.5px; font-weight: 700; color: var(--sub); }
.f input, .f select, .f textarea, .users__add input, .users__add select { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.f textarea { height: auto; padding: 10px 12px; resize: vertical; }
.f input:focus, .f select:focus, .f textarea:focus, .memo textarea:focus { outline: 2px solid var(--pri); outline-offset: -1px; border-color: transparent; }

/* 로그인 */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login__box { width: min(380px, 100%); background: #fff; border-radius: 18px; padding: 36px 28px 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 10px 40px rgba(16,24,40,.08); }
.login__brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--sub); }
.login h1 { font-size: 24px; font-weight: 800; margin-bottom: 6px; }

/* 앱 뼈대: 한 화면 */
.app { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto auto auto 1fr; gap: 12px; padding: 14px 20px 18px; max-width: 1680px; margin: 0 auto; }
.top { display: flex; align-items: center; gap: 10px; }
.top__brand { display: flex; align-items: center; gap: 8px; margin-right: auto; white-space: nowrap; }
.top__brand b { font-size: 17px; font-weight: 800; }
.top__sub { color: var(--muted); font-weight: 600; }
.search { display: flex; align-items: center; gap: 8px; height: 38px; width: 300px; padding: 0 12px; border-radius: 10px; background: #fff; border: 1px solid var(--line); color: var(--muted); }
.search input { border: 0; outline: 0; width: 100%; background: none; color: var(--ink); }
.menu { position: relative; }
.menu__pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; width: 220px; padding: 6px; border-radius: 12px; background: #fff; box-shadow: 0 12px 36px rgba(16,24,40,.16); display: flex; flex-direction: column;
  opacity: 0; transform: translateY(6px); transition: opacity .18s var(--ease-in), transform .18s var(--ease-in); }
.menu__pop.is-open { opacity: 1; transform: none; transition: opacity .22s var(--ease-out), transform .22s var(--ease-out); }
.menu__pop a, .menu__pop button { text-align: left; padding: 10px 12px; border-radius: 8px; font-weight: 600; }
.menu__pop a:hover, .menu__pop button:hover { background: var(--bg); }
.menu__who { padding: 8px 12px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }

/* 상황판 */
.board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(0, 1.6fr); gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px 16px; border-radius: var(--r); background: #fff; text-align: left; border: 2px solid transparent; transition: border-color .15s; min-width: 0; }
button.tile:hover { border-color: var(--line); }
.tile.is-on { border-color: var(--ink); }
.tile span { font-size: 12.5px; font-weight: 700; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tile b { font-size: 28px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile em { font-style: normal; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tile--warn b { color: var(--warn); }
.tile--src { gap: 8px; }
.tile--src small { font-weight: 600; color: var(--muted); }
.srcbar { display: flex; width: 100%; height: 10px; border-radius: 6px; overflow: hidden; background: var(--bg); }
.srcbar i { display: block; height: 100%; }
.srcleg { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--sub); }
.srcleg li { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.srcleg i { width: 8px; height: 8px; border-radius: 2px; }
.srcleg b { font-size: 12.5px; font-weight: 800; color: var(--ink); line-height: inherit; }

/* 거르기 */
.filters { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.chip { flex: none; height: 32px; padding: 0 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: 13px; font-weight: 700; color: var(--sub); white-space: nowrap; }
.chip b { margin-left: 4px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip[aria-pressed="true"] b { color: rgba(255,255,255,.7); }
.filters__sel { display: flex; gap: 6px; flex: none; }
.filters__sel .ui { width: 118px; }
.filters__sel .ui-field { height: 32px; padding: 0 8px 0 12px; border-radius: 8px; font-size: 13px; font-weight: 700; }

/* 목록 */
.list { min-height: 0; overflow: auto; background: #fff; border-radius: var(--r); }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.tbl th { position: sticky; top: 0; z-index: 1; background: #fff; text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 0 12px; height: 46px; border-bottom: 1px solid #f0f2f5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl tbody tr { cursor: pointer; transition: background .12s; }
.tbl tbody tr:hover { background: #f8fafc; }
.tbl tr.is-new td.c-name { font-weight: 800; }
.c-time { width: 84px; } .c-name { width: 104px; } .c-phone { width: 150px; } .c-type { width: 62px; } .c-visit { width: 92px; }
.c-src { width: 168px; } .c-status { width: 92px; } .c-owner { width: 84px; } .c-memo { width: auto; }
td.c-time, td.c-visit { color: var(--sub); font-variant-numeric: tabular-nums; }
td.c-phone { font-variant-numeric: tabular-nums; }
td.c-memo { color: var(--sub); }
.src { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.src i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.src small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.st { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.st-new { background: var(--s-new); color: var(--s-new-t); } .st-absent { background: var(--s-absent); color: var(--s-absent-t); }
.st-talking { background: var(--s-talking); color: var(--s-talking-t); } .st-visit { background: var(--s-visit); color: var(--s-visit-t); }
.st-visited { background: var(--s-visited); color: var(--s-visited-t); } .st-contract { background: var(--s-contract); color: var(--s-contract-t); }
.st-hold { background: var(--s-hold); color: var(--s-hold-t); } .st-lost { background: var(--s-lost); color: var(--s-lost-t); }
.st-invalid { background: var(--s-invalid); color: var(--s-invalid-t); }
.due { color: var(--warn); font-weight: 700; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* 겹 화면 — 열 때 아래에서 위로 + 페이드, 닫을 때 반대로 */
.layer { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.layer[hidden] { display: none; }
.layer__scrim { position: absolute; inset: 0; background: rgba(8,13,24,.5); opacity: 0; transition: opacity .2s var(--ease-in); }
.modal { position: relative; width: min(460px, 100%); max-height: calc(100dvh - 40px); overflow: auto; background: #fff; border-radius: 18px; padding: 28px; display: flex; flex-direction: column; gap: 14px;
  opacity: 0; transform: translateY(16px); transition: opacity .2s var(--ease-in), transform .2s var(--ease-in); }
.layer.is-open .layer__scrim { opacity: 1; transition: opacity .26s var(--ease-out); }
.layer.is-open .modal { opacity: 1; transform: none; transition: opacity .26s var(--ease-out), transform .26s var(--ease-out); }
.modal h2 { font-size: 20px; font-weight: 800; padding-right: 40px; }
.modal--sm { width: min(400px, 100%); }
.modal--md { width: min(560px, 100%); }
.modal--lg { width: min(980px, 100%); padding: 26px 28px 24px; }
.x { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%; background: var(--bg); }
.x::before, .x::after { content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 2px; border-radius: 2px; background: var(--ink); }
.x::before { transform: translate(-50%,-50%) rotate(45deg); } .x::after { transform: translate(-50%,-50%) rotate(-45deg); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 상세 */
.dt__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding-right: 44px; flex-wrap: wrap; }
.dt__head h2 { padding: 0; font-size: 24px; }
.dt__tel { display: inline-block; margin-top: 2px; font-size: 18px; font-weight: 800; color: var(--pri); font-variant-numeric: tabular-nums; }
.dt__status { display: flex; flex-wrap: wrap; gap: 6px; }
.dt__status button { padding: 6px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 800; background: var(--bg); color: var(--sub); transition: background .15s, color .15s; }
.dt__status button[aria-pressed="true"] { outline: 2px solid currentColor; outline-offset: -2px; }
.dt__body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: stretch; min-height: 0; }
.dt__info, .dt__log { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.dt__log { background: var(--bg); border-radius: var(--r); padding: 16px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.grid > div { background: #fff; padding: 10px 12px; min-width: 0; }
.grid dt { font-size: 11.5px; font-weight: 700; color: var(--muted); margin-bottom: 3px; }
.grid dd { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid dd select, .grid dd input { width: 100%; border: 0; padding: 0; font-weight: 700; background: none; outline: 0; }
.grid .wide { grid-column: 1 / -1; }
.dt__msg { flex: 1; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); min-height: 96px; }
.dt__msg p:last-child { white-space: pre-wrap; line-height: 1.6; }
/* 기록이 길어도 상자 높이는 왼쪽 정보에 맞추고 안에서 스크롤 (contain: size 로 높이 계산에서 뺀다) */
.tl { list-style: none; display: flex; flex-direction: column; gap: 10px; overflow: auto; flex: 1; min-height: 150px; contain: size; }
.tl li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; }
.tl i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #fff; font-style: normal; font-size: 11px; }
.tl .k-call i, .tl .k-memo i { background: var(--ink); color: #fff; }
.tl p { line-height: 1.5; white-space: pre-wrap; word-break: break-all; }
.tl small { display: block; color: var(--muted); font-size: 11.5px; }
.memo { display: flex; flex-direction: column; gap: 8px; }
.memo textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; resize: vertical; background: #fff; }
.memo__row { display: flex; justify-content: space-between; align-items: center; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--sub); }

/* 계정 */
.users { list-style: none; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.users li { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.users li:last-child { border-bottom: 0; }
.users small { color: var(--muted); margin-left: 6px; }
.users button { font-size: 12.5px; font-weight: 700; color: var(--pri); }
.users .off { opacity: .45; }
.users__add { display: grid; grid-template-columns: 1fr 1fr 130px auto; gap: 8px; }
.users__add .ui-field { height: 42px; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 200; transform: translate(-50%, 12px); padding: 12px 18px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s var(--ease-in), transform .2s var(--ease-in); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); transition: opacity .24s var(--ease-out), transform .24s var(--ease-out); }

@media (max-width: 1280px) {
  .board { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .tile--src { display: none; }
  .c-owner { width: 70px; } .c-src { width: 100px; }
}
@media (max-width: 900px) {
  .app { height: auto; min-height: 100dvh; padding: 10px 12px calc(20px + env(safe-area-inset-bottom)); gap: 10px; }
  .top__sub { display: none; }
  .search { width: auto; flex: 1; min-width: 0; }
  .top__brand { margin-right: 0; }
  .top__brand b { display: none; }
  #newBtn span { display: none; }
  #newBtn { width: 38px; padding: 0; }
  .board { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
  .board .tile:nth-child(-n+3) { grid-column: span 2; }
  .board .tile:nth-child(n+4) { grid-column: span 3; }
  .tile { padding: 10px 12px; }
  .tile b { font-size: 22px; }
  .tile em { display: none; }
  .filters { flex-direction: column; align-items: stretch; gap: 8px; }
  .filters__sel .ui { flex: 1; min-width: 0; width: auto; }
  .list { overflow: visible; background: none; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody { display: block; }
  .tbl tr { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name status" "phone time" "memo memo"; gap: 2px 8px; padding: 12px 14px; margin-bottom: 8px; background: #fff; border-radius: var(--r); }
  .tbl td { display: block; height: auto; padding: 0; border: 0; }
  td.c-name { grid-area: name; font-size: 15.5px; font-weight: 800; }
  td.c-status { grid-area: status; justify-self: end; }
  td.c-phone { grid-area: phone; color: var(--sub); }
  td.c-time { grid-area: time; justify-self: end; font-size: 12px; }
  td.c-memo { grid-area: memo; font-size: 12.5px; margin-top: 4px; }
  td.c-memo:empty { display: none; }
  td.c-type, td.c-visit, td.c-src, td.c-owner { display: none; }
  .layer { padding: 0; place-items: end stretch; }
  .modal, .modal--lg, .modal--md, .modal--sm { width: 100%; max-height: 92dvh; border-radius: 18px 18px 0 0; padding: 22px 16px calc(18px + env(safe-area-inset-bottom)); transform: translateY(40px); }
  .dt__body, .grid2 { grid-template-columns: 1fr; }
  .tl { contain: none; max-height: none; min-height: 0; }
  .users__add { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .modal, .layer.is-open .modal, .menu__pop, .toast, .toast.is-on { transform: none !important; }
  .toast { transform: translateX(-50%) !important; }
}
