:root {
	--bg: #f4f6fa;
	--card: #ffffff;
	--line: #e4e8ef;
	--line-2: #eef1f6;
	--text: #1b2230;
	--muted: #6b7484;
	--primary: #2f6fed;
	--primary-weak: #eaf1ff;
	--danger: #e5484d;
	--danger-weak: #fdecec;
	--ok: #16a34a;
	--ok-weak: #e8f7ee;
	--warn-weak: #fff4e5;
	--radius: 12px;
	--shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }
body {
	margin: 0; background: var(--bg); color: var(--text);
	font: 14px/1.55 Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
	-webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 0; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 700; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.nowrap { white-space: nowrap; }
.red-text, .red { color: var(--danger); }
.blue { color: var(--primary); }
.green { color: var(--ok); }
input, select, textarea, button { font: inherit; color: inherit; }
input:focus, select:focus { outline: none; border-color: var(--primary); }
[hidden] { display: none !important; }

/* 상단 메뉴 */
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1480px; margin: 0 auto; padding: 0 20px; height: 58px; display: flex; align-items: center; gap: 24px; }
.brand { font-weight: 800; font-size: 17px; color: var(--text); white-space: nowrap; }
.brand-mark { display: inline-block; background: var(--primary); color: #fff; border-radius: 6px; padding: 0 6px; margin-right: 2px; font-size: .9em; }
.menu { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; }
.menu a { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.menu a:hover { background: var(--line-2); color: var(--text); }
.menu a.on { background: var(--primary-weak); color: var(--primary); }
.me { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.me form { margin: 0; }
.me-name { font-weight: 600; }

.page { max-width: 1480px; margin: 0 auto; padding: 24px 20px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .muted { margin-top: 4px; }
.count { color: var(--muted); }
.count strong { color: var(--text); font-size: 18px; }

/* 카드 · 버튼 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--line-2); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(.95); }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; height: 44px; }
.row-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-gap.left { justify-content: flex-start; margin-top: 6px; }

/* 입력칸 */
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld > span { font-size: 12px; font-weight: 700; color: var(--muted); }
.fld input, .fld select { height: 38px; border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; background: #fff; min-width: 0; width: 100%; }
.fld .row-gap input { width: auto; flex: 1; }
.fld.wide select { width: 100%; }
select.sm { height: 30px; border: 1px solid var(--line); border-radius: 7px; padding: 0 6px; background: #fff; font-size: 13px; }

/* 검색 */
.filter { display: grid; grid-template-columns: minmax(260px, 2fr) minmax(140px, 1fr) minmax(300px, 2fr) auto auto; gap: 14px; align-items: start; }
.filter .actions { align-self: end; }
.quick { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.chip-btn { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 2px 10px; font-size: 12px; cursor: pointer; color: var(--muted); }
.chip-btn:hover { border-color: var(--primary); color: var(--primary); }

/* 표 */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th { background: #f8f9fc; color: var(--muted); font-size: 12px; font-weight: 700; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.grid tbody tr:hover { background: #fafbfe; }
.grid .num { text-align: right; white-space: nowrap; }
.photos { white-space: nowrap; }
.photo { height: 96px; width: auto; border-radius: 8px; border: 1px solid var(--line); background: #f3f4f6; margin-right: 4px; cursor: pointer; vertical-align: middle; transition: transform .15s; }
.photo:hover { transform: scale(1.03); }
.photo.static { cursor: default; }
.photo.static:hover { transform: none; }
.photo.big { height: 150px; }
.photo.missing { width: 96px; height: 96px; opacity: .35; }
.ratios { display: grid; grid-template-columns: auto auto; gap: 0 10px; margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.ratios dt { margin: 0; }
.ratios dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.good-name { font-weight: 600; }
.price .sale { color: var(--danger); font-weight: 700; font-size: 15px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.red { background: var(--danger-weak); color: var(--danger); }
.badge.green { background: var(--ok-weak); color: var(--ok); }
.badge.gray { background: var(--line-2); color: var(--muted); }
.badge.blue { background: var(--primary-weak); color: var(--primary); }
.grid .chk { width: 36px; text-align: center; }
.grid .chk input { width: 16px; height: 16px; cursor: pointer; }
.bulk { display: flex; align-items: center; gap: 12px; margin: -4px 0 12px; flex-wrap: wrap; }
.result-list { max-height: 320px; overflow: auto; margin: 0; padding: 0; list-style: none; }
.result-list li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.result-list .mono { width: 64px; font-weight: 700; }
.modal-back { position: fixed; inset: 0; background: rgba(16, 24, 40, .35); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; padding: 20px 22px; box-shadow: 0 20px 50px rgba(0, 0, 0, .2); }
.modal h2 { margin-bottom: 4px; }
.modal .row-gap { justify-content: flex-end; margin-top: 14px; }
.empty { padding: 48px; text-align: center; color: var(--muted); }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
.pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pages a { min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--text); border: 1px solid transparent; padding: 0 8px; }
.pages a:hover { border-color: var(--line); }
.pages a.on { background: var(--primary); color: #fff; font-weight: 700; }
.size select { height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; margin-left: 6px; background: #fff; }

/* RIM 가격 */
.lot-info { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 14px; padding: 12px 14px; background: var(--primary-weak); border-radius: 10px; color: #33415c; }
.calc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.calc-grid input { text-align: right; }
table.calc { width: 100%; border-collapse: collapse; }
.calc th { text-align: left; width: 150px; padding: 9px 10px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line-2); }
.calc td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); }
.calc .expr { color: var(--muted); }
.calc .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.calc .big { font-size: 20px; }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0; }
.summary div { background: #f8f9fc; border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.summary span { color: var(--muted); font-size: 12px; }
.summary b { font-size: 17px; }
.parts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 8px; }
.part { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.part-name { font-weight: 700; margin-bottom: 4px; }
.part-price { font-size: 19px; font-weight: 800; color: var(--danger); }
.part-price small { font-size: 12px; color: var(--muted); font-weight: 500; }
.apply { display: flex; align-items: flex-end; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.apply .fld { width: 220px; }
.apply input { text-align: right; font-weight: 700; }

/* 환경설정 */
.settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 16px; align-items: start; }
.settings .card { margin: 0; }
.setting-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.setting-grid input.num-in { text-align: right; }
.setting-grid input.changed { border-color: #f59e0b; background: var(--warn-weak); }

/* 로그인 */
body.bare { display: grid; place-items: center; min-height: 100vh; }
.login-wrap { width: 100%; max-width: 380px; padding: 16px; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; box-shadow: 0 10px 30px rgba(16, 24, 40, .06); display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 22px; }
.login-card .muted { margin: -6px 0 4px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input { height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
.alert { background: var(--danger-weak); color: var(--danger); border-radius: 10px; padding: 10px 12px; font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #1b2230; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: calc(100% - 32px); white-space: pre-line; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.toast.error { background: var(--danger); }

@media (max-width: 1100px) {
	.filter { grid-template-columns: 1fr 1fr; }
	.summary, .parts { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
	.topbar-inner { gap: 12px; padding: 0 12px; }
	.me-name { display: none; }
	.page { padding: 16px 12px 40px; }
	.filter, .setting-grid, .settings { grid-template-columns: 1fr; }
	.summary, .parts { grid-template-columns: 1fr; }
}
