/* ============================================================================
   reset + 공통 element + 버튼 + 폼 + 토스트
   ============================================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--navy);
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

.hidden { display: none !important; }
.muted  { color: var(--muted); }
.row    { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ─────────── 폼 ─────────── */
.form-group {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}
.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--slate);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.form-group label i { color: var(--blue); width: 16px; text-align: center; }

input[type="text"], input[type="email"], input[type="password"], input[type="url"],
input[type="number"], input[type="date"], input[type="tel"],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  color: var(--navy);
  background: var(--white);
  transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; min-height: 64px; }
input:disabled, select:disabled, textarea:disabled,
input.readonly, select.readonly, textarea.readonly {
  background: #f8fafc;
  color: var(--muted);
}

/* ─────────── 버튼 ─────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  background: var(--white);
  color: var(--navy);
}
.btn:hover  { box-shadow: var(--shadow); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; box-shadow: none; }

.btn-primary   { background: var(--red);  color: var(--white); box-shadow: 0 2px 6px rgba(230,0,18,.2); }
.btn-primary:hover { background: var(--red-dark); }
.btn-secondary { background: var(--blue); color: var(--white); }
.btn-secondary:hover { background: #1d4ed8; }
.btn-outline   { background: transparent; border-color: var(--line); color: var(--slate); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.btn-ghost     { background: transparent; color: var(--slate); }
.btn-ghost:hover { background: rgba(15,23,42,.05); }
.btn-danger    { background: var(--risk-high); color: var(--white); }

.btn-sm  { padding: 6px 12px; font-size: 13px; }
.btn-xs  { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }

/* ─────────── 패널 ─────────── */
.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 16px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}
.panel-header h3 {
  font-size: 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.panel-header h3 i { color: var(--blue); }
.panel-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel-body { padding: 24px; }

/* ─────────── 토스트 ─────────── */
.toast-stack {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 240px;
  max-width: 360px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  background: var(--white);
  border-left: 4px solid var(--blue);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  display: flex;
  gap: 12px;
  animation: toast-in .25s ease;
}
.toast.success { border-left-color: var(--green); }
.toast.warning { border-left-color: var(--orange); }
.toast.error   { border-left-color: var(--risk-high); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ─────────── 로딩 ─────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────── 상태 배지 ─────────── */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.status-badge.draft           { background: #e2e8f0; color: #334155; }
.status-badge.submitted       { background: #dbeafe; color: #1d4ed8; }
.status-badge.part_approved   { background: #fef3c7; color: #92400e; }
.status-badge.safety_approved { background: #d1fae5; color: #065f46; }
.status-badge.returned        { background: #fecaca; color: #991b1b; }
