:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --line: #e3e7ec;
  --line-strong: #cfd6de;
  --text: #17202a;
  --text-2: #4b5866;
  --text-3: #7d8a97;
  --accent: #0e7490;
  --accent-strong: #0b5c72;
  --accent-soft: #e2f3f7;
  --minus: #c2410c;
  --minus-soft: #fff1ea;
  --plus: #166534;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --warn-soft: #fff8e6;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --font: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.minus { color: var(--minus); }
.muted { color: var(--text-3); }
.hidden { display: none !important; }

/* ── 상단 ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--accent);
  background-image: radial-gradient(circle at 30% 120%, rgba(255,255,255,.55) 0 38%, transparent 39%);
}
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-nav select {
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  padding: 6px 10px; font-weight: 600; cursor: pointer;
}
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
/* 탭이 한 줄에 안 들어가면 (app.js fitTopbar가 잼) 탭을 아랫줄로 내리고, 거기서도 넘치면 여러 줄로 감싼다 */
.topbar.stacked { flex-wrap: wrap; row-gap: 6px; }
.topbar.stacked .tabs { order: 3; flex-basis: 100%; flex-wrap: wrap; overflow: visible; }
.topbar.stacked .user-btn { margin-left: auto; }
.tab {
  border: 0; background: none; padding: 8px 14px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-strong); }

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  padding: 7px 14px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; white-space: nowrap;
}
a.btn { text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .icon-btn:focus-visible, .chip:focus-visible, .seg button:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); border-color: #f1c4c4; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  border: 0; background: none; width: 32px; height: 32px; border-radius: var(--radius-sm);
  font-size: 18px; line-height: 1; cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
kbd {
  font: 11px/1 var(--font); padding: 2px 5px; border-radius: 4px;
  border: 1px solid rgba(255,255,255,.4); opacity: .8;
}
.btn:not(.primary) kbd { border-color: var(--line-strong); }

/* ── 요약 띠 ── */
.summary {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 14px 20px 0;
}
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 16px; min-width: 150px;
}
.stat-label { font-size: 12px; color: var(--text-3); font-weight: 600; }
.stat-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ── 본문 ── */
main { padding: 14px 20px 40px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.search {
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  padding: 7px 12px; min-width: 240px;
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.table-wrap { overflow: auto; max-height: calc(100vh - 230px); border-radius: var(--radius); }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.grid th, .grid td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.grid th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2);
  font-size: 12px; font-weight: 700; color: var(--text-2); white-space: nowrap;
}
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover td { background: #f1f8fa; }
.grid tfoot td {
  position: sticky; bottom: 0; background: var(--surface-2); font-weight: 700;
  border-top: 1px solid var(--line-strong); border-bottom: 0;
}
.grid td.nowrap { white-space: nowrap; }
.grid td.memo { min-width: 220px; max-width: 360px; color: var(--text-2); }
.tag {
  display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap;
}
.tag.accent { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: #92600a; border-color: transparent; }
.followup { display: block; color: var(--accent-strong); font-size: 12px; }
.empty {
  padding: 48px 20px; text-align: center; color: var(--text-3);
}
.empty strong { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 6px; }

/* ── 서랍(입력 폼) ── */
.drawer { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 32, .32); opacity: 0; transition: opacity .15s; }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(820px, 100vw);
  background: var(--bg); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .18s ease-out;
}
.drawer.open { pointer-events: auto; }
.drawer.open .drawer-backdrop { opacity: 1; }
/* 그림자는 열렸을 때만: 닫힌 서랍 그림자가 화면 오른쪽 끝에 회색 띠로 비친다 */
.drawer.open .drawer-panel { transform: none; box-shadow: var(--shadow-lg); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 17px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px 24px; }
.drawer-foot {
  display: flex; align-items: center; gap: 8px; padding: 12px 20px;
  background: var(--surface); border-top: 1px solid var(--line);
}
.drawer-foot .grow { flex: 1; }
.totals { display: flex; gap: 18px; font-variant-numeric: tabular-nums; }
.totals div { display: flex; flex-direction: column; line-height: 1.25; }
.totals span { font-size: 11px; color: var(--text-3); font-weight: 700; }
.totals strong { font-size: 17px; }

