:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1b1f24;
  --muted: #6b7480;
  --line: #e2e6eb;
  --accent: #4a5bd4;
  --accent-soft: #eef0fc;
  --ok: #1f7a4d;
  --ok-soft: #e7f5ee;
  --bad: #b4321f;
  --bad-soft: #fdeeeb;
  --warn: #8a6100;
  --warn-soft: #fdf3de;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
        "Malgun Gothic", "Segoe UI", sans-serif;
}

/* ---------- 레이아웃 ---------- */
.top {
  display: flex; align-items: center; gap: 28px;
  padding: 0 24px; height: 56px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 15px; color: var(--ink); text-decoration: none; }
.top nav { display: flex; gap: 4px; }
.top nav a {
  padding: 6px 12px; border-radius: 6px; color: var(--muted);
  text-decoration: none; font-weight: 500;
}
.top nav a:hover { background: var(--bg); color: var(--ink); }
.top nav a.on { background: var(--accent-soft); color: var(--accent); }

main { max-width: 1240px; margin: 0 auto; padding: 24px; }
footer { text-align: center; color: var(--muted); padding: 24px; font-size: 12px; }

h2 { font-size: 17px; margin: 24px 0 6px; }
h3 { font-size: 14px; margin: 0 0 12px; }
main > h2:first-child { margin-top: 0; }
.hint { color: var(--muted); margin: 0 0 16px; font-size: 13px; }
.hint code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.row-between { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.row-between h2 { margin-bottom: 0; }
.actions { display: flex; gap: 8px; align-items: center; }
.actions form { margin: 0; }

/* ---------- 알림 ---------- */
.note {
  padding: 10px 14px; border-radius: var(--radius); margin: 16px 0;
  border: 1px solid transparent; font-size: 13px;
}
.note.ok  { background: var(--ok-soft);  border-color: #c6e5d6; color: var(--ok); }
.note.bad { background: var(--bad-soft); border-color: #f2cdc6; color: var(--bad); }

/* ---------- 카드 ---------- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 2px;
}
.card .n { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.card .l { font-size: 12px; color: var(--muted); }
.card.warn { background: var(--warn-soft); border-color: #f0dcae; }
.card.warn .n { color: var(--warn); }

/* ---------- 표 ---------- */
/* 좁은 화면에서 셀이 글자 단위로 접히지 않도록 표는 가로로 스크롤한다 */
.table-wrap {
  overflow-x: auto; margin: 12px 0 4px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
}
.grid {
  width: 100%; border-collapse: collapse; background: var(--panel);
  font-size: 13px; min-width: 900px;
}
.rows { min-width: 1080px; }
.grid th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--muted);
  background: #fafbfc; padding: 9px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.grid td { padding: 10px 12px; border-bottom: 1px solid #f0f2f5; vertical-align: top; }
.grid tbody tr:last-child td { border-bottom: none; }
.grid tbody tr:hover { background: #fbfcfd; }
.grid .num { text-align: right; }
.grid tr.need { background: #fffdf7; }
.grid tr.need:hover { background: #fffaee; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.small-text { font-size: 12px; color: var(--muted); }
.ellipsis { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 28px; }

.rows .addr { min-width: 260px; max-width: 320px; font-size: 12.5px; word-break: keep-all; }
.rows .zip { color: var(--muted); font-family: ui-monospace, monospace; font-size: 11px; }
.rows .msg { color: var(--warn); font-size: 11.5px; margin-top: 3px; }
.rows .opt { min-width: 190px; max-width: 240px; word-break: keep-all; }
.rows .prod {
  color: var(--muted); font-size: 11px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rows .pick { min-width: 290px; }

.tag {
  display: inline-block; padding: 1px 7px; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.item { color: var(--accent); }
.bad-text { color: var(--bad); }
.danger-text { color: var(--bad); }

.pill { padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.pill.done  { background: var(--bg); color: var(--muted); }
.pill.ready { background: var(--ok-soft); color: var(--ok); }
.pill.wait  { background: var(--warn-soft); color: var(--warn); }

/* ---------- 품목명 선택 ---------- */
.chosen { display: flex; align-items: center; gap: 8px; }
.cands { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.cand {
  border: 1px solid var(--line); background: var(--panel); cursor: pointer;
  padding: 3px 8px; border-radius: 14px; font-size: 12px; color: var(--ink);
  display: inline-flex; align-items: center; gap: 5px; font-family: inherit;
}
.cand:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.cand .sc { color: var(--muted); font-size: 10px; }
.cands .none { color: var(--muted); font-size: 12px; }
.manual { display: flex; gap: 5px; }
.manual input { flex: 1; min-width: 120px; }

/* ---------- 폼 ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin: 12px 0;
  display: flex; flex-direction: column; gap: 14px; max-width: 560px;
}
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.two .panel { max-width: none; margin: 0; }
.panel label { display: flex; flex-direction: column; gap: 5px; }
.panel label > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.panel small { color: var(--muted); font-size: 11.5px; }
.inline { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

input, select {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--panel); color: var(--ink); width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=file] { padding: 6px; font-size: 12.5px; }

.filter { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.filter input[type=search], .filter input[type=text] { width: 280px; }
.filter select { width: 150px; }
.filter .count { color: var(--muted); font-size: 12.5px; margin-left: auto; }

.btn {
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); text-decoration: none;
  display: inline-block;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: #f0cec8; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.off { pointer-events: none; opacity: 0.45; }

.link {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; font-size: 12px; color: var(--muted); text-decoration: underline;
}
.link:hover { color: var(--ink); }

.vendors { margin: 24px 0; }
.vendors summary { cursor: pointer; color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .two { grid-template-columns: 1fr; }
  .inline { grid-template-columns: 1fr; }
}

/* ---------- 발주 회차 선택 ---------- */
.choice {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin: 0; display: flex; flex-direction: column; gap: 8px;
}
.choice legend { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 4px; }
.opt-row { flex-direction: row !important; align-items: center; gap: 8px; cursor: pointer; }
.opt-row input[type=radio] { width: auto; margin: 0; }
.opt-row span { font-size: 13px; font-weight: 400; }
.opt-row code {
  background: var(--bg); padding: 1px 6px; border-radius: 4px;
  font-size: 12px; color: var(--accent);
}
