/* 착붙 업무관리 화면 디자인
   흰색·연회색·진회색 바탕 + 포인트 색 1개(짙은 초록). 상태 배지만 색으로 구분. */
:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e4e6e9;
  --border-strong: #d0d4d9;
  --text: #1d2125;
  --text-2: #464c53;
  --muted: #6d737a;
  --faint: #a3a8ae;
  --accent: #2f5d50;
  --accent-hover: #264d42;
  --accent-soft: #e8f0ed;
  --danger: #b3412f;
  --danger-soft: #fbeae7;
  --warn: #8a5a00;
  --warn-soft: #fdf3dc;
  --info: #2b5a9e;
  --info-soft: #eaf1fb;
  --ok: #23704f;
  --ok-soft: #e6f3ec;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .04);
  --shadow-pop: 0 10px 30px rgba(16, 24, 32, .14);
  --sidebar: 212px;
  --sidebar-mini: 64px;
  --topbar: 58px;
  --tabbar: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.ic { flex-shrink: 0; display: block; }

.app { display: flex; min-height: 100vh; }

/* ── 왼쪽 메뉴 (PC) ── */
.sidebar {
  width: var(--sidebar); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; transition: width .18s;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: var(--topbar); border-bottom: 1px solid var(--border); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 800;
  display: grid; place-items: center; flex-shrink: 0; font-size: 15px;
}
.brand-text { min-width: 0; }
.brand-name { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { color: var(--muted); font-size: 12px; margin-top: -2px; }
.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 600; font-size: 14px; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a .ic { color: var(--muted); }
.nav a.active .ic { color: var(--accent); }
.sidebar-foot { border-top: 1px solid var(--border); padding: 8px 8px 8px 14px; display: flex; align-items: center; gap: 6px; }
.save-state { flex: 1; font-size: 12px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-state.error { color: var(--danger); font-weight: 700; white-space: normal; }
.collapse-btn { border: none; background: none; color: var(--muted); padding: 7px; border-radius: 6px; cursor: pointer; }
.collapse-btn:hover { background: var(--surface-2); color: var(--text); }

/* 접힌 메뉴 */
body.collapsed .sidebar { width: var(--sidebar-mini); }
body.collapsed .brand { padding: 0 16px; }
body.collapsed .brand-text, body.collapsed .nav-label, body.collapsed .save-state { display: none; }
body.collapsed .nav a { justify-content: center; padding: 10px; }
body.collapsed .sidebar-foot { padding: 8px; justify-content: center; }

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

/* ── 상단 바 ── */
.topbar {
  position: sticky; top: 0; z-index: 15; height: var(--topbar); display: flex; align-items: center; gap: 14px;
  padding: 0 24px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.crumb { display: flex; align-items: center; gap: 4px; font-size: 14px; color: var(--muted); min-width: 0; flex-shrink: 1; white-space: nowrap; overflow: hidden; }
.crumb a { color: var(--muted); }
.crumb span:last-child { color: var(--text); font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.crumb .ic { color: var(--faint); }
.topbar-title { display: none; }
.gsearch { position: relative; flex: 1; max-width: 440px; margin-left: auto; display: flex; align-items: center; }
.gsearch-ic { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.gsearch input {
  width: 100%; height: 38px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px;
  padding: 0 12px 0 36px; font-size: 14px;
}
.gsearch input:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.gsearch-close { display: none; }
.gresults {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-pop); max-height: 70vh; overflow-y: auto; z-index: 40;
}
.gresult { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.gresult:hover, .gresult.sel { background: var(--surface-2); text-decoration: none; }
.gresult:last-child { border-bottom: none; }
.gresult-main { display: flex; align-items: center; gap: 8px; }
.gresult-sub { display: block; font-size: 13px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gresult.more { color: var(--accent); font-weight: 600; font-size: 14px; }
.gresult.empty-r { color: var(--muted); font-size: 14px; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.top-btn {
  position: relative; border: none; background: none; width: 38px; height: 38px; border-radius: 8px;
  display: grid; place-items: center; color: var(--text-2); cursor: pointer;
}
.top-btn:hover { background: var(--surface-2); text-decoration: none; }
.dot-count {
  position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
}
.user-menu { position: relative; }
.user-pop {
  position: absolute; right: 0; top: calc(100% + 6px); width: 220px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 6px; z-index: 40;
}
.user-pop-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-weight: 700; display: flex; flex-direction: column; }
.user-pop a, .user-pop button {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 10px; border: none; background: none;
  border-radius: 6px; color: var(--text); font-size: 14px; cursor: pointer; text-align: left;
}
.user-pop a:hover, .user-pop button:hover { background: var(--surface-2); text-decoration: none; }
.only-mobile { display: none !important; }

.content { padding: 24px 28px 60px; max-width: 1280px; width: 100%; }
.banner { background: var(--danger-soft); color: var(--danger); padding: 10px 28px; font-weight: 600; }

h1 { font-size: 22px; margin: 0 0 2px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 10px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-sub { color: var(--muted); font-size: 14px; }

/* ── 카드 ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-head h3 { margin: 0; display: flex; align-items: center; gap: 6px; }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid > .card { margin-bottom: 0; }
.grid.stack { margin-bottom: 14px; }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 22px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* 대시보드: 오늘 할 일 */
ul.todo { list-style: none; margin: 0; padding: 0; }
ul.todo li { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
ul.todo li:last-child { border-bottom: none; }
ul.todo .pill { text-align: center; }
.todo-main { color: var(--text); min-width: 0; display: flex; flex-wrap: wrap; gap: 0 8px; align-items: baseline; }
.todo-main:hover { text-decoration: none; }
.todo-main:hover b { text-decoration: underline; }
.todo-text { flex-basis: 100%; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-act { display: flex; gap: 6px; }

/* 대시보드: 진행 숫자 줄 */
.pipe { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.pipe-cell {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  color: var(--text); display: flex; flex-direction: column; box-shadow: var(--shadow); min-width: 0;
}
.pipe-cell:hover { border-color: var(--border-strong); text-decoration: none; }
.pipe-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.pipe-cell b { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pipe-cell b small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.pipe-cell b.money { font-size: 19px; padding: 3px 0 2px; }
.pipe-sub { font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipe-cell.warn b { color: var(--danger); }

/* 대시보드: 이번 달 (순이익을 가장 크게) */
.profit-row { display: grid; grid-template-columns: 1.1fr 1fr; gap: 12px; }
.profit-main { background: var(--accent); color: #fff; border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; justify-content: center; }
.profit-main .label { font-size: 14px; opacity: .85; font-weight: 600; }
.profit-value { font-size: 32px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.25; }
.profit-value.minus { color: #ffd6cf; }
.profit-main .sub { font-size: 13px; opacity: .8; }
.profit-side { display: grid; gap: 10px; }
.mini-stats { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.mini-stats b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px;
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 8px;
  padding: 7px 14px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; color: var(--text);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: #ecc8c1; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 13px; min-height: 30px; }
.btn-contact { color: var(--accent); }
.btn-link { border: none; background: none; color: var(--accent); padding: 0; cursor: pointer; font-weight: 600; }
.icon-btn { border: none; background: none; font-size: 18px; cursor: pointer; padding: 4px 8px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── 입력 ── */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea, .input {
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 11px; background: #fff; width: 100%; min-height: 38px;
}
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.invalid input { border-color: var(--danger); }
.req { color: var(--danger); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
details.more { border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 10px; }
details.more summary { cursor: pointer; color: var(--accent); font-weight: 700; margin-bottom: 10px; }

/* ── 목록 ── */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { max-width: 340px; }
.toolbar select.input { max-width: 240px; }
table.list { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.list th, table.list td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list th { background: var(--surface-2); font-size: 12px; color: var(--muted); font-weight: 700; white-space: nowrap; }
table.list tr.row { cursor: pointer; }
table.list tr.row:hover td { background: var(--surface-2); }
table.list tr:last-child td { border-bottom: none; }
table.crm td { font-size: 14px; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.clip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clist.only-mobile-list { display: none; }

/* 휴대폰 고객 카드 */
.clist { display: flex; flex-direction: column; gap: 8px; }
.ccard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; box-shadow: var(--shadow); }
.ccard:active { background: var(--surface-2); }
.ccard-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ccard-name { font-size: 16px; }
.ccard-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ccard-work { font-size: 14px; color: var(--text-2); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccard-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.ccard-amt { font-variant-numeric: tabular-nums; }
.ccard-act { display: flex; gap: 6px; }

/* ── 상태 배지 (이름은 11개, 색은 6가지로 묶음) ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 700;
  background: #eef0f2; color: var(--text-2); white-space: nowrap; line-height: 1.5;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }
.badge.s-new { background: #eef0f2; color: #4a5059; }
.badge.s-talk, .badge.s-visit, .badge.s-quote, .badge.s-review { background: var(--info-soft); color: var(--info); }
.badge.s-contract, .badge.s-work { background: var(--ok-soft); color: var(--ok); }
.badge.s-done { background: #d9eae2; color: #1d4a35; }
.badge.s-paid { background: var(--accent); color: #fff; }
.badge.s-hold { background: var(--warn-soft); color: var(--warn); }
.badge.s-fail { background: var(--danger-soft); color: var(--danger); }
.overdue { color: var(--danger); font-weight: 700; }
.today-mark { color: var(--accent); font-weight: 700; }

.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.status-cell { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: var(--surface); }
.status-cell:hover { background: var(--surface-2); text-decoration: none; }
.status-cell b { font-size: 16px; font-variant-numeric: tabular-nums; }

ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 9px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; align-items: center; }
ul.plain li:last-child { border-bottom: none; }

/* ── 고객 상세 ── */
.detail-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.detail-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-name { font-size: 24px; font-weight: 800; margin: 0; }
.detail-meta { color: var(--muted); margin-top: 2px; }
.detail-contact { display: flex; gap: 8px; margin-top: 10px; }
.detail-actions { align-items: center; }
dl.info { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; }
dl.info dt { color: var(--muted); font-size: 13px; padding-top: 1px; }
dl.info dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.status-select { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border-strong); font-weight: 700; background: #fff; min-height: 36px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }
.timeline .t-date { color: var(--muted); font-size: 13px; }
.timeline .t-type { font-weight: 700; margin-right: 6px; }
.timeline .t-text { white-space: pre-wrap; word-break: break-word; }

/* ── 모달 ── */
dialog#modal { border: none; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog#modal::backdrop { background: rgba(20, 22, 24, .45); }
dialog#modal form { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-body p { margin: 0 0 10px; }
.warn-box { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1d2125; color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 600; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.2); }

/* ── 휴대폰 아래 메뉴·더보기 (PC에서는 숨김) ── */
.tabbar, .sheet { display: none; }

/* ═════════ 휴대폰 ═════════ */
@media (max-width: 860px) {
  body { font-size: 16px; }
  .sidebar { display: none; }
  .only-pc { display: none !important; }
  .only-mobile { display: grid !important; }

  /* 흐림 효과(backdrop-filter)를 쓰면 검색창(position: fixed)이 상단 바 안에 갇혀서 휴대폰에서는 끔 */
  .topbar { padding: env(safe-area-inset-top) 6px 0 16px; gap: 4px; height: calc(54px + env(safe-area-inset-top)); background: var(--surface); backdrop-filter: none; }
  .crumb { display: none; }
  .topbar-title { display: block; flex: 1; font-weight: 800; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top-btn { width: 44px; height: 44px; }
  .gsearch { display: none; }
  body.search-open .gsearch {
    display: flex; position: fixed; inset: 0 0 auto 0; max-width: none; margin: 0; z-index: 45; background: var(--surface);
    padding: calc(8px + env(safe-area-inset-top)) 8px 8px 12px; border-bottom: 1px solid var(--border); gap: 4px;
  }
  body.search-open .gsearch-ic { left: 23px; }
  body.search-open .gsearch input { height: 44px; font-size: 16px; }
  body.search-open .gsearch-close { display: grid; place-items: center; border: none; background: none; width: 44px; height: 44px; color: var(--text-2); flex-shrink: 0; }
  body.search-open .gresults { position: fixed; top: calc(61px + env(safe-area-inset-top)); left: 0; right: 0; bottom: 0; max-height: none; border-radius: 0; border: none; box-shadow: none; }
  body.search-open .gresult { padding: 13px 16px; }

  .content { padding: 16px 14px calc(var(--tabbar) + 28px + env(safe-area-inset-bottom)); }
  .banner { padding: 10px 16px; }
  h1 { font-size: 21px; }
  .page-head { margin-bottom: 14px; }
  #dashNew, #custNew { display: none; } /* 새 등록은 아래 [＋] 버튼으로 */

  /* 손가락으로 누르기 편한 크기 */
  .btn { min-height: 44px; padding: 9px 16px; font-size: 15px; }
  .btn-sm { min-height: 40px; padding: 7px 12px; font-size: 14px; }
  .btn-contact { min-width: 44px; }
  .field input, .field select, .field textarea, .input, .status-select { min-height: 46px; font-size: 16px; }
  .field label { font-size: 14px; }
  .check input { width: 22px; height: 22px; }
  .modal-foot .btn { flex: 1; }
  dialog#modal { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
  dialog#modal form { max-height: 92vh; }
  .modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }

  .card { padding: 14px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2.stack, .grid-3.stack { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .toolbar .input, .toolbar select.input { max-width: none; flex: 1 1 140px; }

  .pipe { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipe-cell:last-child { grid-column: 1 / -1; }
  .profit-row { grid-template-columns: 1fr; }
  .profit-value { font-size: 30px; }
  .profit-side { grid-template-columns: 1fr 1fr; }
  ul.todo li { grid-template-columns: auto 1fr; grid-template-areas: "pill main" ". act"; gap: 6px 10px; padding: 11px 0; align-items: start; }
  ul.todo .pill { grid-area: pill; justify-self: start; margin-top: 2px; }
  ul.todo .todo-act { justify-self: end; }
  ul.todo .todo-main { grid-area: main; }
  ul.todo .todo-act { grid-area: act; }

  .only-pc-table { display: none; }
  .clist.only-mobile-list { display: flex; }

  table.list.responsive thead { display: none; }
  table.list.responsive, table.list.responsive tbody, table.list.responsive tr, table.list.responsive td { display: block; width: 100%; }
  table.list.responsive tr { border-bottom: 1px solid var(--border); padding: 10px 4px; }
  table.list.responsive td { border: none; padding: 2px 10px; }
  table.list.responsive td[data-label]::before { content: attr(data-label) " · "; color: var(--muted); font-size: 12px; }
  .clip { max-width: none; white-space: normal; }
  dl.info { grid-template-columns: 96px 1fr; }
  .timeline li { grid-template-columns: 1fr auto; }
  .timeline .t-date { grid-column: 1 / -1; }
  .detail-head > div:first-child { width: 100%; }
  .detail-contact .btn { flex: 1; }
  .detail-actions { width: 100%; }
  .detail-actions .status-select { flex: 1; }

  .toast { bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px); border-top: 1px solid var(--border);
    height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: none; background: none;
    color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer;
  }
  .tab:hover { text-decoration: none; }
  .tab.active { color: var(--accent); }
  .tab-new { align-self: center; justify-self: center; width: 50px; height: 50px; border-radius: 50%; background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(47, 93, 80, .35); }

  .sheet:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 50; }
  .sheet-bg { position: absolute; inset: 0; background: rgba(20, 22, 24, .4); }
  .sheet-panel {
    position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 16px 16px 0 0;
    padding: 8px 10px calc(14px + env(safe-area-inset-bottom));
  }
  .sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 4px auto 10px; }
  .sheet-item { display: flex; align-items: center; gap: 14px; padding: 0 10px; min-height: 54px; color: var(--text); font-weight: 600; font-size: 16px; border-radius: 10px; }
  .sheet-item span { flex: 1; }
  .sheet-item .ic:last-child { color: var(--faint); }
  .sheet-item.active { color: var(--accent); background: var(--accent-soft); }
  .sheet-item:hover { text-decoration: none; }
}

/* 견적·비용·수금 */
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.plus { color: var(--accent); }
.minus { color: var(--danger); }
table.edit { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
table.edit th { font-size: 12px; color: var(--muted); text-align: left; font-weight: 700; padding: 4px 6px; border-bottom: 1px solid var(--border); }
table.edit td { padding: 4px 4px; vertical-align: middle; }
table.edit input, table.edit select { border: 1px solid var(--border); border-radius: 6px; padding: 7px 8px; width: 100%; background: #fff; min-width: 0; }
table.edit input.n { text-align: right; }
table.edit td.calc { text-align: right; font-weight: 700; white-space: nowrap; padding-right: 8px; }
table.edit .del { border: none; background: none; color: #b5b1a8; font-size: 16px; cursor: pointer; padding: 4px 6px; }
table.edit .del:hover { color: var(--danger); }
.cost-group { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.cost-group:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.cost-group-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cost-group-head b { font-size: 14px; }
.sum-table { width: 100%; border-collapse: collapse; }
.sum-table td { padding: 6px 0; border-bottom: 1px solid var(--border); }
.sum-table tr:last-child td { border-bottom: none; }
.sum-table tr.total td { font-weight: 800; font-size: 17px; border-top: 2px solid var(--text); }
.sum-table td.num { padding-left: 12px; }
.compare { width: 100%; border-collapse: collapse; }
.compare th, .compare td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.compare th { font-size: 13px; color: var(--muted); text-align: right; }
.compare th:first-child { text-align: left; }
.compare tr.total td { font-weight: 800; font-size: 16px; background: var(--accent-soft); }
.big-profit { font-size: 26px; font-weight: 800; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.pill.gray { background: #eceae5; color: #6b675f; }
.pill.red { background: var(--danger-soft); color: var(--danger); }
.stat .value.small-v { font-size: 19px; }
.stat .sub { font-size: 12px; color: var(--muted); }
.date-group { margin-bottom: 14px; }
.date-group h3 { margin-bottom: 6px; }
@media (max-width: 860px) {
  table.edit.responsive thead { display: none; }
  table.edit.responsive, table.edit.responsive tbody { display: block; }
  table.edit.responsive tr { display: grid; grid-template-columns: 1fr 1fr 32px; gap: 6px 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  table.edit.responsive td { display: block; padding: 0; grid-column: auto; }
  table.edit.responsive td.wide { grid-column: 1 / 3; }
  table.edit.responsive td:last-child { grid-column: 3; grid-row: 1; }
  table.edit.responsive td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
  table.edit.responsive td.calc { text-align: left; align-self: end; padding: 0 0 8px; }
  .compare th, .compare td { padding: 7px 4px; font-size: 14px; }
}
.toolbar label { display: flex; flex-direction: column; gap: 2px; }
.bar { height: 8px; border-radius: 4px; background: var(--accent); min-width: 2px; }
.bar.neg { background: var(--danger); }
.bar-cell { width: 28%; }
table.list.stats td, table.list.stats th { padding: 8px 10px; }
table.list.stats tr.total td { font-weight: 800; background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
table.list .num, table.list th.num { text-align: right; }
body.login-mode .sidebar, body.login-mode .topbar, body.login-mode .tabbar { display: none !important; }
.login-card { max-width: 380px; margin: 60px auto; }

/* ── 일정 달력 (색: 실측 파랑 · 시공 초록 · 연락 회색) ── */
:root { --ev-visit: #2b5a9e; --ev-visit-soft: #eaf1fb; --ev-work: #23704f; --ev-work-soft: #e6f3ec; --ev-contact: #6d737a; --ev-contact-soft: #eef0f2; }
.sched-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.seg { display: inline-flex; background: #eceef0; border-radius: 9px; padding: 3px; }
.seg button { border: none; background: none; padding: 6px 14px; border-radius: 7px; font-weight: 700; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 32, .1); }
.sched-nav { display: inline-flex; gap: 4px; }
.sched-nav .btn { min-width: 36px; font-size: 15px; }
.sched-title { font-size: 17px; font-weight: 800; }
.sched-legend { margin-left: auto; display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.sched-legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ev-contact); }
.dot-visit { background: var(--ev-visit); }
.dot-work { background: var(--ev-work); }
.dot-contact { background: #a3a8ae; }

/* 월 */
.mcal { padding: 0; overflow: hidden; }
.mhead { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.mhead span { padding: 8px 10px; font-size: 12px; font-weight: 700; color: var(--muted); }
.mhead .sun, .mcell.sun .mnum { color: var(--danger); }
.mhead .sat, .mcell.sat .mnum { color: var(--info); }
.mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.mcell {
  min-height: 112px; padding: 6px 6px 8px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 3px; cursor: pointer; min-width: 0; background: var(--surface); text-align: left;
}
.mcell:nth-child(7n) { border-right: none; }
.mcell:hover { background: var(--surface-2); }
.mcell.out { background: #fafbfb; }
.mcell.out .mnum { opacity: .4; }
.mnum { font-size: 13px; font-weight: 700; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.mcell.today .mnum { background: var(--accent); color: #fff !important; }
.mevs { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mdots { display: none; }
.ev {
  display: flex; gap: 4px; align-items: center; font-size: 12px; line-height: 1.35; padding: 2px 6px; border-radius: 5px;
  color: var(--ev-contact); background: var(--ev-contact-soft); white-space: nowrap; overflow: hidden; min-width: 0; border-left: 3px solid currentColor;
}
.ev:hover { text-decoration: none; filter: brightness(.97); }
.ev-visit { color: var(--ev-visit); background: var(--ev-visit-soft); }
.ev-work { color: var(--ev-work); background: var(--ev-work-soft); }
.ev.done, .wev.done { opacity: .55; }
.ev-name { overflow: hidden; text-overflow: ellipsis; font-weight: 600; color: var(--text); }
.ev-time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 11px; }
.ev-more { font-size: 11px; color: var(--muted); padding-left: 6px; font-weight: 600; }
.mpick { display: none; }

/* 주 */
.wgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.wday { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-height: 220px; display: flex; flex-direction: column; min-width: 0; box-shadow: var(--shadow); }
.wday.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.wday-head { display: flex; align-items: baseline; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text); }
.wday-head:hover { text-decoration: none; background: var(--surface-2); }
.wday-head span:first-child { font-size: 12px; color: var(--muted); font-weight: 700; }
.wday-head b { font-size: 17px; }
.wday-evs { padding: 6px; display: flex; flex-direction: column; gap: 5px; }
.wev { display: flex; flex-direction: column; padding: 6px 8px; border-radius: 7px; border-left: 3px solid currentColor; color: var(--ev-contact); background: var(--ev-contact-soft); min-width: 0; }
.wev:hover { text-decoration: none; filter: brightness(.97); }
.wev.ev-visit { color: var(--ev-visit); background: var(--ev-visit-soft); }
.wev.ev-work { color: var(--ev-work); background: var(--ev-work-soft); }
.wev-top { display: flex; justify-content: space-between; gap: 4px; font-size: 11px; font-weight: 700; }
.wev b { color: var(--text); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wev-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wempty { font-size: 12px; color: var(--faint); padding: 4px; }

/* 일 · 목록 */
ul.evlist { list-style: none; margin: 0; padding: 0; }
.evrow { display: grid; grid-template-columns: 76px 1fr auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: start; }
.evrow:last-child { border-bottom: none; }
.evrow-type { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.evrow-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.evrow-head a { color: var(--text); font-size: 15px; }
.evrow-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; font-size: 13px; color: var(--text-2); }
.evrow-meta span { display: inline-flex; align-items: center; gap: 4px; }
.evrow-meta .ic { color: var(--muted); }
.evrow-text { margin-top: 4px; font-size: 14px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.evrow-act { display: flex; gap: 6px; }

@media (max-width: 860px) {
  .sched-bar { gap: 8px; }
  .seg { width: 100%; }
  .seg button { flex: 1; min-height: 40px; font-size: 15px; }
  .sched-nav .btn { min-width: 44px; }
  .sched-title { flex: 1; text-align: right; font-size: 16px; }
  .sched-legend { display: none; }
  .mhead span { padding: 6px 0; text-align: center; }
  .mcell { min-height: 58px; padding: 4px 2px 6px; align-items: center; gap: 4px; }
  .mcell.pick { background: var(--accent-soft); }
  .mevs { display: none; }
  .mdots { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; justify-content: center; }
  .mdots small { font-size: 10px; color: var(--muted); margin-right: 2px; }
  .mdots .dot { width: 7px; height: 7px; }
  .mpick { display: block; }
  .wgrid { grid-template-columns: 1fr; gap: 8px; }
  .wday { min-height: 0; flex-direction: row; }
  .wday-head { flex-direction: column; align-items: center; justify-content: flex-start; gap: 0; border-bottom: none; border-right: 1px solid var(--border); width: 56px; flex-shrink: 0; padding: 10px 4px; }
  .wday-head b { font-size: 19px; }
  .wday-evs { flex: 1; min-width: 0; padding: 8px; }
  .wempty { padding: 8px 4px; }
  .evrow { grid-template-columns: 1fr auto; grid-template-areas: "type act" "main main"; gap: 6px 10px; }
  .evrow-type { grid-area: type; flex-direction: row; align-items: center; gap: 6px; }
  .evrow-main { grid-area: main; }
  .evrow-act { grid-area: act; }
}