.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 6px; margin-bottom: 12px; }
.section h3 { margin: 0 0 10px; font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.row { display: grid; gap: 10px 14px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.row.two { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > label, .field > .label { font-size: 12px; font-weight: 700; color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.req::after { content: "*"; color: var(--danger); margin-left: 2px; }
.input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
  padding: 7px 10px; min-height: 36px;
}
.field textarea { min-height: 64px; resize: vertical; }
.input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field.has-error .input, .field.has-error .seg, .field.has-error .chips, .field.has-error .combo .input { border-color: var(--danger); background: #fffafa; }
.error { font-size: 12px; color: var(--danger); min-height: 0; }
.hint { font-size: 12px; color: var(--text-3); }
.hint.ok { color: var(--plus); }

/* 버튼형 선택 */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); width: fit-content; max-width: 100%; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 14px; cursor: pointer; font-weight: 600; color: var(--text-2); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-2); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; border: 1px solid transparent; border-radius: var(--radius-sm); }
.chip {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px;
  padding: 5px 13px; cursor: pointer; font-weight: 600; color: var(--text-2);
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.add { border-style: dashed; color: var(--text-3); font-weight: 500; }

/* 콤보박스 */
.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); max-height: 264px; overflow-y: auto; padding: 4px; margin: 0; list-style: none;
}
.combo-list li { padding: 7px 10px; border-radius: 5px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.combo-list li[aria-selected="true"] { background: var(--accent-soft); }
.combo-list li .meta { color: var(--text-3); font-size: 12px; }
.combo-list li.create { color: var(--accent-strong); font-weight: 600; border-top: 1px solid var(--line); margin-top: 2px; }
.combo-list li.none { color: var(--text-3); cursor: default; }
.combo .clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--text-3); cursor: pointer; font-size: 14px; padding: 4px;
}

/* 금액 */
.amount-group { margin-bottom: 6px; }
.amount-group-title { font-size: 12px; font-weight: 700; color: var(--text-3); margin: 2px 0 6px; display: flex; align-items: center; gap: 6px; }
.amount-field .input { text-align: right; font-variant-numeric: tabular-nums; }
.amount-field.minus .input { background: var(--minus-soft); }
.amount-field .preview { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-3); min-height: 18px; }
.amount-field .preview.minus { color: var(--minus); }
.flags { display: inline-flex; gap: 3px; margin-left: auto; }
.flags .tag { font-size: 10px; padding: 0 5px; }

/* 사후 조치 */
.fu-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.fu-row {
  display: grid; gap: 8px; align-items: start;
  grid-template-columns: 128px 76px 132px minmax(160px, 1.3fr) minmax(110px, 1fr) 32px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px;
}
.fu-row .field { margin: 0; }
.fu-preview { grid-column: 1 / -1; font-size: 12px; color: var(--accent-strong); font-weight: 600; }
.fu-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }

