:root {
  --bg: #f4f6f9; --card: #fff; --ink: #1f2933; --muted: #6b7280; --line: #e3e7ee;
  --brand: #c8102e; --link: #1d4ed8; --good: #15803d; --good-bg: #ecfdf3; --bad: #dc2626; --bad-bg: #fef2f2;
  --min: #fff4c2; --ours: #f5f8ff;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h1 small { font-size: 14px; font-weight: normal; margin-left: 6px; }
h3 { font-size: 15px; margin: 22px 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 12px; }
.good { color: var(--good); } .bad { color: var(--bad); }

.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 24px; background: #fff;
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.topbar .brand { color: var(--ink); font-size: 18px; white-space: nowrap; }
.topbar .brand b { color: var(--brand); }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a { padding: 6px 12px; border-radius: 6px; color: var(--ink); }
.topbar nav a.on { background: #fde8eb; color: var(--brand); font-weight: 600; }
.topbar nav a:hover { background: #f3f4f6; text-decoration: none; }

.page { max-width: 1400px; margin: 0 auto; padding: 20px 24px 60px; }
.head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.head .grow { flex: 1; }
form.inline { display: inline; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; }
.card.scroll { overflow-x: auto; padding: 0; }
.card.empty { text-align: center; color: var(--muted); padding: 30px; }
.card.maps { display: flex; gap: 22px; flex-wrap: wrap; font-size: 13px; }
.card.maps > div { display: flex; gap: 6px; align-items: baseline; }

.btn { display: inline-block; padding: 7px 14px; border-radius: 7px; border: 1px solid #cfd5df; background: #fff;
  color: var(--ink); font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #a50d26; }
.btn:disabled { opacity: .6; cursor: wait; }
select, input[type=file] { font: inherit; padding: 5px 6px; border: 1px solid #cfd5df; border-radius: 6px; background: #fff; max-width: 100%; }

.flash { padding: 9px 14px; border-radius: 8px; margin-bottom: 8px; background: #eef2ff; border: 1px solid #c7d2fe; }
.flash.ok { background: var(--good-bg); border-color: #bbf7d0; }
.flash.warn { background: #fffbeb; border-color: #fde68a; }
.flash.error { background: var(--bad-bg); border-color: #fecaca; }

table.grid { border-collapse: collapse; width: 100%; }
.grid th, .grid td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.grid th { background: #f8fafc; font-weight: 600; font-size: 12.5px; color: #374151; position: sticky; top: 0; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid td.ours, .grid th.ours { background: var(--ours); font-weight: 600; }
.grid td.min { background: var(--min); }
.grid tr.click { cursor: pointer; }
.grid tr.click:hover td { background: #fafafa; }
.grid select { width: 100%; min-width: 220px; }
.chg { font-size: 10px; color: var(--muted); margin-left: 2px; }

@media (max-width: 700px) {
  .page { padding: 14px 16px 40px; }
  .topbar { padding: 8px 16px; gap: 8px; }
}

.paper-name { display: block; font-size: 11px; font-weight: normal; color: var(--muted); white-space: normal; max-width: 150px; margin-left: auto; line-height: 1.3; }
.grid th.site-head { vertical-align: bottom; }
.grid th.ours .paper-name { color: #4b5563; }
.paper-note { display: block; font-size: 10.5px; font-weight: normal; color: #b45309; white-space: nowrap; }

/* 가격표 형식으로 보기 */
.matrix { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }
/* 모든 블록·칸을 같은 크기로: 고정 레이아웃 + colgroup 폭 */
.matrix .mblock { width: 246px; table-layout: fixed; background: #fff; border: 1px solid #9ca3af; border-collapse: collapse; flex: none; }
.matrix .mblock col.c-qty { width: 72px; }
.matrix .mblock col.c-price { width: 87px; }
.matrix .mblock td, .matrix .mblock thead tr:nth-child(3) th { overflow: hidden; text-overflow: ellipsis; padding: 4px 7px; }
.matrix .mblock th, .matrix .mblock td { border: 1px solid #c4c9d2; padding: 4px 9px; }
.matrix .mhead { text-align: center; background: var(--brand); color: #fff; font-size: 13.5px; cursor: grab; user-select: none; position: static; }
.matrix .ours-block .mhead { background: #1f2933; }
.matrix .mhead .handle { opacity: .6; margin-right: 4px; letter-spacing: -2px; }
.matrix .mpaper { text-align: center; font-weight: normal; white-space: normal; overflow-wrap: anywhere; position: static;
  height: 46px; box-sizing: border-box; font-size: 12px; line-height: 1.3; vertical-align: middle; }
.matrix .mblock tbody td { height: 26px; box-sizing: border-box; }
.matrix .mpaper .paper-note { display: block; }
.matrix thead tr:nth-child(3) th { position: static; }
.matrix td.qty { background: #f8fafc; color: #374151; }
.matrix .ours-block td:not(.qty) { background: var(--ours); font-weight: 600; }
.matrix .mblock.dragging { opacity: .4; }
.matrix .mblock.drop-before { box-shadow: -4px 0 0 var(--link); }
.matrix .mblock.drop-after { box-shadow: 4px 0 0 var(--link); }
.msection { margin: 26px 0 8px; font-size: 16px; }
.msection a { color: var(--ink); }
/* 용지 바로가기: 한 줄 막대(고정) + 펼치면 높이 제한 칩 목록 */
.jumpbar { position: sticky; top: 0; z-index: 3; background: var(--bg); display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.jumpbar select { max-width: 340px; font-size: 13px; }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.paper-jump { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 5px; max-height: 92px; overflow-y: auto; padding: 2px 0; }
.paper-jump[hidden] { display: none; }
.paper-jump a { font-size: 12px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); }
.paper-jump a:hover { border-color: var(--brand); text-decoration: none; }
.head form.inline select { max-width: 100%; }
@media (max-width: 700px) {
  .head form.inline { display: flex; flex-direction: column; gap: 6px; width: 100%; }
  .jumpbar select { max-width: 100%; flex: 1; }
}

/* 메인: 프린트시티 상품 카테고리 */
.catnav { display: flex; flex-direction: column; gap: 8px; }
.catnav-title { font-weight: 700; font-size: 13px; color: var(--muted); }
.catnav .cat { display: flex; gap: 12px; align-items: flex-start; }
.catnav .cat-name { font-weight: 700; min-width: 40px; padding-top: 4px; }
.catnav .cat-groups { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.catnav .cat-group { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.catnav .group-name { font-size: 12px; color: var(--muted); margin-right: 2px; }
.chip { display: inline-block; padding: 4px 11px; border: 1px solid var(--line); border-radius: 14px; background: #fff;
  color: var(--ink); font-size: 13px; white-space: nowrap; }
.chip:hover { border-color: var(--brand); text-decoration: none; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
/* 메인: 프린트시티 가격표 블록 */
.ourprices { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.ourprices .oblock { width: auto; background: #fff; border: 1px solid #c4c9d2; border-collapse: collapse; }
.ourprices .oblock th, .ourprices .oblock td { border: 1px solid #dfe3ea; padding: 3px 9px; position: static; }
.ourprices .ohead { background: #1f2933; color: #fff; text-align: center; white-space: normal; max-width: 260px; font-size: 12.5px; }
.ourprices td.qty { background: #f8fafc; color: #374151; }
@media (max-width: 700px) { .catnav .cat { flex-direction: column; gap: 4px; } }
.filters { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 0 0 10px; }
.filters select { max-width: 360px; }
.ourprices .osize { display: block; font-weight: normal; font-size: 11px; opacity: .8; }
.catnav .cat-tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 2px solid var(--line); margin: -4px -4px 4px; }
.catnav .cat-tab { padding: 7px 13px; color: var(--ink); font-weight: 600; font-size: 14px; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.catnav .cat-tab:hover { color: var(--brand); text-decoration: none; }
.catnav .cat-tab.on { color: var(--brand); border-bottom-color: var(--brand); }
.msection { scroll-margin-top: 56px; }
.picker { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.picker select { max-width: 260px; }
/* 상품 단위 매칭 */
.pmatch { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 10px 14px; }
.pmatch-title { font-weight: 700; font-size: 13px; color: var(--muted); margin-right: 4px; }
.pm { display: inline-flex; gap: 5px; align-items: baseline; padding: 3px 9px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 13px; }
.pm small { font-size: 11px; color: var(--muted); }
.pm.inline { padding: 0 6px; font-size: 12px; }
.pm.compared, .pmcell.compared { background: #ecfdf3; border-color: #bbf7d0; }
.pm.ready, .pmcell.ready { background: #fffbeb; border-color: #fde68a; }
.pm.wait, .pmcell.wait { background: #f8fafc; }
.pm.none { color: var(--muted); }
.sim { color: #b45309; font-weight: 700; margin-right: 2px; }
table.matches td { white-space: normal; font-size: 13px; }
table.matches td.pmcell { min-width: 120px; }
/* ±20% 근사 수량으로 대응한 칸 */
.matrix td.qty.approx { background: #fff4c2; color: #92400e; font-weight: 700; cursor: help; }
.cqty { display: block; font-size: 10.5px; color: #92400e; }
/* 경쟁사 가격 일괄 가져오기 진행 */
.fetchbox { display: inline-flex; gap: 6px; }
.fetchprog .fp-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.fetchprog .fp-bar { height: 8px; background: #eef1f5; border-radius: 4px; overflow: hidden; margin-bottom: 6px; }
.fetchprog #fp-fill { height: 100%; width: 0; background: var(--brand); transition: width .3s; }
.fetchprog #fp-err { color: var(--bad); }
