/* 색상은 한곳에서 관리 */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #667085;
  --line: #e4e7ec;
  --primary: #2f6fed;
  --primary-dark: #2458c4;
  --error-bg: #fdecec;
  --error: #b42318;
  --notice-bg: #eaf2ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--primary); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.me { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.me form { margin: 0; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
}
.card.narrow { max-width: 420px; margin: 24px auto; }
.card h1 { margin-top: 0; font-size: 22px; }

label { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
input, select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px; /* 16px 미만이면 아이폰이 입력 시 화면을 확대함 */
  background: #fff;
}

button {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: var(--primary-dark); }
button.link {
  width: auto;
  padding: 0;
  background: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 400;
}

.muted { color: var(--muted); font-size: 14px; }
.error { background: var(--error-bg); color: var(--error); padding: 10px 12px; border-radius: 8px; }
.notice { background: var(--notice-bg); padding: 10px 12px; border-radius: 8px; }

/* ───────── 3단계: 관리자 메뉴 ───────── */
.me a { text-decoration: none; }
.badge {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--error);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}
.flash { margin-top: 0; }
.page-title { font-size: 22px; margin: 0 0 12px; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a {
  padding: 10px 14px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tabs a.on { color: var(--text); font-weight: 600; border-bottom-color: var(--primary); }

.card + .card { margin-top: 16px; }
.card h2 { margin-top: 0; font-size: 18px; }

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row.inactive { opacity: 0.55; }
.row-main { flex: 1 1 220px; min-width: 0; }
.row-main div.muted, .row-main > span.muted:last-child { display: block; word-break: break-all; }
.row-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.row-edit.grow { flex: 1 1 260px; }
.row-edit input, .row-edit select { width: auto; margin-top: 0; padding: 8px 10px; }
.row-edit.grow input[type=text] { flex: 1 1 140px; min-width: 0; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.order { width: 24px; color: var(--muted); text-align: right; }
.add-form { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.add-form input[type=text] { flex: 1 1 200px; }

form.inline { display: inline; margin: 0; }
.btn-sm {
  width: auto;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}
.btn-sm:hover { background: var(--bg); }
.btn-sm.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-sm.primary:hover { background: var(--primary-dark); }
.btn-sm.danger { color: var(--error); border-color: #f3c4c0; }
.btn-sm:disabled { opacity: 0.4; cursor: default; }

.status {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  background: var(--bg);
  color: var(--muted);
}
.status-active { background: #e7f6ec; color: #1a7f37; }
.status-pending { background: #fff4e0; color: #9a6700; }
.status-suspended, .status-rejected { background: var(--error-bg); color: var(--error); }

/* ───────── 4단계: 표 ───────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 8px 10px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; white-space: nowrap; border-top: 0; }
.table { min-width: 560px; }
.table td { white-space: nowrap; }
.table td.product { white-space: normal; min-width: 180px; }
.table td.muted:last-child { white-space: normal; }
.status { white-space: nowrap; }

/* ───────── 5단계: 주문 목록과 주문 카드 ───────── */
.tabs .count { color: var(--muted); font-size: 13px; font-weight: 400; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters select, .filters input { width: auto; margin-top: 0; padding: 8px 10px; }
.filters input[type=search] { flex: 1 1 220px; }

.order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.order-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}
.order-item:hover { border-color: var(--primary); }
.oi-main { flex: 1 1 280px; min-width: 0; color: var(--text); text-decoration: none; }
.order-item:target { border-color: var(--primary); box-shadow: 0 0 0 2px var(--notice-bg); }
.oi-meta { align-items: center; }
.assign-select {
  width: auto;
  margin-top: 0;
  padding: 3px 28px 3px 10px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
}
.assign-select.unassigned { background-color: #fff4e0; border-color: #f5d9a8; color: #9a6700; }
.oi-title { font-weight: 600; }
.oi-meta { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; flex: 0 1 auto; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 13px;
  white-space: nowrap;
}
.pill.stage { background: var(--notice-bg); border-color: #cddcfb; color: var(--primary-dark); font-weight: 600; }
.pill.warn { background: #fff4e0; border-color: #f5d9a8; color: #9a6700; }
.pill.light { color: var(--muted); }
.pill.due-soon { background: #fff4e0; border-color: #f5d9a8; color: #9a6700; font-weight: 600; }
.pill.due-over { background: var(--error-bg); border-color: #f3c4c0; color: var(--error); font-weight: 600; }

.detail { display: grid; gap: 16px; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
.detail .card + .card { margin-top: 0; }
.detail-title { font-size: 20px; margin: 0 0 4px; }
.detail-form { margin-top: 16px; }
textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 16px;
  resize: vertical;
}
.form-actions { display: flex; gap: 8px; }
button.secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
button.secondary:hover { background: var(--notice-bg); }

.info { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; margin: 0 0 16px; font-size: 14px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; word-break: break-all; }

@media (max-width: 760px) {
  .detail { grid-template-columns: 1fr; }
  .oi-meta { justify-content: flex-start; }
}

/* ───────── 6단계: 알림 ───────── */
.toast-stack {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 24px));
}
.toast {
  position: relative;
  display: block;
  padding: 12px 36px 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(16, 24, 40, 0.12);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  animation: toast-in 0.2s ease-out;
}
.toast strong { display: block; margin-bottom: 2px; }
.toast-unassigned_over { border-left-color: #d29922; }
.toast-signup { border-left-color: #1a7f37; }
.toast-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  padding: 0;
  background: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 28px;
}
.toast-close:hover { background: var(--bg); }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

.inline-label { display: inline-block; margin-right: 12px; }
.inline-label input { width: 120px; }
.check-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; }
.check input { width: auto; margin: 0; }
.plain { padding-left: 18px; }
.alert-bar {
  display: block;
  padding: 10px 16px;
  background: #fff4e0;
  border-bottom: 1px solid #f5d9a8;
  color: #7a5200;
  text-decoration: none;
  font-size: 14px;
  text-align: center;
}
.alert-bar:hover { background: #ffecc7; }