/* 기준정보 */
.masters { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; align-items: start; }
.masters .card { padding: 14px 16px; }
.masters h3 { margin: 0 0 4px; font-size: 15px; }
.masters p.desc { margin: 0 0 10px; font-size: 12px; color: var(--text-3); }
.master-add { display: flex; gap: 6px; margin-bottom: 8px; }
.master-add .input { flex: 1; }
.master-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.master-list li { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.master-list li:last-child { border-bottom: 0; }
.master-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.master-list li.inactive .name { color: var(--text-3); text-decoration: line-through; }
.master-list .count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.master-list .input { padding: 3px 8px; min-height: 28px; }
.switch { position: relative; width: 34px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line-strong); border-radius: 999px; transition: background .12s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; background: #fff; border-radius: 50%; transition: transform .12s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 대화상자 · 알림 */
.modal { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; background: rgba(15, 23, 32, .4); padding: 16px; }
.modal.open { display: flex; }
.modal-card { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 20px 22px 16px; width: min(440px, 100%); }
.modal-card h3 { margin: 0 0 8px; font-size: 16px; }
.modal-card p { margin: 0 0 10px; color: var(--text-2); }
.modal-card ul { margin: 0 0 10px; padding-left: 18px; color: var(--text-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #1f2a35; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 14px; font-weight: 500; max-width: min(560px, 92vw);
}
.toast.error { background: var(--danger); }
.toast button { background: none; border: 0; color: #9be3f3; font-weight: 700; cursor: pointer; padding: 0; }
.goodbye { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 20px; }
.goodbye h2 { margin: 0; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  main, .summary { padding-left: 12px; padding-right: 12px; }
  .search { min-width: 0; flex: 1; }
  .fu-row { grid-template-columns: 1fr 1fr; }
  .drawer-foot { flex-wrap: wrap; }
}

/* 매출정산 */
.rule-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; }
.rule-line .steps { font-weight: 700; color: var(--text); }
.settle-store { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.settle-store .stat { min-width: 140px; padding: 8px 14px; }
.settle-store .stat-value { font-size: 16px; }
.grid.settle .num { text-align: right; }
/* 옆으로 밀어도 판매자 이름은 보이게 */
.grid.settle th:first-child, .grid.settle td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.grid.settle th:first-child, .grid.settle tfoot td:first-child { z-index: 2; background: var(--surface-2); }
.grid.settle tbody tr:hover td:first-child { background: #f1f8fa; }
.grid th .th-sub { font-weight: 600; color: var(--text-3); font-size: 11px; }
.grid td.payout { font-weight: 700; }
.grid tr.empty-row td { color: var(--text-3); }
.grid tr.empty-row { cursor: default; }
.sub-count { display: block; font-size: 11px; color: var(--text-3); }
.note { font-size: 12px; color: var(--text-3); margin: 10px 2px 0; }
.mini-check { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.rule-steps { display: flex; flex-direction: column; }
.rule-step { display: grid; grid-template-columns: 22px minmax(140px, 1fr) 150px 32px; gap: 8px; align-items: start; }
.rule-step .step-no { padding-top: 28px; font-weight: 700; color: var(--text-3); text-align: center; }
.rule-step .icon-btn { margin-top: 22px; }
.rule-step .icon-btn:disabled { opacity: .3; cursor: default; }
.rule-preview {
  font-size: 13px; color: var(--text-2); background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 8px 10px; margin-bottom: 10px; font-variant-numeric: tabular-nums;
}
.rule-history { list-style: none; margin: 0; padding: 0; }
.rule-history li { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.rule-history li:last-child { border-bottom: 0; }
.rule-history .grow { flex: 1; }

/* 연락할 고객 */
.tab-badge {
  display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; border-radius: 9px;
  background: var(--minus); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums;
}
.tag.ok { background: #e7f6ec; color: var(--plus); border-color: transparent; }
.tag.due-today { background: var(--accent); color: #fff; border-color: transparent; }
.tag.due-late { background: var(--minus-soft); color: var(--minus); border-color: transparent; }
.followup.done { color: var(--text-3); }
.seg-count { margin-left: 6px; font-size: 11px; opacity: .8; font-variant-numeric: tabular-nums; }
.tg-card {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-size: 13px; color: var(--text-2);
}
.tg-card.todo { background: var(--warn-soft); border-color: #f3dfa8; }
.tg-card .grow { flex: 1; min-width: 220px; }
.task-alert { margin-bottom: 10px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--minus-soft); color: var(--minus); font-size: 13px; font-weight: 600; }
.grid.tasks td .sub { font-size: 12px; color: var(--text-3); }
.grid.tasks td.check, .grid.tasks th.check { text-align: center; width: 48px; }
.grid.tasks td.check input { width: 18px; height: 18px; cursor: pointer; }
.grid.tasks a { color: var(--accent-strong); text-decoration: none; }
.grid.tasks .link { color: var(--accent-strong); }
.grid.tasks tr.done-row td { color: var(--text-3); }
.grid.tasks tr.done-row strong { text-decoration: line-through; font-weight: 600; }
.fu-fixed { padding: 7px 0; font-size: 13px; color: var(--text-2); }
.tg-steps { margin: 0 0 10px; padding-left: 20px; font-size: 13px; color: var(--text-2); }
.tg-steps li { margin-bottom: 4px; }
.tg-steps code, .hint code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.tg-list { list-style: none; margin: 0 0 10px; padding: 0; }
.tg-link { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 8px; }
.tg-code-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.tg-code { font-size: 26px; font-weight: 700; letter-spacing: 2px; font-variant-numeric: tabular-nums; color: var(--accent-strong); }
.tg-link .hint code { word-break: break-all; }
.tg-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; }
.tg-list .tg-row { border-bottom: 1px solid var(--line); }
.tg-list .tg-row:last-child { border-bottom: 0; }
.tg-row .grow { flex: 1; }
.tg-row.wrap { flex-wrap: wrap; }
.tg-kind-hint { margin: -4px 0 8px; }
.tg-preview { margin: 10px 0 0; padding: 10px 12px; max-height: 420px; overflow: auto; white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: inherit; font-size: 13px; line-height: 1.5; color: var(--text); }
.row-input { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-input .input { flex: 1; min-width: 160px; }
.grid.tasks td.todo { min-width: 170px; max-width: 340px; }
.grid.tasks td.memo { min-width: 120px; max-width: 220px; }
.grid.tasks td.memo .btn { margin-top: 4px; }
.memo-last { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.memo-facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0 0 12px; font-size: 13px; }
.memo-facts dt { color: var(--text-3); }
.memo-facts dd { margin: 0; color: var(--text-2); word-break: break-word; }
.memo-facts a { color: var(--accent-strong); }
.fu-memo { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; padding-top: 4px; border-top: 1px dashed var(--line); }
.fu-memo-last { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-card .memo-list { list-style: none; margin: 0 0 12px; padding: 0; max-height: 260px; overflow-y: auto; border-top: 1px solid var(--line); }
.memo-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.memo-list li.muted { color: var(--text-3); font-size: 13px; }
.memo-body { white-space: pre-wrap; word-break: break-word; }
.memo-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 2px; font-size: 12px; color: var(--text-3); }
.grid.tasks td .sub { white-space: nowrap; }

/* ── 로그인 · 사용자 ── */
[hidden] { display: none !important; }
.auth-screen { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 24px; overflow-y: auto; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 22px 18px; }
.auth-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 16px; margin-bottom: 16px; }
.auth-form h1 { font-size: 18px; margin: 0 0 12px; }
.auth-form > .error { margin: 2px 0 8px; }
.auth-form > .hint { margin: 12px 0 0; }
.auth-form > .hint.auth-intro { margin: -4px 0 14px; }
.btn.block { width: 100%; padding: 10px 14px; margin-top: 4px; }
.user-btn { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.perm-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.perm-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.perm-row:last-of-type { border-bottom: 0; }
.perm-row input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; }
.perm-row input:disabled + span { opacity: .55; }
.perm-row .hint { margin-top: 2px; }
.grid.users td .sub { font-size: 12px; color: var(--text-3); }
.grid.users tbody tr { cursor: pointer; }
.grid.users td { vertical-align: top; }
.login-log { margin-top: 22px; }
.grid.logins tbody tr { cursor: default; }
.block-title { font-size: 14px; margin: 0 2px 4px; }

/* 판매자 고르기 (매출정산 캡처용 · 방마다 실적 보고) */
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 2px 12px; max-height: 50vh; overflow-y: auto; }
.pick-row { display: flex; align-items: center; gap: 8px; padding: 6px 2px; cursor: pointer; font-size: 14px; }
.pick-row input { width: 18px; height: 18px; margin: 0; flex: none; }
.pick-all { border-bottom: 1px solid var(--line); margin-bottom: 6px; padding-bottom: 8px; font-weight: 600; }

/* 폰: 상단은 여러 줄이라 고정하지 않는다 (화면을 너무 가림). 매출정산 여섯 칸이 한 화면에 들어오게 (캡처용) */
@media (max-width: 600px) {
  .topbar { position: static; }
  .tab { padding: 7px 10px; }
  /* 표 안에서 또 세로로 밀지 않게: 페이지만 아래로 민다 (카드로 안 바꾼 표는 옆으로만) */
  .table-wrap { max-height: none; }
  /* 위 요약 네 칸이 화면 반을 차지하지 않게 두 칸씩 */
  .summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-top: 10px; }
  .summary .stat { min-width: 0; padding: 8px 12px; }
  .summary .stat-value { font-size: 16px; }
  .btn kbd { display: none; }
  /* 입력 · 날짜순 버튼은 윗줄 양끝, 검색은 아랫줄 전체 폭 */
  .list-toolbar .search { flex: 1 1 100%; order: 3; }
  /* 연락할 고객: 완료 포함 · 모두 완료는 윗줄, 검색은 아랫줄 전체 폭 */
  .task-toolbar .search { flex: 1 1 100%; order: 3; }
  .grid.settle { font-size: 11.5px; }
  .grid.settle th, .grid.settle td { padding: 7px 4px; }
  .grid.settle th:first-child, .grid.settle td:first-child { padding-left: 8px; }
  .grid.settle th:last-child, .grid.settle td:last-child { padding-right: 8px; }
}

/* 요금수납: 휴대폰으로 보면서 한 손으로 체크 (버튼을 크게) */
.fee-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.fee-title { font-size: 17px; text-align: center; }
.fee-progress { padding: 12px 14px; margin-bottom: 10px; }
.fee-progress-row { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.fee-progress-row .muted { color: var(--text-2); }
.fee-bar { height: 6px; border-radius: 3px; background: var(--line); margin-top: 8px; overflow: hidden; }
.fee-bar > div { height: 100%; background: var(--plus); border-radius: 3px; }
.fee-list { list-style: none; margin: 0; padding: 0 14px; }
.fee-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.fee-row:last-child { border-bottom: 0; }
.fee-row.done .fee-main { opacity: .6; }
.fee-main { flex: 1; min-width: 0; cursor: pointer; }
.fee-main:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.fee-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 15px; }
.fee-main .sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.fee-note { font-size: 12px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn.fee-check { min-width: 84px; min-height: 44px; font-size: 14px; flex-shrink: 0; }
.btn.fee-check.ok { background: #e7f6ec; color: var(--plus); border-color: #b9e2c6; font-size: 12px; }
.fee-hint { font-size: 13px; color: var(--plus); margin: -4px 0 8px; }
.fee-hint .warn { color: var(--minus); }
@media (max-width: 600px) {
  .fee-toolbar .search { flex: 1 1 100%; order: 3; }
  .fee-list { padding: 0 10px; }
  .fee-title { font-size: 15px; }
}

/* 폰 목록 카드 (무선 · 유선 · 쿠폰 · 마을회관): 표 대신 한 건 = 한 장, 아래로만 민다 */
.sale-cards { list-style: none; margin: 0; padding: 0; }
.sale-card { padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; overflow-wrap: anywhere; }
.sale-card:last-child { border-bottom: 0; }
.sale-card:active { background: #f1f8fa; }
.sale-card:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sale-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sale-who { min-width: 0; }
.sale-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 15px; }
.sale-card .sub { font-size: 13px; color: var(--text-2); margin-top: 2px; font-variant-numeric: tabular-nums; }
.sale-card .sub.muted { font-size: 12px; color: var(--text-3); }
.sale-amts { flex-shrink: 0; text-align: right; font-variant-numeric: tabular-nums; }
.sale-amt { font-size: 15px; font-weight: 700; white-space: nowrap; }
.sale-amt + .sale-amt { font-size: 13px; font-weight: 600; color: var(--text-2); }
.sale-amt.minus { color: var(--minus); }
.sale-amt span { margin-right: 4px; font-size: 11px; font-weight: 600; color: var(--text-3); }
.sale-card .followup { margin-top: 3px; }
.sale-memo { margin-top: 3px; font-size: 12px; color: var(--text-2); white-space: pre-wrap; }
.list-foot {
  display: flex; flex-wrap: wrap; gap: 2px 12px; padding: 10px 14px; border-top: 1px solid var(--line-strong);
  border-radius: 0 0 var(--radius) var(--radius); background: var(--surface-2); font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* 활동 기록 (관리자): 표 한 줄 = 한 일. 폰은 카드. 누르면 바뀐 것 전부 */
.activity-toolbar .activity-who { width: auto; max-width: 200px; }
.activity-toolbar .activity-day { width: auto; }
.grid.activity td { vertical-align: top; }
.grid.activity tbody tr { cursor: pointer; }
.grid.activity .sub { font-size: 12px; margin-top: 2px; }
.grid.activity .tag { margin-left: 4px; }
.grid.activity .activity-change { color: var(--text-2); max-width: 340px; overflow-wrap: anywhere; }
.grid.activity tr.fail-row td { background: #fffafa; }
.activity-foot { justify-content: space-between; align-items: center; }
.activity-cards { list-style: none; margin: 0; padding: 0; }
.activity-card { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; overflow-wrap: anywhere; font-size: 14px; }
.activity-card:last-child { border-bottom: 0; }
.activity-card.fail { background: #fffafa; }
.activity-card:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.activity-card .tag { margin-left: 4px; }
.activity-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 2px; }
.activity-card .sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.activity-card .sub.muted { color: var(--text-3); }
.activity-target { color: var(--text-2); }
.activity-detail { max-height: 50vh; overflow: auto; margin-bottom: 10px; }
@media (max-width: 600px) {
  .activity-toolbar .search { flex: 1 1 100%; order: 3; }
  /* 종류 여섯 개가 한 줄에 (좁으면 고르게 두 줄) */
  .activity-toolbar .seg { width: 100%; }
  .activity-toolbar .seg button { flex: 1 1 auto; padding: 7px 8px; }
}
.grid.activity .activity-error { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 360px; }
.grid.activity .activity-target-cell { min-width: 150px; }

/* 목록 상세검색 (무선 · 유선 · 요금수납): [상세검색] 버튼으로 접고 편다. 칸마다 한 줄 (이름 | 체크박스들), 폰은 이름이 위 */
.filter-toggle .chev { font-size: 11px; color: var(--text-3); }
.filter-toggle.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.filter-toggle.on .chev { color: inherit; }
.list-filter {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px 14px; margin: -2px 0 10px;
}
.filter-row { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: start; padding: 6px 0; border-bottom: 1px solid var(--line); }
.filter-row .filter-label { padding-top: 5px; }
.filter-row.on .filter-label { color: var(--accent-strong); }
.filter-label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.filter-dates { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-dates .input { width: auto; min-height: 32px; padding: 4px 8px; }
.filter-row[data-key="date"].on .input { border-color: var(--accent); background: var(--accent-soft); }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; min-height: 32px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 14px;
}
.check:hover { border-color: var(--accent); }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.check .n { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.check:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter-foot { display: flex; justify-content: flex-end; padding-top: 6px; min-height: 6px; }
.filter-summary {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -2px 0 10px; padding: 6px 12px;
  border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent-soft);
  color: var(--accent-strong); font-size: 13px; font-weight: 600;
}
.filter-summary span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sale-list .table-wrap { max-height: calc(100vh - 280px); }
@media (max-width: 600px) {
  /* 입력 · 상세검색 · 날짜순 버튼이 320px에서도 한 줄에 (검색은 아랫줄 전체 폭) */
  .list-toolbar { gap: 8px; }
  .list-toolbar .btn { padding-left: 10px; padding-right: 10px; }
  .list-filter { padding: 4px 12px; }
  .filter-row { grid-template-columns: 1fr; gap: 6px; }
  .filter-row .filter-label { padding-top: 0; }
  .filter-dates .input { flex: 1; min-width: 0; }
  .check { font-size: 13.5px; }
}
/* 요금수납: 상세검색 · 검색으로 거르면 '3명 (전체 60명 중)' */
.fee-count { margin: 8px 4px 0; font-size: 13px; font-weight: 600; color: var(--text-2); }
