:root {
  --text: #37352f;
  --muted: #787774;
  --faint: #a5a29d;
  --line: #e9e9e7;
  --bg: #ffffff;
  --col: #f7f7f5;
  --hover: #efefed;
  --accent: #2383e2;
  --danger: #d44c47;
  --todo: #9b9a97;
  --doing: #2383e2;
  --done: #4dab9a;
  --hold: #d9730d;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.brand { font-weight: 700; letter-spacing: -0.01em; font-size: 15px; white-space: nowrap; }
.brand span { font-weight: 500; color: var(--muted); }

.btn {
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--text); border-color: var(--text); color: #fff; }
.btn.primary:hover { opacity: 0.9; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--danger); border-color: transparent; }
.btn.danger:hover { background: #fbe4e4; }

input.field, select.field, textarea.field {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  background: var(--bg);
  outline: none;
  width: 100%;
}
input.field:focus, select.field:focus, textarea.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.12); }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--col); padding: 16px; }
.login { width: 100%; max-width: 300px; display: grid; gap: 10px; text-align: center; }
.login .brand { font-size: 20px; margin-bottom: 8px; }
.login input {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; text-align: center; outline: none; background: #fff;
}
.login input:focus { border-color: var(--accent); }
.login .btn { padding: 10px; }
.error { color: var(--danger); font-size: 13px; min-height: 20px; margin: 0; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 2px; }
.tab { border: 0; background: none; padding: 5px 10px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.tab:hover { background: var(--hover); }
.tab.active { color: var(--text); background: var(--hover); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.filter { display: flex; gap: 2px; background: var(--col); border-radius: 7px; padding: 2px; }
.filter button { border: 0; background: none; padding: 3px 10px; border-radius: 5px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.filter button.active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 24px rgba(15, 15, 15, 0.1);
  padding: 4px; min-width: 150px; display: grid;
}
.menu-pop a, .menu-pop button {
  display: block; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 5px;
  color: var(--text); text-decoration: none; font-size: 13px;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--hover); }
.menu-btn { border: 0; background: none; padding: 2px; border-radius: 50%; display: grid; place-items: center; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 600; background: var(--hover); color: var(--text);
}
.avatar.kim { background: #e7f3f8; color: #1f6c9f; }
.avatar.park { background: #f6f3f9; color: #6940a5; }
.whoami { font-size: 12px; color: var(--muted); padding: 6px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; white-space: nowrap; }
.status-tabs { display: none; }

main { padding: 20px 24px 40px; }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); gap: 14px; align-items: start; overflow-x: auto; }
.column { background: var(--col); border-radius: 10px; padding: 10px; min-height: 120px; }
.column-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; font-weight: 600; font-size: 13px; }
.column-head .count { color: var(--faint); font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.todo { background: var(--todo); }
.dot.doing { background: var(--doing); }
.dot.done { background: var(--done); }
.dot.hold { background: var(--hold); }

.cards { display: grid; gap: 8px; min-height: 8px; }
.card {
  background: #fff; border-radius: var(--radius); padding: 10px 12px;
  box-shadow: 0 0 0 1px rgba(15, 15, 15, 0.06), 0 1px 2px rgba(15, 15, 15, 0.06);
  cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.card:hover { background: #fbfbfa; }
.card.dragging { opacity: 0.35; }
.card.ghost {
  position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none; margin: 0;
  box-shadow: 0 0 0 1px rgba(15, 15, 15, 0.06), 0 10px 24px rgba(15, 15, 15, 0.16);
}
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }
.card-title { font-weight: 500; word-break: break-word; padding-right: 16px; }
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.card-meta .date { margin-left: auto; color: var(--faint); }
.who { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 4px; font-size: 12px; white-space: nowrap; }
.who.kim { background: #e7f3f8; color: #1f6c9f; }
.who.park { background: #f6f3f9; color: #6940a5; }
.ai { display: inline-flex; padding: 0 5px; border-radius: 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; background: #f1f1ef; color: var(--muted); border: 1px solid var(--line); }
.wait-badge {
  margin-top: 6px; font-size: 12px; color: #6b6a67; background: #f1f1ef; border-radius: 4px; padding: 2px 7px;
  display: inline-block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wait-badge.overdue { background: #fbecdd; color: #b35d0b; }
.waiting { display: grid; gap: 4px; }
.wait-line { display: flex; align-items: center; gap: 2px; }
.wait-line.overdue .wait-on { color: #b35d0b; }
.wait-on { border: 0; outline: none; padding: 3px 4px; border-radius: 4px; flex: 1; min-width: 0; font-weight: 500; background: none; }
.wait-on:hover, .wait-on:focus { background: var(--hover); }
.wait-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; color: var(--muted); font-size: 12px; }
.wait-meta label { display: inline-flex; align-items: center; gap: 4px; }
.wait-date { border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; font-size: 12px; color: var(--text); background: #fff; }
.wait-meta .btn { padding: 3px 10px; font-size: 12px; }
.link-btn { border: 0; background: none; padding: 3px 4px; margin-left: -4px; border-radius: 4px; color: var(--faint); font-size: 13px; text-align: left; }
.link-btn:hover { background: var(--hover); color: var(--muted); }
.props { align-items: start; }
.props > .label { padding-top: 4px; }
.placeholder { height: 4px; border-radius: 2px; background: var(--accent); margin: -2px 0; }

.add-card { margin-top: 8px; width: 100%; border: 0; background: none; text-align: left; padding: 6px 6px; border-radius: 6px; color: var(--faint); }
.add-card:hover { background: var(--hover); color: var(--muted); }
.new-card { margin-top: 8px; }
.new-card input { box-shadow: 0 0 0 1px rgba(15, 15, 15, 0.06); border: 0; }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20; background: rgba(15, 15, 15, 0.35);
  display: flex; justify-content: center; align-items: flex-start; padding: 6vh 16px; overflow-y: auto;
}
.modal { background: #fff; width: 100%; max-width: 680px; border-radius: 12px; box-shadow: 0 16px 48px rgba(15, 15, 15, 0.2); padding: 28px 32px 24px; }
.modal-title { width: 100%; border: 0; outline: none; font-size: 24px; font-weight: 700; padding: 0; margin-bottom: 16px; }
.props { display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; align-items: center; font-size: 13px; margin-bottom: 18px; }
.props .label { color: var(--muted); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 3px 10px; font-size: 13px; color: var(--muted);
}
.seg button:hover { background: var(--hover); }
.seg button.on { color: var(--text); border-color: var(--text); font-weight: 600; }
.seg button.st-todo.on { color: #6b6a67; border-color: var(--todo); background: #f1f1ef; }
.seg button.st-doing.on { color: #1b6ab8; border-color: var(--doing); background: #e7f3f8; }
.seg button.st-done.on { color: #2f7f71; border-color: var(--done); background: #e9f5f1; }
.seg button.st-hold.on { color: #b35d0b; border-color: var(--hold); background: #fbecdd; }
.modal { position: relative; }
.card { position: relative; }
.card-link {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border: 0; border-radius: 5px;
  background: #fff; font-size: 12px; opacity: 0; transition: opacity 0.1s;
}
.card:hover .card-link { opacity: 1; }
.card-link:hover { background: var(--hover); }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 8px);
  background: var(--text); color: #fff; font-size: 13px; padding: 8px 14px; border-radius: 8px; z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.15s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.props .value { color: var(--text); }
.md .md-gap { height: 0.6em; }
.md .md-h { font-weight: 700; margin: 0.5em 0 0.2em; line-height: 1.4; }
.md .md-h:first-child { margin-top: 0; }
.md .md-h1 { font-size: 1.35em; }
.md .md-h2 { font-size: 1.18em; }
.md .md-h3 { font-size: 1.05em; }
.md .md-li { position: relative; padding-left: calc(var(--ind, 0) * 20px + 20px); }
.md .md-ul::before { content: '•'; position: absolute; left: calc(var(--ind, 0) * 20px + 5px); color: var(--muted); }
.md .md-ol::before { content: attr(data-n); position: absolute; left: calc(var(--ind, 0) * 20px); color: var(--muted); font-variant-numeric: tabular-nums; }
.md .md-task { display: flex; align-items: flex-start; gap: 7px; padding-left: calc(var(--ind, 0) * 20px); cursor: pointer; }
.md .md-task input { margin: 0.38em 0 0; width: 15px; height: 15px; flex: none; accent-color: var(--text); cursor: pointer; }
.md .md-task input:disabled { cursor: default; }
.md .md-task.done span { color: var(--faint); text-decoration: line-through; }
.md .md-quote { border-left: 3px solid var(--line); padding-left: 12px; color: var(--muted); }
.md code { background: var(--col); border-radius: 4px; padding: 1px 5px; font-size: 0.9em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.md pre { background: var(--col); border-radius: 6px; padding: 10px 12px; overflow-x: auto; margin: 4px 0; }
.md pre code { background: none; padding: 0; }
.md a { color: var(--accent); text-decoration: none; }
.md a:hover { text-decoration: underline; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.card-meta .tasks { font-variant-numeric: tabular-nums; }
.card-meta .tasks.all { color: var(--done); }
.modal-section { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 8px; }
.modal-section h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 10px; }
.comment { padding: 8px 0; }
.comment + .comment { border-top: 1px solid #f1f1ef; }
.comment-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--faint); }
.comment-head .del { margin-left: auto; border: 0; background: none; color: var(--faint); font-size: 12px; visibility: hidden; }
.comment:hover .del { visibility: visible; }
.comment-head .del:hover { color: var(--danger); }
.comment-text { margin-top: 3px; word-break: break-word; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; align-items: flex-start; }
.comment-form > .who { flex: none; margin-top: 8px; }
.comment-form textarea { resize: none; min-height: 36px; height: 36px; overflow: hidden; }
.comment-form .btn { white-space: nowrap; height: 36px; }
.empty { color: var(--faint); font-size: 13px; padding: 4px 0; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
.saved { font-size: 12px; color: var(--faint); }

.form { display: grid; gap: 12px; }
.form h2 { margin: 0 0 4px; font-size: 18px; }
.form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin-top: -4px; cursor: pointer; }
.form label.check input { margin: 0; accent-color: var(--text); }
input.field:disabled { background: var(--col); color: var(--faint); }
.variable { font-size: 13px; color: var(--muted); }

/* ---------- subscriptions ---------- */
.subs { max-width: 880px; }
.subs-head { display: flex; align-items: flex-end; gap: 24px; margin-bottom: 16px; flex-wrap: wrap; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.subs-head .btn { margin-left: auto; }
.sub-list { border-top: 1px solid var(--line); }
.sub-row {
  display: grid; grid-template-columns: 1.6fr 1fr 1.1fr 0.7fr 1.4fr; gap: 12px; align-items: center;
  padding: 11px 6px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.sub-row:hover { background: #fbfbfa; }
.sub-row.head { cursor: default; font-size: 12px; color: var(--muted); padding: 8px 6px; }
.sub-row.head:hover { background: none; }
.sub-name { font-weight: 500; }
.sub-price { font-variant-numeric: tabular-nums; }
.sub-sub { display: none; }
.sub-memo { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dday { font-size: 12px; padding: 1px 7px; border-radius: 4px; background: var(--col); color: var(--muted); justify-self: start; white-space: nowrap; }
.dday.soon { background: #fbecdd; color: #b35d0b; }

/* ---------- expenses ---------- */
.month-nav { display: flex; align-items: center; gap: 4px; margin-bottom: 14px; }
.month-nav .month { font-size: 17px; font-weight: 700; min-width: 112px; text-align: center; }
.month-nav .btn { font-size: 18px; padding: 2px 10px; }
.month-nav .btn.today { font-size: 13px; padding: 5px 10px; }
.cats { display: grid; gap: 6px; margin: 4px 0 18px; }
.cat { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.cat-name { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-bar { height: 6px; background: var(--col); border-radius: 3px; overflow: hidden; }
.cat-bar span { display: block; height: 100%; background: var(--text); opacity: 0.55; border-radius: 3px; }
.cat-sum { font-variant-numeric: tabular-nums; text-align: right; }
.exp-list { border-top: 1px solid var(--line); }
.exp-date { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); padding: 14px 6px 6px; font-variant-numeric: tabular-nums; }
.exp-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  padding: 10px 6px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.exp-row:hover { background: #fbfbfa; }
.exp-main { display: grid; gap: 1px; min-width: 0; }
.exp-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-sub { font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-sub:empty { display: none; }
.exp-amount { font-variant-numeric: tabular-nums; font-weight: 500; text-align: right; min-width: 90px; }
.form .seg { margin-top: 2px; }
.form .seg button { padding: 6px 14px; font-size: 14px; }

/* ---------- card peek: 노션 가운데 보기 (상단 바 고정, 내용만 스크롤, 전체 화면 전환) ---------- */
.overlay.peek { padding: 48px 24px; align-items: center; overflow: hidden; }
.modal.card-modal {
  display: flex; flex-direction: column; padding: 0; max-width: 920px; overflow: hidden;
  height: min(940px, calc(100vh - 96px)); height: min(940px, calc(100dvh - 96px));
}
.overlay.full { padding: 0; }
.overlay.full .modal.card-modal { max-width: none; height: 100vh; height: 100dvh; border-radius: 0; box-shadow: none; }
.modal-bar { flex: none; display: flex; align-items: center; gap: 2px; padding: 8px 10px; }
.bar-space { flex: 1; }
.bar-btn { border: 0; background: none; color: var(--muted); border-radius: 6px; height: 30px; padding: 0 8px; font-size: 13px; white-space: nowrap; }
.bar-btn:hover { background: var(--hover); color: var(--text); }
.bar-btn.danger:hover { background: #fbe4e4; color: var(--danger); }
.full-btn { width: 32px; padding: 0; font-size: 16px; }
.modal-bar .saved { margin-right: 6px; }
.modal-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.modal-inner { max-width: 760px; margin: 0 auto; padding: 4px 56px 96px; }
.overlay.full .modal-inner { padding-top: 40px; }
.card-modal .modal-title { font-size: 30px; line-height: 1.25; margin: 6px 0 18px; padding-right: 0; }
.modal-section.comments { padding: 12px 0 16px; margin-top: 6px; }
.more-comments { margin: 0 0 2px; font-size: 12px; }

/* ---------- 블록 에디터 ---------- */
.blocks-wrap { border-top: 1px solid var(--line); padding-top: 14px; min-height: 220px; cursor: text; }
.blocks { font-size: 15px; cursor: auto; }
.blk { display: flex; align-items: flex-start; margin-left: calc(var(--ind, 0) * 24px); padding: 1px 0; }
.blk-text {
  flex: 1; min-width: 0; outline: none; padding: 3px 2px; line-height: 1.6; min-height: 1.6em;
  white-space: pre-wrap; word-break: break-word; caret-color: var(--text);
}
.blk-text:empty::before { content: attr(data-ph); color: #c4c3bf; pointer-events: none; display: none; }
.blk-text:focus:empty::before { display: inline; }
.blocks.is-empty .blk-text:empty::before { display: inline; content: "내용을 입력하거나 '/'로 블록을 추가하세요"; }
.blk-h1 .blk-text { font-size: 1.75em; font-weight: 700; line-height: 1.3; }
.blk-h2 .blk-text { font-size: 1.4em; font-weight: 700; line-height: 1.3; }
.blk-h3 .blk-text { font-size: 1.17em; font-weight: 700; line-height: 1.35; }
.blk-h1:not(:first-child) { margin-top: 1.1em; }
.blk-h2:not(:first-child) { margin-top: 0.9em; }
.blk-h3:not(:first-child) { margin-top: 0.6em; }
.blk-ul::before { content: '•'; flex: none; width: 24px; text-align: center; font-size: 1.25em; line-height: 1.35; padding-top: 3px; }
.blk-ol::before { content: attr(data-n); flex: none; min-width: 24px; padding: 3px 5px 0 0; text-align: right; line-height: 1.6; font-variant-numeric: tabular-nums; }
.blk-todo input { flex: none; width: 16px; height: 16px; margin: 6px 7px 0 4px; accent-color: #2383e2; cursor: pointer; }
.blk-todo.checked .blk-text { color: #a5a29d; text-decoration: line-through; text-decoration-color: #c4c3bf; }
.blk-quote .blk-text { border-left: 3px solid var(--text); padding-left: 14px; }
.blk-code .blk-text {
  background: #f7f6f3; border-radius: 6px; padding: 14px 16px; margin: 4px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.6; tab-size: 2;
}
.blk-hr { display: block; padding: 10px 2px; outline: none; }
.blk-hr hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
.blk-hr:focus hr { border-top-color: var(--accent); }
.blk-text strong { font-weight: 650; }
.blk-text a { color: inherit; text-decoration: underline; text-decoration-color: rgba(55, 53, 47, 0.4); text-underline-offset: 2px; }
.blk-text code { background: rgba(135, 131, 120, 0.15); color: #eb5757; border-radius: 4px; padding: 0.15em 0.35em; font-size: 0.86em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.blk-text del { color: var(--faint); }

.slash-menu {
  position: fixed; z-index: 60; width: 240px; max-height: 320px; overflow-y: auto; padding: 6px;
  background: #fff; border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(15, 15, 15, 0.05), 0 3px 6px rgba(15, 15, 15, 0.1), 0 9px 24px rgba(15, 15, 15, 0.2);
}
.slash-title { font-size: 11px; color: var(--muted); padding: 4px 8px 6px; }
.slash-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 4px 8px; border-radius: 5px; text-align: left; font-size: 14px; color: var(--text); }
.slash-item.sel { background: var(--hover); }
.slash-icon {
  flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 5px;
  border: 1px solid var(--line); background: #fff; font-size: 12px; font-weight: 600; color: var(--muted);
}
.slash-empty { padding: 6px 8px; color: var(--faint); font-size: 13px; }

/* ---------- 청구서 ---------- */
.inv-tabs { margin-bottom: 16px; }
.notice { background: #fbf3db; color: #7a5b13; border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }
.notice .link-btn { color: #7a5b13; font-weight: 600; }
.inv-row {
  display: grid; grid-template-columns: 130px 1.6fr 100px 130px 80px; gap: 12px; align-items: center;
  padding: 11px 6px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.inv-row.cust { grid-template-columns: 1.4fr 1.4fr 110px; }
.inv-row:hover { background: #fbfbfa; }
.inv-row.head { cursor: default; font-size: 12px; color: var(--muted); padding: 8px 6px; }
.inv-row.head:hover { background: none; }
.inv-no { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.inv-cust { font-weight: 500; display: grid; min-width: 0; }
.inv-date { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.inv-email { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-amount { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.inv-status { justify-self: start; font-size: 12px; padding: 1px 8px; border-radius: 4px; white-space: nowrap; }
.inv-status.draft { background: #f1f1ef; color: #6b6a67; }
.inv-status.sent { background: #e7f3f8; color: #1b6ab8; }
.inv-status.paid { background: #e9f5f1; color: #2f7f71; }
.modal.invoice-modal { max-width: 760px; position: relative; }
.inv-close { position: absolute; top: 14px; right: 14px; width: 32px; font-size: 16px; }
.inv-sent { font-size: 12px; color: var(--muted); margin-top: -6px; }
.inv-label { font-size: 12px; color: var(--muted); margin-bottom: -6px; }
.inv-items { display: grid; gap: 6px; }
.inv-item { display: grid; grid-template-columns: 1fr 130px 110px 110px 28px; gap: 8px; align-items: center; }
.inv-item.head { font-size: 11px; color: var(--faint); }
.inv-item.head span:not(:first-child) { text-align: right; }
.inv-item .num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-sum { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.inv-del { border: 0; background: none; color: var(--faint); border-radius: 5px; height: 28px; }
.inv-del:hover:not(:disabled) { background: var(--hover); color: var(--danger); }
.inv-del:disabled { opacity: 0.3; cursor: default; }
.inv-items .link-btn { justify-self: start; margin-top: 2px; }
.inv-totals { display: grid; gap: 4px; margin-left: auto; width: 280px; font-size: 13px; color: var(--muted); }
.inv-totals > div { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.inv-totals .grand { border-top: 1px solid var(--text); padding-top: 8px; margin-top: 4px; color: var(--text); font-weight: 700; font-size: 15px; }
.inv-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.inv-actions-right { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.settings-form { max-width: 640px; }

@media (max-width: 760px) {
  /* iOS는 16px 미만 입력창에 포커스하면 화면을 확대한다 */
  input, select, textarea, .field { font-size: 16px !important; }
  body.modal-open { overflow: hidden; }

  .top { padding: 8px 12px 0; padding-top: max(8px, env(safe-area-inset-top)); gap: 8px; flex-wrap: wrap; }
  .top .brand { display: none; }
  .tab { padding: 6px 12px; font-size: 15px; }
  .top-right { margin-left: auto; gap: 6px; }
  .filter button { padding: 5px 10px; }
  .tab { padding: 6px 10px; }
  .menu-btn { padding: 4px; }
  .avatar { width: 30px; height: 30px; }
  .top > :not(.status-tabs) { margin-bottom: 8px; }

  .status-tabs {
    display: flex; width: calc(100% + 24px); margin: 0 -12px; padding: 0 8px;
    border-top: 1px solid var(--line); overflow-x: auto; scrollbar-width: none;
  }
  .status-tabs::-webkit-scrollbar { display: none; }
  .stab {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
    border: 0; background: none; padding: 11px 4px 10px; font-size: 14px; color: var(--muted); white-space: nowrap;
    border-bottom: 2px solid transparent; transition: background 0.15s;
  }
  .stab .count { color: var(--faint); font-size: 12px; }
  .stab.active { color: var(--text); font-weight: 600; border-bottom-color: var(--text); }
  .stab.drop { background: #e7f3f8; border-radius: 8px 8px 0 0; }

  main { padding: 12px 12px calc(40px + env(safe-area-inset-bottom)); }
  .board { display: block; overflow: visible; min-height: 60vh; }
  .column { display: none; background: none; padding: 0; min-height: 0; }
  .column.m-active { display: block; }
  .column-head { display: none; }
  .cards { gap: 10px; }
  .card { padding: 14px 14px; }
  .card-title { font-size: 15px; padding-right: 0; }
  .card:hover { background: #fff; }
  .card:active { background: #fbfbfa; }
  .add-card { margin-top: 10px; padding: 12px; font-size: 15px; text-align: center; border: 1px dashed var(--line); border-radius: 8px; }
  .new-card input { padding: 12px; }

  .overlay { padding: 0; align-items: stretch; overscroll-behavior: contain; }
  .modal {
    max-width: none; min-height: 100%; border-radius: 0; box-shadow: none;
    padding: max(16px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  }
  .card-link { display: none; }
  .modal-title { font-size: 21px; margin-top: 40px; padding-right: 0 !important; }
  .overlay.peek { padding: 0; }
  .modal.card-modal { max-width: none; min-height: 0; height: 100vh; height: 100dvh; border-radius: 0; padding: 0; box-shadow: none; }
  .modal-bar { padding: max(6px, env(safe-area-inset-top)) 6px 6px; }
  .full-btn { display: none; }
  .bar-btn { height: 36px; padding: 0 10px; font-size: 14px; }
  .modal-inner { padding: 4px 16px calc(96px + env(safe-area-inset-bottom)); }
  .card-modal .modal-title { font-size: 24px; margin: 2px 0 14px; }
  .blocks { font-size: 16px; }
  .blk-code .blk-text { font-size: 14px !important; }
  .props { grid-template-columns: 64px 1fr; gap: 10px 10px; }
  .seg button { padding: 7px 12px; font-size: 14px; }
  .wait-meta .btn { padding: 7px 12px; font-size: 13px; }
  .wait-date { padding: 6px 8px; }
  .comment-head .del { visibility: visible; }
  .comment-form { flex-wrap: wrap; }
  .comment-form > .who { display: none; }
  .comment-form textarea { flex: 1; min-height: 44px; height: 44px; padding: 10px 12px; }
  .comment-form .btn { height: 44px; padding: 0 16px; }
  .modal-foot .btn { padding: 9px 16px; }

  .subs-head { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .subs-head .btn { grid-column: 1 / -1; margin: 0; padding: 12px; font-size: 15px; }
  .stat .v { font-size: 20px; }
  .sub-row { grid-template-columns: 1fr auto auto; padding: 13px 4px; gap: 10px; }
  .sub-row > :nth-child(3), .sub-row > :nth-child(5) { display: none; }
  .sub-row.head { display: none; }
  .sub-name { display: grid; gap: 2px; min-width: 0; }
  .sub-sub { display: block; font-size: 12px; color: var(--faint); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .row { grid-template-columns: 1fr; }
  .inv-row { grid-template-columns: 1fr auto; gap: 4px 10px; }
  .inv-row.head { display: none; }
  .inv-row .inv-no { grid-column: 1; font-size: 12px; }
  .inv-row .inv-status { grid-column: 2; grid-row: 1; justify-self: end; }
  .inv-row .inv-cust { grid-column: 1; }
  .inv-row .inv-amount { grid-column: 2; grid-row: 2; }
  .inv-row .inv-date { grid-column: 1; font-size: 12px; }
  .inv-row.cust { grid-template-columns: 1fr; }
  .inv-item { grid-template-columns: 1fr 1fr 28px; }
  .inv-item > :first-child { grid-column: 1 / -1; }
  .inv-item .inv-sum { display: none; }
  .inv-item.head { display: none; }
  .inv-totals { width: 100%; }
  .inv-actions-right { width: 100%; }
  .inv-actions-right .btn { flex: 1; padding: 10px 8px; }
  .inv-close { top: max(10px, env(safe-area-inset-top)); right: 8px; width: 40px; height: 40px; }
  .invoice-modal h2 { margin-top: 36px; }
  .expenses .subs-head .stat:first-child { grid-column: 1 / -1; }
  .row.money { grid-template-columns: 1.6fr 1fr; }
  .cat { grid-template-columns: 84px 1fr auto; }
  .exp-row { padding: 12px 4px; gap: 8px; }
  .exp-amount { min-width: 0; }
  .form input[type=date] { min-height: 44px; }
  .form .field { padding: 10px 12px; }
  .form .modal-foot .btn { padding: 10px 18px; }
}
