* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #ffffff;
  color: #0f172a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard",
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: #e2e8f0;
  border-bottom: 1px solid #cbd5e1;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync-status {
  font-size: 12px;
  color: #64748b;
  min-width: 84px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sync-status.ok { color: #16a34a; }
.sync-status.busy { color: #64748b; }
.sync-status.err { color: #dc2626; }
.sync-status.local { color: #94a3b8; }

select#year-select {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}

select#year-select:hover { border-color: #94a3b8; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: #e2e8f0; color: #0f172a; }
.btn-secondary:hover { background: #cbd5e1; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 4fr 0.7fr;
  grid-template-rows: 1fr;
  gap: 16px;
  padding: 20px 32px;
  min-height: 0;
}

.main-area {
  background: #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #cbd5e1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.months-grid {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 320px;
}

/* 1~12월을 가르는 간격 없이 하나의 박스로 */
.month-boxes {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  flex: 1;
  min-height: 0;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  overflow: hidden;
}

/* 월별 매출액 곡선: 박스 배경 위, 로봇 아이콘 아래에 깔리는 레이어 */
.revenue-curve {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.dropzone {
  min-width: 0;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  padding: 6px 4px 16px;
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: background 0.15s, box-shadow 0.15s;
}

.dropzone::-webkit-scrollbar { width: 6px; }
.dropzone::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.dropzone.drag-over {
  background: rgba(59, 130, 246, 0.08);
  box-shadow: inset 0 0 0 2px #3b82f6;
}

.instance {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  max-width: 100%;
}

.instance-name {
  font-size: 10px;
  line-height: 1.2;
  color: #475569;
  text-align: center;
  max-width: 100%;
  word-break: break-all;
  cursor: text;
  min-height: 0;
}

.instance-name:empty { display: none; }

.instance-name-input {
  font-size: 10px;
  line-height: 1.2;
  border: 1px solid #3b82f6;
  border-radius: 4px;
  padding: 1px 4px;
  width: 70px;
  text-align: center;
  font-family: inherit;
  color: #0f172a;
  background: #ffffff;
  outline: none;
}

.robot-icon {
  width: auto;
  max-width: 100%;
  height: 57px;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
  pointer-events: auto;
  object-fit: contain;
}

.robot-icon:active { cursor: grabbing; }

.robot-icon[data-model="deux"] { height: 66px; }
.palette-icon[data-model="deux"] { height: 84px; }

.dragging { opacity: 0.35; }

.month-price {
  position: relative;
  z-index: 2;
  font-size: 12px;
  font-weight: 600;
  color: #0f172a;
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}

.month-labels {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  margin-top: 14px;
}

.month-label {
  min-width: 0;
  text-align: center;
  font-size: 13px;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}

.month-label .count { color: #0f172a; font-weight: 600; }

.goal-band {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.goal-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #334155;
  font-weight: 500;
  white-space: nowrap;
}

.goal-input-wrap input {
  width: 70px;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  text-align: right;
  font-variant-numeric: tabular-nums;
  background: #ffffff;
  color: #0f172a;
}

.goal-input-wrap input:focus {
  outline: none;
  border-color: #3b82f6;
}

.goal-progress-label {
  font-size: 17px;
  font-weight: 500;
  color: #334155;
  white-space: nowrap;
  line-height: 1;
}

.goal-progress-track {
  flex: 1;
  height: 30px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 15px;
  overflow: hidden;
}

.goal-progress-fill {
  height: 100%;
  background: #3b82f6;
  width: 0;
  transition: width 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.goal-progress-pct {
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.goal-progress-text {
  font-size: 17px;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  min-width: 100px;
  text-align: right;
  line-height: 1;
}

.sidebar {
  background: #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  border: 2px dashed transparent;
  transition: border-color 0.15s, background 0.15s;
  outline: 1px solid #e2e8f0;
}

.sidebar.drag-over {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

.sidebar h2 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  color: #334155;
  text-align: center;
}

.palette-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.palette-item {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.palette-icon {
  width: auto;
  height: 73px;
  cursor: grab;
  user-select: none;
  object-fit: contain;
}

.palette-icon:active { cursor: grabbing; }

.palette-label {
  font-size: 13px;
  color: #334155;
  font-weight: 500;
}

.palette-hint {
  margin: 16px 0 0;
  font-size: 11px;
  line-height: 1.6;
  color: #94a3b8;
  text-align: center;
}

footer {
  background: #e2e8f0;
  border-radius: 12px;
  padding: 18px 24px;
  margin: 0 32px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  border: 1px solid #cbd5e1;
}

.summary-breakdown {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 14px;
}

.summary-breakdown .pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #ffffff;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
}

.summary-breakdown .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.summary-breakdown .name { color: #334155; }
.summary-breakdown .value { color: #0f172a; font-weight: 600; font-variant-numeric: tabular-nums; }

.summary-totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.summary-total {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.summary-total-price {
  font-size: 15px;
  font-weight: 600;
  color: #334155;
  font-variant-numeric: tabular-nums;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.visible { display: flex; }

.modal {
  background: #ffffff;
  border-radius: 12px;
  padding: 24px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.15);
  border: 1px solid #cbd5e1;
}

.modal h3 { margin: 0 0 12px; font-size: 18px; }
.modal p { margin: 0 0 20px; color: #475569; font-size: 14px; line-height: 1.6; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* 판매 축하 폭죽/색종이 — 클릭을 가로막지 않도록 포인터 이벤트를 끈다 */
.celebration-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1000;
}

/* 새로고침 버튼 — xyz-brand·loungex-brand 와 같은 모양(파란 알약 + 아이콘, 누르면 아이콘이 한 바퀴) */
.refresh-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: #4263eb; color: #fff;
  border: 0; border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  white-space: nowrap;
}
.refresh-btn:hover { background: #3651c8; transform: translateY(-1px); }
.refresh-btn:active { transform: translateY(0); }
.refresh-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.refresh-btn .refresh-icon { width: 14px; height: 14px; transition: transform 0.6s; }
.refresh-btn.spinning .refresh-icon { transform: rotate(360deg); }
