@font-face { font-family: "SungSans"; src: url("/static/fonts/SungSans-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "SungSans"; src: url("/static/fonts/SungSans-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --primary: #0f766e;
  --primary-2: #115e59;
  --primary-bg: #e6f4f2;
  --accent: #e11d48;
  --accent-bg: #fff1f3;
  --amber: #b45309;
  --amber-bg: #fef6e7;
  --radius: 8px;
  --top-h: 56px;
  --side-w: 280px;
  font-family: "SungSans", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
.boot { padding: 40px; color: var(--text-3); text-align: center; }
.hidden { display: none !important; }
.muted { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- buttons, inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 12px;
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 7px; cursor: pointer; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease; font-size: 14px; }
.btn:hover { background: var(--surface-2); border-color: #94a3b8; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--accent); border-color: #fecdd3; }
.btn.danger:hover { background: var(--accent-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #e9eef4; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; flex: none; }
.icon-btn { width: 36px; padding: 0; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span, .label { font-size: 13px; color: var(--text-2); }
.input, select.input, textarea.input { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 7px;
  background: var(--surface); outline: none; transition: border-color .15s ease, box-shadow .15s ease; }
textarea.input { height: auto; min-height: 96px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, .15); }
.input.sm { height: 32px; font-size: 14px; }
.hint { font-size: 12px; color: var(--text-3); }
.err { color: var(--accent); font-size: 13px; min-height: 18px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 30px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface);
  cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; transition: background-color .15s ease, border-color .15s ease; }
.chip:hover { border-color: #94a3b8; }
.chip.on { background: var(--primary-bg); border-color: var(--primary); color: var(--primary-2); font-weight: 700; }
.chip .n { color: var(--text-3); font-weight: 400; font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }

/* ---------- top bar */
.top { position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 17px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.brand img { width: 24px; height: 24px; }
.brand small { font-weight: 400; color: var(--text-3); font-size: 13px; }
.search { flex: 1; max-width: 560px; position: relative; }
.search input { padding-left: 34px; height: 38px; background: var(--surface-2); }
.search svg { position: absolute; left: 10px; top: 10px; width: 18px; height: 18px; color: var(--text-3); }
.search .clear { position: absolute; right: 4px; top: 4px; height: 30px; }
.top .spacer { flex: 1; }
.top-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- layout */
.layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: calc(100vh - var(--top-h)); }
.side { border-right: 1px solid var(--line); background: var(--surface); position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h));
  overflow-y: auto; padding: 14px 16px 40px; }
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.side-head h2 { font-size: 15px; margin: 0; }
.fgroup { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.fgroup:last-child { border-bottom: 0; }
.fgroup > .label { font-weight: 700; color: var(--text); font-size: 13px; }
.range { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; }
.range .tilde { color: var(--text-3); font-size: 13px; }
.range .input { min-width: 0; padding: 0 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

.main { min-width: 0; padding: 14px 20px 80px; }
.bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.count { font-size: 15px; }
.count b { font-size: 18px; }
.bar .spacer { flex: 1; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.afilter { height: 26px; padding: 0 6px 0 9px; border-radius: 6px; background: var(--primary-bg); color: var(--primary-2); font-size: 13px;
  display: inline-flex; align-items: center; gap: 4px; border: 1px solid #b7ded9; cursor: pointer; }
.afilter svg { width: 14px; height: 14px; }

.aptbar { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: thin; }
.aptbar .chip { flex: none; }
.apt-head { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.apt-head h3 { margin: 0 0 8px; font-size: 16px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.apt-head h3 small { font-weight: 400; color: var(--text-3); font-size: 13px; }

/* ---------- list: table (desktop) */
.tbl-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.tbl thead th:first-child { border-top-left-radius: var(--radius); }
.tbl thead th:last-child { border-top-right-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { position: sticky; top: var(--top-h); z-index: 5; background: var(--surface-2); text-align: left; font-weight: 700; font-size: 13px;
  color: var(--text-2); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
.tbl th.sorted { color: var(--primary-2); }
.tbl th .arrow { font-size: 11px; margin-left: 2px; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; transition: background-color .1s ease; }
.tbl tbody tr:hover { background: #f6faf9; }
.tbl .unit { font-weight: 700; white-space: nowrap; }
.tbl .sub { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.tbl .content { max-width: 360px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.tbl .nowrap { white-space: nowrap; }

/* ---------- list: cards (mobile) */
.cards { display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; }
.card .l1 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card .unit { font-weight: 700; font-size: 16px; }
.card .apt { font-size: 13px; }
.card .spacer { flex: 1; }
.card .price { margin-top: 4px; font-weight: 700; font-size: 15px; }
.card .meta { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--text-2); }
.card .content { margin-top: 6px; font-size: 13px; color: var(--text-2); white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.card .phones { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.tel { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 9px; border: 1px solid var(--line-2); border-radius: 6px;
  font-size: 13px; color: var(--text); background: var(--surface); white-space: nowrap; }
.tel svg { width: 14px; height: 14px; color: var(--primary); }
.tel.primary-tel { border-color: #9fd3cc; }
.tbl .tel { height: auto; padding: 0; border: 0; background: none; color: var(--primary-2); }
.tbl .tel svg { display: none; }

.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: 5px; font-size: 12px; font-weight: 700;
  background: #eef2f7; color: var(--text-2); white-space: nowrap; }
.tag.s-거래중 { background: var(--primary-bg); color: var(--primary-2); }
.tag.s-예정 { background: var(--amber-bg); color: var(--amber); }
.tag.s-보류 { background: #eef2f7; color: #475569; }
.tag.s-거래완료 { background: #e2e8f0; color: #334155; }
.tag.urgent { background: var(--accent-bg); color: var(--accent); }
.tag.deal { background: transparent; border: 1px solid var(--line-2); font-weight: 400; color: var(--text); }

.more { text-align: center; padding: 16px; color: var(--text-3); }
.empty { background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 40px 20px; text-align: center; color: var(--text-3); }

/* ---------- dialogs */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(15, 23, 42, .4); display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; }
.dialog { background: var(--surface); border-radius: 10px; width: 100%; max-width: 760px; box-shadow: 0 2px 8px rgba(0,0,0,.08); border: 1px solid var(--line);
  display: flex; flex-direction: column; max-height: calc(100vh - 80px); max-height: calc(100dvh - 80px); }
.dialog.narrow { max-width: 460px; }
.dialog.wide { max-width: 980px; }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex: none; }
.dlg-head h2 { margin: 0; font-size: 17px; flex: 1; }
.dlg-body { padding: 16px 18px; overflow-y: auto; flex: 1 1 auto; overscroll-behavior: contain; }
.dlg-foot { display: flex; gap: 8px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); flex: none; }
.dlg-foot .spacer { flex: 1; }
.section { padding: 4px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.section:last-child { border-bottom: 0; margin-bottom: 0; }
.section h3 { font-size: 14px; margin: 0 0 10px; color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 12px; }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.span4 { grid-column: 1 / -1; }
.phone-row { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: center; }
.conv { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.with-unit { position: relative; }
.with-unit .input { padding-right: 38px; }
.with-unit em { position: absolute; right: 10px; top: 9px; font-style: normal; color: var(--text-3); font-size: 13px; pointer-events: none; }
.reading { font-size: 12px; color: var(--primary-2); min-height: 16px; }
.seg { display: inline-flex; align-self: flex-start; border: 1px solid var(--line-2); border-radius: 7px; overflow: hidden; flex-wrap: wrap; }
.seg button { height: 34px; padding: 0 12px; border: 0; background: var(--surface); cursor: pointer; border-right: 1px solid var(--line-2); font-size: 14px; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--primary); color: #fff; font-weight: 700; }
.audit { font-size: 12px; color: var(--text-3); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 14px; overflow-x: auto; }
.tabs button { height: 38px; padding: 0 12px; border: 0; background: none; cursor: pointer; border-bottom: 2px solid transparent; color: var(--text-2); white-space: nowrap; }
.tabs button.on { color: var(--primary-2); border-bottom-color: var(--primary); font-weight: 700; }
.notice { border: 1px solid #f3d9a4; background: var(--amber-bg); color: #78350f; border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.notice.ok { border-color: #b7ded9; background: var(--primary-bg); color: var(--primary-2); }
.notice.bad { border-color: #fecdd3; background: var(--accent-bg); color: #9f1239; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; white-space: pre-wrap; word-break: break-all; }
.ip { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; font-weight: 700; }
.users { width: 100%; border-collapse: collapse; font-size: 14px; }
.users th, .users td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.users th { font-size: 13px; color: var(--text-2); }
.pw-box { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.batches { display: flex; flex-wrap: wrap; gap: 6px; }
.img-prev { max-width: 160px; max-height: 160px; border: 1px solid var(--line); border-radius: 6px; display: block; }
.bytes { font-size: 13px; color: var(--text-3); display: flex; gap: 8px; align-items: center; }

/* ---------- 거래내용 colour marks + editor */
.hl-red { color: #d92d20; } .hl-blue { color: #1d4ed8; } .hl-green { color: #15803d; } .hl-orange { color: #c2410c; }
.hl-red, .hl-blue, .hl-green, .hl-orange { font-weight: 700; }
.rte-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.hl-btn { height: 32px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); cursor: pointer;
  font-size: 13px; display: inline-flex; align-items: center; gap: 6px; color: var(--c, var(--text)); font-weight: 700; touch-action: manipulation; }
.hl-btn i { width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.hl-btn:hover { border-color: #94a3b8; }
.rte-bar .hint { flex-basis: 100%; }
@media (min-width: 641px) { .rte-bar .hint { flex-basis: auto; margin-left: 4px; } }
.input.rte { height: auto; min-height: 130px; padding: 8px 10px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; }
.input.rte:empty::before { content: attr(data-ph); color: var(--text-3); }

/* ---------- menu */
.menu { position: absolute; right: 12px; top: calc(var(--top-h) - 4px); z-index: 50; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.08); min-width: 220px; padding: 6px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 8px; height: 38px; padding: 0 10px; border: 0; background: none; cursor: pointer; border-radius: 6px; text-align: left; font-size: 14px; }
.menu button:hover { background: var(--surface-2); }
.menu button svg { width: 18px; height: 18px; flex: none; color: var(--text-2); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu .who { padding: 6px 10px 8px; font-size: 13px; color: var(--text-3); }

/* ---------- login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 26px 24px; }
.login h1 { font-size: 20px; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.login h1 img { width: 28px; height: 28px; }
.login p { margin: 0 0 18px; color: var(--text-3); font-size: 14px; }
.login form { display: flex; flex-direction: column; gap: 12px; }
.login .btn { height: 42px; }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 90; background: #0f172a; color: #fff; padding: 10px 16px;
  border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s ease; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }

.mobile-bar { display: none; }
.sheet-close { display: none; }
#print-area { display: none; }

/* ---------- tablet / phone */
@media (max-width: 1023px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0; z-index: 70; height: auto; border: 0; padding: 0 16px 90px; transform: none; display: none; }
  .side.open { display: block; }
  .side-head { position: sticky; top: 0; background: var(--surface); padding: 12px 0; margin: 0; border-bottom: 1px solid var(--line); z-index: 2; }
  .sheet-close { display: inline-flex; }
  .side-apply { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); display: flex; gap: 8px; }
  .side-apply .btn { flex: 1; height: 44px; }
  .main { padding: 10px 12px calc(84px + env(safe-area-inset-bottom)); }
  .mobile-bar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface);
    border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); gap: 4px; }
  .mobile-bar button { height: 48px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; color: var(--text-2); border-radius: 8px; cursor: pointer; }
  .mobile-bar button svg { width: 20px; height: 20px; }
  .mobile-bar button.primary { color: var(--primary-2); font-weight: 700; }
  .mobile-bar .badge { font-size: 11px; color: #fff; background: var(--primary); border-radius: 9px; padding: 0 6px; margin-left: 2px; }
  .desk-only { display: none !important; }
}
@media (min-width: 1024px) {
  .side-apply { display: none; }
  .mob-only { display: none !important; }
}
@media (max-width: 640px) {
  .top { gap: 8px; padding: 0 10px; }
  .brand small { display: none; }
  .brand span.full { display: none; }
  .overlay { padding: 0; align-items: stretch; }
  .dialog, .dialog.narrow, .dialog.wide { max-width: none; border-radius: 0; height: 100vh; height: 100dvh; max-height: none; border: 0; }
  .dlg-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span3 { grid-column: 1 / -1; }
  .kv { grid-template-columns: 110px 1fr; }
  .menu { right: 6px; left: 6px; }
}
@media (min-width: 641px) and (max-width: 1023px) {
  .cards { display: grid; grid-template-columns: 1fr 1fr; }
}

/* ---------- print: the current filtered list, full 거래내용, A4 landscape */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  html, body { background: #fff; }
  #app, #toast { display: none !important; }
  #print-area { display: block !important; font-size: 9.5pt; color: #000; }
  .p-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1.5pt solid #000; padding-bottom: 4pt; margin-bottom: 6pt; }
  .p-head h1 { font-size: 14pt; margin: 0; }
  .p-filters { font-size: 8.5pt; color: #333; margin-bottom: 6pt; }
  table.p { width: 100%; border-collapse: collapse; table-layout: fixed; }
  table.p th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; font-size: 8.5pt; text-align: left; }
  table.p th, table.p td { border: 0.5pt solid #888; padding: 3pt 4pt; vertical-align: top; word-break: break-all; }
  table.p tr { break-inside: avoid; page-break-inside: avoid; }
  table.p thead { display: table-header-group; }
  table.p td.c { white-space: pre-wrap; }
  .p-urgent { color: #c00; font-weight: 700; }
  .p-head h1 small { font-size: 9pt; font-weight: 400; color: #333; margin-left: 6pt; }
  table.p tr.p-group td { background: #e6e6e6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; font-weight: 700; font-size: 10.5pt; border-top: 1pt solid #000; }
  table.p tr.p-group td span { font-weight: 400; font-size: 8.5pt; margin-left: 6pt; }
  table.p td.c .hl-red, table.p td.c .hl-blue, table.p td.c .hl-green, table.p td.c .hl-orange { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .nw { white-space: nowrap; }
}
