:root {
  --bg: #f4f5f7; --panel: #fff; --line: #e2e4e9; --text: #1f2329; --muted: #6b7280;
  --brand: #1f4fd1; --brand-d: #173da3; --ok: #127a3b; --ok-bg: #e7f6ec; --err: #b42318; --err-bg: #fdecea;
  --warn: #9a6200; --warn-bg: #fff4e0;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 16px; }
h1 small, h2 small { font-size: 12px; color: var(--muted); font-weight: normal; margin-left: 6px; }
h2 { font-size: 15px; margin: 0 0 12px; }

.top { display: flex; align-items: center; gap: 24px; background: #111827; color: #fff; padding: 0 20px; height: 52px; position: sticky; top: 0; z-index: 10; }
.top .brand { color: #fff; font-weight: bold; font-size: 15px; }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { color: #cbd5e1; padding: 6px 12px; border-radius: 6px; }
.top nav a:hover { background: #1f2937; color: #fff; text-decoration: none; }
.top nav a.on { background: #374151; color: #fff; }
.top .me { display: flex; align-items: center; gap: 8px; color: #cbd5e1; font-size: 13px; }
.top .me form { margin: 0; }
.top .me .link { color: #93c5fd; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-h h1, .panel-h h2 { margin: 0; }

.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 14px; border-radius: 6px; cursor: pointer; font: inherit; line-height: 1.3; 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: var(--brand-d); }
.btn.primary:disabled { opacity: .6; cursor: wait; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); border-color: #f3b4ae; }
.btn.danger:hover { background: var(--err-bg); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.block { display: block; width: 100%; padding: 10px; }
button.link { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font: inherit; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }

input, select, textarea { font: inherit; border: 1px solid #cfd3da; border-radius: 6px; padding: 7px 9px; background: #fff; color: var(--text); max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfd0ff; border-color: var(--brand); }
textarea { width: 100%; resize: vertical; }
.chk { display: inline-flex; align-items: center; gap: 5px; margin-right: 12px; cursor: pointer; white-space: nowrap; }
.chk input { margin: 0; }
.chk.small { font-size: 12px; color: var(--err); }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }

.login-box { max-width: 360px; margin: 10vh auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.login-box h1 { text-align: center; }
.login-box label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.login-box input { display: block; width: 100%; margin-top: 4px; padding: 10px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; color: var(--text); }
.card:hover { text-decoration: none; border-color: #b9c6ee; }
.card b { display: block; font-size: 26px; }
.card span { color: var(--muted); font-size: 13px; }
.card.warn b { color: var(--warn); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters input[name=q] { width: 260px; }

table.grid { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.grid th, .grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
.grid td.wrap { white-space: normal; min-width: 160px; }
.grid th { background: #f9fafb; font-weight: 600; color: #374151; font-size: 13px; white-space: nowrap; }
.grid tr:last-child td { border-bottom: 0; }
.grid tr.dim td { color: #9ca3af; }
.grid td.num { text-align: right; white-space: nowrap; }
.grid td.empty { text-align: center; color: var(--muted); padding: 30px; }
.grid .sub { font-size: 12px; color: var(--muted); }
.grid td.thumb img, .grid td.thumb .noimg { width: 72px; height: 54px; object-fit: cover; border-radius: 4px; display: block; }
.grid td.act { white-space: nowrap; }
.grid td.act form { display: inline; margin: 0; }
.noimg { display: flex; align-items: center; justify-content: center; background: #f3f4f6; color: #9ca3af; font-size: 12px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; }
.tag.green { background: var(--ok-bg); color: var(--ok); }
.tag.gray { background: #eef0f3; color: #6b7280; }

.pager { display: flex; gap: 4px; justify-content: center; margin-top: 16px; }
.pager a, .pager b { padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pager b { background: var(--brand); color: #fff; border-color: var(--brand); }

.carform .row { display: flex; flex-wrap: wrap; gap: 12px 16px; margin-bottom: 12px; }
.carform .f { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.carform .f.wide { flex: 1 1 100%; }
.carform .f .l { font-size: 12px; color: var(--muted); }
.carform .f select + select { margin-top: 4px; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 10px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.photo { border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 12px; }
.photo .ph { height: 110px; border-radius: 6px; overflow: hidden; background: #f3f4f6; margin-bottom: 6px; }
.photo .ph img, .photo .ph .noimg { width: 100%; height: 100%; object-fit: cover; }
.photo .ph.new { outline: 2px solid var(--brand); }
.photo .pl { font-weight: 600; margin-bottom: 4px; }
.photo input[type=file] { width: 100%; font-size: 11px; padding: 4px; }
.actions { position: sticky; bottom: 0; background: rgba(244,245,247,.95); padding: 12px 0; display: flex; gap: 8px; }
.danger-zone { margin-top: 24px; padding-top: 16px; border-top: 1px dashed #f3b4ae; display: flex; gap: 12px; align-items: center; }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .top nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .wrap { padding: 16px 12px 60px; }
  .grid { display: block; overflow-x: auto; }
  .filters input[name=q] { width: 100%; }
}

/* ---- 상담관리 / 차종코드 ---- */
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; word-break: break-all; }
.memo { background: #f9fafb; border: 1px solid var(--line); border-radius: 8px; padding: 12px; white-space: normal; word-break: break-all; }
.mt { margin-top: 18px; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs a { padding: 6px 16px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); }
.tabs a.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tabs a:hover { text-decoration: none; }
.pick { list-style: none; margin: 0 0 12px; padding: 0; max-height: 460px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.pick li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.pick li:last-child { border-bottom: 0; }
.pick li.on { background: #eef3ff; }
.pick li a:first-child, .pick li span { flex: 1; color: var(--text); }
.pick li small { color: var(--muted); }
.pick .ed { font-size: 12px; }
form.mini { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
form.mini b { flex-basis: 100%; font-size: 13px; }
form.mini input, form.mini select { flex: 1 1 120px; min-width: 0; }
form.mini input[name=orderNo] { flex: 0 0 64px; }
@media (max-width: 1000px) { .three-col, .two-col { grid-template-columns: 1fr; } }

/* 로그인: 아이디 저장 체크박스 */
.login-box label.saveid { display: flex; align-items: center; gap: 6px; margin: -2px 0 14px; color: var(--text); }
.login-box label.saveid input { display: inline-block; width: auto; margin: 0; padding: 0; }

/* 헤더: 사이트로 이동 */
.top .me .tosite { color: #fff; border: 1px solid #4b5563; border-radius: 6px; padding: 4px 10px; margin-right: 6px; }
.top .me .tosite:hover { background: #374151; text-decoration: none; }
