:root {
  --bg: #f5f6f8; --panel: #ffffff; --ink: #1c2430; --muted: #6b7380; --line: #e3e6ea;
  --brand: #1f3a5f; --brand-ink: #ffffff; --accent: #b4632a; --good: #1f7a46; --bad: #b42318; --warn: #a15c00;
  --chip: #eef1f5; --mine: #fff7ec;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 12px; }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { color: var(--bad); border-color: #f0c9c5; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: #fff; min-width: 0; }
input[type=number] { text-align: right; }
.hidden { display: none !important; }

header.top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--brand); color: var(--brand-ink); flex-wrap: wrap; }
header.top .logo { font-weight: 700; letter-spacing: -.2px; }
header.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
header.top nav a { color: #cfd8e3; text-decoration: none; padding: 6px 10px; border-radius: 6px; }
header.top nav a.on { background: rgba(255,255,255,.14); color: #fff; }
header.top .who { margin-left: auto; font-size: 13px; color: #cfd8e3; display: flex; gap: 10px; align-items: center; }
header.top .who button { background: transparent; color: #cfd8e3; border-color: rgba(255,255,255,.25); padding: 3px 8px; }

main { padding: 18px 20px 60px; max-width: 1400px; margin: 0 auto; }
.bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.bar h2 { margin: 0 12px 0 0; font-size: 18px; }
.bar .grow { flex: 1; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .s { color: var(--muted); font-size: 12px; margin-top: 2px; }

.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; position: sticky; top: 0; cursor: default; }
th.sort { cursor: pointer; } th.sort:hover { color: var(--ink); }
td.num, th.num { text-align: right; }
tr.mine td { background: var(--mine); }
tr.dim td { color: #9aa1ab; }
tr.total td { font-weight: 700; background: #fafbfc; }
td.memo { white-space: normal; max-width: 360px; font-size: 12px; color: #4b5563; }
td.memo .more { color: var(--brand); cursor: pointer; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 10px; background: var(--chip); font-size: 12px; }
.chip.A { background: #e7eefb; color: #1f4fa3; } .chip.B { background: #e9f6ee; color: #1f7a46; }
.chip.C { background: #f3eefb; color: #6a3fb0; } .chip.D { background: #fdf1e5; color: #a15c00; }
.chip.warn { background: #fdecea; color: var(--bad); } .chip.ok { background: #e9f6ee; color: var(--good); }
.pos { color: var(--good); } .neg { color: var(--bad); }
.muted { color: var(--muted); }

.login { max-width: 360px; margin: 12vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.login h1 { font-size: 20px; margin: 0 0 4px; } .login p { color: var(--muted); margin: 0 0 18px; }
.login label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.login input { width: 100%; padding: 9px 10px; }
.login button { width: 100%; margin-top: 18px; padding: 10px; }
.err { color: var(--bad); font-size: 13px; margin-top: 10px; min-height: 18px; }

.modal { position: fixed; inset: 0; background: rgba(15,23,35,.45); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; z-index: 50; overflow-y: auto; }
.modal-box { background: var(--panel); border-radius: 12px; width: min(860px, 100%); padding: 18px 20px; }
.modal-box h3 { margin: 0 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 12px; }
.grid label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.grid label input, .grid label select { color: var(--ink); }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; padding: 10px 12px 12px; }
legend { font-size: 12px; font-weight: 700; color: var(--brand); padding: 0 4px; }
.calc { display: flex; gap: 18px; flex-wrap: wrap; padding: 10px 12px; background: #f7f9fb; border-radius: 8px; margin-bottom: 12px; }
.calc div { font-size: 12px; color: var(--muted); } .calc b { display: block; font-size: 17px; color: var(--ink); }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.actions .left { margin-right: auto; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1c2430; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 60; white-space: pre-line; max-width: 90vw; }
.notice { background: #fff8e6; border: 1px solid #f3dfae; color: #6b4b00; border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px; }
@media (max-width: 700px) { main { padding: 12px; } header.top { padding: 10px 12px; } .kpi .v { font-size: 18px; } }

/* ───── v1 ───── */
.small { font-size: 12px; }
.span2 { grid-column: span 2; }
.link { background: none; border: none; color: var(--brand); padding: 2px 4px; text-decoration: underline; }
.link.danger { color: var(--bad); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin: 8px 0; }
.notice.ok { background: #e9f6ee; border-color: #bfe3cc; color: #1f5f39; }
.kpi.warnk .v { color: var(--bad); } .kpi.okk .v { color: var(--good); }
.kpi.wide-kpi { grid-column: span 2; } .kpi.wide-kpi .v { font-size: 14px; font-weight: 600; display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; }
.mini { white-space: nowrap; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.tabs button { border-radius: 18px; padding: 5px 12px; }
.tabs button span { color: var(--muted); margin-left: 3px; font-variant-numeric: tabular-nums; }
.tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); } .tabs button.on span { color: #cfd8e3; }
.tabs input { margin-left: auto; min-width: 180px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 10px; }
.pcard { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid #c9d1dc; border-radius: 10px; padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.pcard:hover { border-color: #b9c3cf; }
.pcard.mine { background: var(--mine); }
.pcard.st-wait { border-left-color: #8a96a6; } .pcard.st-doing { border-left-color: var(--accent); } .pcard.st-ok { border-left-color: var(--good); }
.pcard.st-dim { opacity: .55; } .pcard.st-warn { border-left-color: var(--bad); opacity: .75; }
.pcard .row1, .pcard .row3 { display: flex; align-items: center; gap: 8px; }
.pcard .row2 { font-size: 13px; line-height: 1.5; }
.pcard .time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; min-width: 38px; }
.pcard .nm { font-size: 15px; }
.pcard .wish { color: #374151; }
.pcard .amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.grow { flex: 1; }
.badge { font-size: 11px; padding: 1px 8px; border-radius: 10px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.badge.wait { background: #eef1f5; } .badge.doing { background: #fbeee3; color: var(--accent); } .badge.ok { background: #e9f6ee; color: var(--good); } .badge.warn { background: #fdecea; color: var(--bad); }
.guide-line { font-size: 12px; background: #f6f8fb; border-radius: 6px; padding: 5px 8px; line-height: 1.5; }

.modal-box.wide { width: min(1100px, 100%); }
.detail { display: grid; grid-template-columns: 380px 1fr; gap: 18px; }
@media (max-width: 900px) { .detail { grid-template-columns: 1fr; } }
.pi-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 10px; } .pi-head h3 { margin: 0; font-size: 19px; }
.guide-box { background: #f3f7fc; border: 1px solid #dbe5f1; border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; line-height: 1.55; }
.gb-title { font-weight: 700; color: var(--brand); }
.guide-box .stat { background: #fff; border-radius: 8px; padding: 8px 10px; }
.memo-d { margin-top: 10px; font-size: 13px; } .memo-d summary { cursor: pointer; color: var(--muted); }
.memo-full { white-space: pre-wrap; background: #fafbfc; border-radius: 8px; padding: 8px 10px; margin-top: 6px; font-size: 12px; color: #4b5563; max-height: 260px; overflow: auto; }
.sec-title { font-weight: 700; color: var(--brand); margin: 2px 0 10px; }
.entry .field { margin-bottom: 12px; } .entry .field > label, .amount > label, .desk-part .field > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.entry input[name=wish], .entry input[name=memo] { width: 100%; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } @media (max-width: 600px) { .two { grid-template-columns: 1fr; } }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; } @media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.seg, .multi { display: flex; flex-wrap: wrap; gap: 5px; }
.seg button, .multi button { border-radius: 16px; padding: 5px 11px; font-size: 13px; }
.seg button.on, .multi button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.multi button.hint:not(.on) { border-style: dashed; border-color: var(--accent); color: var(--accent); }
.amount { margin-bottom: 12px; }
.amount-row { display: flex; align-items: center; gap: 10px; }
.amount input { width: 170px; text-align: right; font-variant-numeric: tabular-nums; }
.amount.big input { width: 220px; font-size: 20px; font-weight: 700; padding: 8px 10px; }
.hangul { color: var(--brand); font-weight: 600; }
.quick { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; } .quick button { padding: 3px 9px; font-size: 12px; border-radius: 14px; }
.live { display: flex; gap: 22px; flex-wrap: wrap; background: #f7f9fb; border-radius: 8px; padding: 10px 12px; margin: 6px 0 4px; }
.live div { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; } .live b { font-size: 18px; color: var(--ink); }
.desk-part { border-top: 1px dashed var(--line); margin-top: 14px; padding-top: 12px; }
.dentry { font-size: 13px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.desk-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-top: 8px; } .desk-add .amount { margin: 0; } .desk-add input[name=d_memo] { flex: 1; min-width: 160px; }
.mapping { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; margin-top: 10px; }
@media (max-width: 700px) { .kpi.wide-kpi { grid-column: span 1; } .cards { grid-template-columns: 1fr; } .tabs input { margin-left: 0; width: 100%; } }

a.btnlink { display: inline-block; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 12px; color: var(--ink); text-decoration: none; }

.fee-search input#fee-q { width: 100%; margin-bottom: 6px; }
.fee-cands { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; }
.fee-chip { text-align: left; border-radius: 8px; padding: 5px 9px; font-size: 12.5px; display: flex; gap: 6px; align-items: baseline; }
.fee-chip b { margin-left: auto; white-space: nowrap; }
.fee-chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.fee-chip .k { font-size: 10.5px; padding: 0 5px; border-radius: 6px; background: var(--chip); color: var(--muted); }
.fee-chip .k.ev { background: #e9f6ee; color: var(--good); }
.fee-chip.on .k { background: rgba(255,255,255,.2); color: #fff; }

.perm-boxes { display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: center; }
.perm-boxes .check { margin: 2px 0; }

.basebox { background: #f3f7fc; border: 1px solid #dbe5f1; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 3px; }
.basebox .bb-top { display: flex; align-items: center; gap: 8px; font-size: 14px; } .basebox .bb-top b { font-size: 18px; }
details.adj { border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; } details.adj summary { cursor: pointer; font-weight: 600; color: var(--brand); }

/* 오늘 고객 목록 (촘촘한 행) */
.plist { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.prow { display: grid; grid-template-columns: 48px minmax(130px, 1.1fr) 132px minmax(220px, 3fr) 76px 62px 128px 64px; gap: 10px; align-items: center;
  padding: 7px 12px 7px 9px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; cursor: pointer; min-height: 46px; }
.prow:last-child { border-bottom: 0; }
.prow:hover { background: #f8fafc; }
.prow.phead { position: sticky; top: 0; z-index: 1; min-height: 0; padding-top: 8px; padding-bottom: 8px; background: #f3f5f8; color: var(--muted); font-size: 12px; cursor: default; }
.prow.mine { background: var(--mine); }
.prow.st-doing { border-left-color: var(--accent); } .prow.st-ok { border-left-color: var(--good); }
.prow.st-dim { opacity: .55; } .prow.st-warn { border-left-color: var(--bad); opacity: .7; }
.prow > span { min-width: 0; }
.prow .r { text-align: right; }
.prow .time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.prow .who { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 4px; }
.prow .nm { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.prow .sub { flex-basis: 100%; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow .need { color: var(--warn); }
a.need { text-decoration: underline dotted; }
button.icon { border: 0; background: transparent; padding: 0 3px; color: var(--muted); font-size: 13px; line-height: 1; }
button.icon:hover { color: var(--brand); }
.prow .type { display: flex; gap: 4px; flex-wrap: wrap; }
.prow .wishc { display: flex; flex-direction: column; font-size: 13px; }
.prow .wish, .prow .g { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow .g { color: var(--muted); font-size: 12px; }
.prow .amt { display: flex; flex-direction: column; font-size: 13px; font-variant-numeric: tabular-nums; }
.prow .amt span { font-size: 12px; }
.prow .act { text-align: right; }
button.sm { padding: 3px 10px; font-size: 13px; }
@media (max-width: 1000px) {
  .prow.phead { display: none; }
  .prow { grid-template-columns: 40px 1fr auto auto; grid-template-areas: "time who who st" "time wishc wishc act" "time type own amt"; row-gap: 4px; padding: 9px 10px 9px 8px; }
  .prow .time { grid-area: time; align-self: start; padding-top: 2px; } .prow .who { grid-area: who; } .prow .st { grid-area: st; text-align: right; }
  .prow .act { grid-area: act; } .prow .wishc { grid-area: wishc; } .prow .type { grid-area: type; align-items: center; }
  .prow .own { grid-area: own; } .prow .own .muted { display: none; }
  .prow .amt { grid-area: amt; flex-direction: row; gap: 6px; justify-content: flex-end; align-items: baseline; }
  .prow .who .sub { flex-basis: auto; margin-left: 4px; }
}

/* 상담 지식 가이드 */
details.kb { background: #fff; border: 1px solid #dbe5f1; border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: 13px; line-height: 1.55; }
details.kb > summary { cursor: pointer; font-weight: 700; color: var(--brand); }
.kb-sum { margin: 8px 0 4px; color: #374151; }
.kb-sec { margin-top: 10px; font-size: 12px; font-weight: 700; color: var(--muted); }
.kb-sec.warn { color: var(--bad); }
.kb-prods { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.kb-prod { border-left: 3px solid #dbe5f1; padding: 2px 0 2px 8px; }
.kb-ph { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; }
.kb-price { font-size: 11px; background: var(--chip); border-radius: 10px; padding: 1px 7px; color: var(--muted); }
.kb-price.ev { background: #fbeee3; color: var(--accent); }
.kb-price b { color: var(--ink); }
.kb-desc { color: #374151; }
.kb-diff { color: var(--brand); font-size: 12px; }
.kb-list { margin: 4px 0 0; padding-left: 18px; }
.kb-list li { margin: 2px 0; }
.kb-list.warn li { color: #7a271a; }
.kb-src { margin-top: 8px; font-size: 11px; color: var(--muted); }
.kb-src a { color: var(--muted); }
.kb-edit textarea { width: 100%; min-height: 90px; font-size: 13px; line-height: 1.5; }
.kb-edit label { display: block; margin-top: 10px; font-size: 12px; color: var(--muted); }
.kb-edit input { width: 100%; }
.kb-chk { white-space: normal; font-size: 12px; max-width: 420px; line-height: 1.5; }
.kb-chk > div + div { margin-top: 4px; }
.crm-orders { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-top: 10px; font-size: 13px; }
.crm-orders .co { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.crm-orders .co b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.crm-orders .co.tot { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.recon-orders { white-space: normal; max-width: 520px; line-height: 1.4; }
.report-text { width: 100%; min-height: 460px; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
