/* 이음ERP 라이선스 관리 — 먹(ink)·지면(paper)·강철(steel)·인주(seal) */
:root {
  --ink: #18202b;
  --ink-2: #3b4656;
  --muted: #6b7686;
  --paper: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #f7f6f3;
  --line: #e2dfd8;
  --line-strong: #c9c5bb;
  --steel: #1f4f82;
  --steel-soft: #e7eef6;
  --seal: #c42b1c;
  --seal-soft: #fbeceb;
  --ok: #1d6b45;
  --ok-soft: #e6f2eb;
  --warn: #9a6200;
  --warn-soft: #fdf3e1;
  --nav: #18202b;
  --nav-ink: #b9c2ce;
  --radius: 4px;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 14px/1.55 'Noto Sans KR', system-ui, -apple-system, 'Malgun Gothic', sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--steel); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* 레이아웃 */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100dvh; }
.side { background: var(--nav); color: var(--nav-ink); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100dvh; }
.brand { color: #fff; font-weight: 700; padding: 4px 10px 18px; display: flex; align-items: center; gap: 10px; }
.brand .mark { width: 28px; height: 28px; border: 2px solid var(--seal); color: var(--seal); border-radius: 3px; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: #fff; }
.brand small { display: block; color: var(--nav-ink); font-weight: 400; font-size: 11.5px; }
.side a { color: var(--nav-ink); padding: 8px 10px; border-radius: var(--radius); display: block; }
.side a:hover { background: #222c3a; text-decoration: none; color: #fff; }
.side a.on { background: #263243; color: #fff; box-shadow: inset 3px 0 0 var(--seal); }
.side .spacer { flex: 1; }
.side button.link { background: none; border: 0; color: var(--nav-ink); text-align: left; padding: 8px 10px; cursor: pointer; font: inherit; }
.side button.link:hover { color: #fff; }
.main { padding: 24px 28px 60px; min-width: 0; max-width: 1180px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* 패널 */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel > header h2 { font-size: 15px; }
.panel .body { padding: 14px 16px; }
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 2px; font-family: var(--mono); }
.stat.alert .value { color: var(--seal); }

/* 표 */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 500; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--surface-2); }
td.r, th.r { text-align: right; }
.table-wrap { overflow-x: auto; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* 배지 */
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 3px; font-size: 12px; font-weight: 500; white-space: nowrap; border: 1px solid var(--line-strong); color: var(--ink-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.seal { background: var(--seal-soft); color: var(--seal); border-color: transparent; }
.badge.steel { background: var(--steel-soft); color: var(--steel); border-color: transparent; }

/* 폼 */
label.f { display: grid; gap: 5px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
label.f .hint { font-weight: 400; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 7px 10px; min-height: 36px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--steel); outline-offset: -1px; border-color: var(--steel); }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.btn { font: inherit; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--steel); border-color: var(--steel); color: #fff; }
.btn.primary:hover { background: #193f69; }
.btn.danger { color: var(--seal); border-color: #e7b4ae; }
.btn.danger:hover { background: var(--seal-soft); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.search { max-width: 320px; }

/* 정의 목록 */
dl.dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 20px; margin: 0; }
dl.dl div { min-width: 0; }
dl.dl dt { font-size: 12px; color: var(--muted); }
dl.dl dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.code-box { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 10px 12px; }
.code-box .code { font-family: var(--mono); font-size: 17px; letter-spacing: 0.06em; font-weight: 500; flex: 1; }
.lic-text { font-family: var(--mono); font-size: 12px; word-break: break-all; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; max-height: 140px; overflow: auto; }

/* 대화상자 */
.dlg-back { position: fixed; inset: 0; background: rgb(10 16 24 / 0.5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.dlg { background: var(--surface); border-radius: 6px; width: min(560px, 100%); max-height: 90dvh; overflow: auto; box-shadow: 0 20px 50px rgb(0 0 0 / 0.25); }
.dlg header { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.dlg header h2 { font-size: 16px; }
.dlg .body { padding: 16px 18px; }
.dlg footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.x { background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }
.note { background: var(--steel-soft); color: var(--ink-2); border-radius: var(--radius); padding: 10px 12px; font-size: 13px; }
.note.warn { background: var(--warn-soft); }
.note.seal { background: var(--seal-soft); color: var(--seal); }

/* 로그인 */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login form { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; width: min(380px, 100%); padding: 28px; display: grid; gap: 14px; }
.login h1 { font-size: 19px; }
.err { color: var(--seal); font-size: 13px; min-height: 1em; }

/* 알림 */
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; }
#toast div { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / 0.2); }
#toast div.error { background: var(--seal); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .brand { padding: 4px 8px; width: 100%; }
  .side .spacer { display: none; }
  .main { padding: 16px; }
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-2, .form-grid, dl.dl { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}

/* 납품서 */
table.kv th { width: 130px; background: var(--surface-2); color: var(--ink-2); font-size: 13px; }
table.kv td, table.kv th { border: 1px solid var(--line); }
@media print {
  .side, .noprint, #toast { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  body { background: #fff; }
  .panel.sheet { border: 0; }
}

/* 수정 요청 — 첨부·상세 */
.drop { border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 16px; text-align: center; color: var(--muted); background: var(--surface); cursor: default; }
.drop.on { border-color: var(--steel); background: color-mix(in srgb, var(--steel) 6%, transparent); }
.drop .link-like { color: var(--steel); text-decoration: underline; cursor: pointer; margin: 0 2px; }
.files, .gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-top: 10px; }
.file { position: relative; display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; background: var(--surface); color: var(--ink); text-decoration: none; min-width: 0; }
.file img { width: 48px; height: 48px; object-fit: cover; border-radius: 3px; flex: none; }
.file .ext { width: 48px; height: 48px; display: grid; place-items: center; background: var(--line); border-radius: 3px; font-size: 11px; font-weight: 700; flex: none; }
.file .nm { display: grid; min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
.file .nm small { color: var(--muted); }
.file .x { position: absolute; top: 2px; right: 4px; border: 0; background: none; font-size: 16px; cursor: pointer; color: var(--muted); }
.md-body { font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; }
.md-body h4 { margin: 14px 0 4px; font-size: 14px; }
.md-body h4:first-child { margin-top: 0; }
.md-body .sp { height: 6px; }
.md-body code { background: var(--line); padding: 0 4px; border-radius: 3px; font-size: 12.5px; }
.md-body table.md { border-collapse: collapse; margin: 6px 0; font-size: 13px; }
.md-body table.md th, .md-body table.md td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.md-body hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.msg { border-left: 3px solid var(--line-strong); padding: 4px 0 4px 12px; margin-bottom: 14px; }
.msg .who { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.grid.req { align-items: start; }
#rqf .form-grid { align-items: start; }
#rqf div.f > span { font-size: 13px; color: var(--ink-2); font-weight: 500; }

/* 고객관리 — 영업 단계·수납 그래프·계약서 */
.sec-title { font-size: 16px; margin: 8px 0 12px; }
.pipe { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.pipe div { background: var(--surface-2); border-radius: var(--radius); padding: 10px 4px; text-align: center; }
.pipe b { display: block; font-size: 20px; }
.pipe span { font-size: 11.5px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; }
.bars .c { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; min-width: 0; }
.bars .b { width: 100%; max-width: 30px; background: var(--steel); border-radius: 2px 2px 0 0; min-height: 2px; }
.bars .b.cur { background: var(--seal); }
.bars span { font-size: 11px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 6px 10px; font-weight: 400; cursor: pointer; }
.chips input, label.small input[type=checkbox] { width: auto; min-height: 0; }
.calc { margin-top: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.calc span { display: block; font-size: 12px; color: var(--muted); }
.pre { white-space: pre-wrap; }
table.edit input, table.edit select { min-height: 30px; padding: 4px 8px; min-width: 90px; }
table.edit input.r { text-align: right; }
.dlg.wide { width: min(760px, 100%); }
.pad { display: block; width: 100%; height: 150px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: #fff; touch-action: none; cursor: crosshair; }
.paper { font-size: 13.5px; line-height: 1.8; max-width: 820px; margin: 0 auto; padding: 32px 36px; }
.paper h3 { text-align: center; font-size: 20px; letter-spacing: 0.3em; margin-bottom: 18px; }
.paper h4 { margin: 14px 0 2px; font-size: 13.5px; }
.paper p { margin: 0 0 4px; }
.paper .r { text-align: right; }
.paper .c { text-align: center; }
.doc-table { margin: 4px 0 8px; }
.doc-table th, .doc-table td { border: 1px solid var(--line-strong); padding: 6px 8px; background: none; color: var(--ink); font-size: 13px; }
.sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 22px; }
.sigs > div { border: 1px solid var(--line-strong); padding: 12px; min-height: 130px; }
.sigs img { height: 60px; display: block; margin-top: 8px; }
.sig-meta { font-size: 11px; color: var(--muted); }
.sig-empty { color: var(--muted); margin-top: 22px; }
.doc-hash { margin-top: 16px; font-family: var(--mono); font-size: 11px; color: var(--muted); word-break: break-all; }
@media (max-width: 860px) {
  .pipe { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .calc, .sigs { grid-template-columns: 1fr 1fr; }
  .paper { padding: 16px 4px; }
}
@media print {
  .paper { padding: 0; max-width: none; }
}
label.f { align-content: start; }
div.f { display: grid; gap: 5px; align-content: start; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.nowrap { white-space: nowrap; }
@media (max-width: 860px) { table.wide-table { min-width: 820px; } }
.addr { display: grid; gap: 6px; padding: 12px; margin-bottom: 12px; border: 1px solid var(--steel); border-radius: var(--radius); background: var(--steel-soft); }
.addr a.mono { font-size: 15px; font-weight: 600; color: var(--steel); overflow-wrap: anywhere; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.choice label { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; row-gap: 2px; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; background: var(--surface); }
.choice label:has(input:checked) { border-color: var(--steel); background: var(--steel-soft); }
.choice input { width: auto; min-height: 0; margin: 0; }
.choice .small { grid-column: 2; }
@media (max-width: 640px) { .choice { grid-template-columns: 1fr; } }
.brand .mark-img { height: 22px; width: auto; flex: none; }
.tone-warn { color: var(--warn); font-weight: 600; }
.tone-seal { color: var(--seal); font-weight: 600; }
